Date and time functions :: Kloudfuse Docs
Date and time functions
Date and time functions expose the evaluation clock and sample timestamps, enabling age calculations and time-dependent alert conditions. All values are UTC.
day_of_month
Returns the day of the month (1–31), UTC, for each sample’s timestamp. Called with no argument, it uses the query evaluation time. Date functions gate time-dependent alert rules — for example, suppressing a batch-job alert on weekends.
Syntax
day_of_month([<vector of timestamps>])
Parameters
| Parameter | Required | Description |
|---|---|---|
<vector> |
Optional | Timestamps to convert; defaults to the evaluation time. |
Example
Return the current day of the month in UTC.
day_of_month()
| Value |
|---|
| 4 |
Expected output
| All date functions operate in UTC. |
day_of_week
Returns the day of the week (0–6, Sunday = 0), UTC, for each sample’s timestamp. Called with no argument, it uses the query evaluation time. Date functions gate time-dependent alert rules — for example, suppressing a batch-job alert on weekends.
Syntax
day_of_week([<vector of timestamps>])
Parameters
| Parameter | Required | Description |
|---|---|---|
<vector> |
Optional | Timestamps to convert; defaults to the evaluation time. |
Example
Return the current day of the week in UTC.
day_of_week()
| Value |
|---|
| 6 |
Expected output
| All date functions operate in UTC. |
day_of_year
Returns the day of the year (1–366), UTC, for each sample’s timestamp. Called with no argument, it uses the query evaluation time. Date functions gate time-dependent alert rules — for example, suppressing a batch-job alert on weekends.
Syntax
day_of_year([<vector of timestamps>])
Parameters
| Parameter | Required | Description |
|---|---|---|
<vector> |
Optional | Timestamps to convert; defaults to the evaluation time. |
Example
Return the current day of the year in UTC.
day_of_year()
| Value |
|---|
| 185 |
Expected output
| All date functions operate in UTC. |
days_in_month
Returns the number of days in the month (28–31), UTC, for each sample’s timestamp. Called with no argument, it uses the query evaluation time. Date functions gate time-dependent alert rules — for example, suppressing a batch-job alert on weekends.
Syntax
days_in_month([<vector of timestamps>])
Parameters
| Parameter | Required | Description |
|---|---|---|
<vector> |
Optional | Timestamps to convert; defaults to the evaluation time. |
Example
Return the current number of days in the month in UTC.
days_in_month()
| Value |
|---|
| 31 |
Expected output
| All date functions operate in UTC. |
hour
Returns the hour of the day (0–23), UTC, for each sample’s timestamp. Called with no argument, it uses the query evaluation time. Date functions gate time-dependent alert rules — for example, suppressing a batch-job alert on weekends.
Syntax
hour([<vector of timestamps>])
Parameters
| Parameter | Required | Description |
|---|---|---|
<vector> |
Optional | Timestamps to convert; defaults to the evaluation time. |
Example
Return the current hour of the day in UTC.
hour()
| Value |
|---|
| 19 |
Expected output
| All date functions operate in UTC. |
minute
Returns the minute of the hour (0–59), UTC, for each sample’s timestamp. Called with no argument, it uses the query evaluation time. Date functions gate time-dependent alert rules — for example, suppressing a batch-job alert on weekends.
Syntax
minute([<vector of timestamps>])
Parameters
| Parameter | Required | Description |
|---|---|---|
<vector> |
Optional | Timestamps to convert; defaults to the evaluation time. |
Example
Return the current minute of the hour in UTC.
minute()
| Value |
|---|
| 55 |
Expected output
| All date functions operate in UTC. |
month
Returns the month of the year (1–12), UTC, for each sample’s timestamp. Called with no argument, it uses the query evaluation time. Date functions gate time-dependent alert rules — for example, suppressing a batch-job alert on weekends.
Syntax
month([<vector of timestamps>])
Parameters
| Parameter | Required | Description |
|---|---|---|
<vector> |
Optional | Timestamps to convert; defaults to the evaluation time. |
Example
Return the current month of the year in UTC.
month()
| Value |
|---|
| 7 |
Expected output
| All date functions operate in UTC. |
time
Returns the evaluation timestamp of the query in Unix seconds, as a scalar. The standard building block for age calculations: time() - <timestamp metric> gives seconds since an event.
Syntax
time()
Example
Return the evaluation time as a chartable vector.
vector(time())
| Value |
|---|
| 1,783,194,966 |
Expected output
time() is a scalar; wrap it in vector() to chart it or compare it against vectors. |
timestamp
Replaces every sample’s value with that sample’s timestamp in Unix seconds, preserving labels. Combined with time(), it measures data freshness: how old is the newest sample of each series.
Syntax
timestamp(<expr>)
Example
Measure the age in seconds of the newest query-service goroutine sample — small values mean fresh data.
time() - max(timestamp(go_goroutines{app_kubernetes_io_name="query-service"}))
| Value |
|---|
| 0 |
Expected output
year
Returns the year, UTC, for each sample’s timestamp. Called with no argument, it uses the query evaluation time. Date functions gate time-dependent alert rules — for example, suppressing a batch-job alert on weekends.
Syntax
year([<vector of timestamps>])
Parameters
| Parameter | Required | Description |
|---|---|---|
<vector> |
Optional | Timestamps to convert; defaults to the evaluation time. |
Example
Return the current year in UTC.
year()
| Value |
|---|
| 2026 |
Expected output
| All date functions operate in UTC. |