Relative Time Syntax
Relative time syntax allows you to specify a time interval as a duration relative to a specific endpoint, typically the current moment ("now"). This syntax is versatile and can be used in various parts of the platform, including:
Specifying the time range for a query using the UI or API.
Defining the length of the span for buckets when using functions like
timeChart()
orbucket()
To make specifying a time more flexible, LogScale supports a relative time syntax. This lets you express a simple time duration, rather than specifying two absolute times.
You specify a relative time modifier as a number followed by a word. The following table shows which words you can use:
Time Unit | Accepted Values | Notes |
---|---|---|
Milliseconds |
millisecond ,
milliseconds ,
millis ,
ms
| |
Seconds |
second ,
seconds ,
s ,
sec ,
secs
| |
Minutes |
minute ,
minutes ,
m ,
min
| |
Hours |
hour ,
hours ,
h ,
hr ,
hrs
| |
Days |
day ,
days ,
d
| Interpreted as 24h in milliseconds |
Weeks |
week ,
weeks ,
w
| Interpreted as 7 days in milliseconds |
Months |
month ,
months ,
mon
| Interpreted as 30 days in milliseconds |
Quarters |
quarter ,
quarters ,
q ,
qtr ,
qtrs
| Interpreted as 90 days in milliseconds |
Years |
year ,
years ,
y ,
yr ,
yrs
| Interpreted as 365 days in milliseconds |
You can include a space character between the number and the unit of time.
Relative Time Syntax Examples
Two hours:
2h
Two hours:
2 hours
Three weeks:
3 weeks
Ten seconds:
10s
Ten seconds:
10seconds
Regular Expression
This regular expression describes the format:
^(\d+) ?(years?
| y
| yrs?
| quarters?
| q
| qtrs?
| months?
| mon
| weeks?
| w
| days?
| d
| hours?
| hr?
| hrs
| minutes?
| m
| min
| seconds?
| s
| secs?
| milliseconds?
| millis
| ms)$