roundInterval
Description
Returns an interval rounded down to a specified precision. All time units smaller than the specified timeunit
are zeroed out.
Syntax
Like many functions in DataPrime, roundInterval
supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.
Arguments
Name | Type | Required | Description |
---|---|---|---|
interval | interval | true | The interval to round |
scale | timeunit | true | The unit to round to, zeroing out smaller units |
Example
Use case: Bucket intervals into whole hours
Logs contain a time_taken
interval. Use roundInterval
to reduce precision to hours, then format and group by these buckets.
[
{ "time_taken": "2h10m15s" },
{ "time_taken": "3h8m15s" },
{ "time_taken": "5d2h22m46s" },
{ "time_taken": "53m15s" }
]
Output
[
{ "time_taken": "2h10m15s", "time_bucket": "2h" },
{ "time_taken": "5d2h22m46s", "time_bucket": "5d2h" },
{ "time_taken": "3h10m15s", "time_bucket": "3h" },
{ "time_taken": "53m15s", "time_bucket": "0ns" }
]
Theme
Light