Overview
Time ranges in Slung allow you to filter data to specific time windows. Ranges are optional and support both absolute timestamps and relative time expressions.Syntax
Time ranges are specified as the fourth component of a query, enclosed in square brackets:start and end can be:
- Absolute timestamps (microseconds since Unix epoch)
- The special keyword
now - Relative time expressions (e.g.,
1m,2h,3d)
Time ranges are automatically normalized, so the order of start and end doesn’t matter.
[now,1m] is equivalent to [1m,now].Absolute Timestamps
Provide Unix timestamps in microseconds:1700000000 to 1700000100 (microseconds).
The now Keyword
Use now to reference the current time:
Relative Time Expressions
Relative time expressions let you specify durations relative tonow. The format is:
<amount> is a positive integer and <unit> is one of the supported time units.
Supported Time Units
Seconds
s,sec,secs,second,seconds- 1 second = 1,000,000 microseconds
Minutes
m,min,mins,minute,minutes- 1 minute = 60 seconds
Hours
h,hr,hrs,hour,hours- 1 hour = 60 minutes
Days
d,day,days- 1 day = 24 hours
Weeks
w,wk,wks,week,weeks- 1 week = 7 days
Whitespace in Relative Times
Whitespace is flexible and optional:Real-World Examples
Last Hour of CPU Data
Last Week with Specific Tags
enabled tag is present.
Reversing Start and End
[24h,now].
Custom Time Window
Queries Without Time Ranges
Time ranges are optional. Omit the range to query all available data:enabled tag.
Implementation Details
Time Calculation
Relative times are calculated by:- Converting the amount and unit to seconds
- Multiplying by 1,000,000 to get microseconds
- Subtracting from the current time (
now)
2matnow = 10,000,000,000microseconds- Calculation:
10,000,000,000 - (2 * 60 * 1,000,000) = 9,880,000,000 - Range:
[9,880,000,000, 10,000,000,000]
Normalization
After parsing both start and end values, the range is normalized:start <= end regardless of input order.
Error Handling
Invalid time range syntax will return an error:Related Topics
Query Syntax
Complete query DSL reference
Tags
Tag filtering syntax