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.
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.
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.
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.
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.
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.
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.
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.
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.
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.