All Products
Search
Document Center

Simple Log Service:PromQL function usage examples

Last Updated:Jun 04, 2026

Simple Log Service (SLS) supports PromQL functions for querying and processing metrics stored in Metricstores. This topic provides usage examples for common PromQL functions.

abs()

Returns the absolute value of each data point in the input time series.

abs(container_network_receive_bytes_total{})

changes()

Returns the number of times each time series value changes within the specified time range.

changes(demo_api_request_duration_seconds_count[1m])

absent()

Returns an empty vector if the input vector has any elements. Returns a 1-element vector with the value 1 if the input vector has no elements. Use this function to alert when a metric has no data.

absent(test_metrics)

absent_over_time()

Returns 1 if there are no data points within the specified time range. Returns an empty vector otherwise. Use this function to detect gaps in metric data over a range.

absent_over_time(test_metrics[1m])

ceil()

Rounds each data point up to the nearest integer.

ceil(process_start_time_seconds)

clamp()

Clamps each data point to a specified range. Values below min are set to min; values above max are set to max.

Syntax: clamp(v instant-vector, min scalar, max scalar)

clamp(process_start_time_seconds,10,20)

clamp_max()

Clamps each data point to a maximum value. Values above max are set to max. Similar to clamp(), but applies an upper bound only.

Syntax: clamp_max(v instant-vector, max scalar)

clamp_max(process_start_time_seconds,10)

clamp_min()

Clamps each data point to a minimum value. Values below min are set to min. Similar to clamp(), but applies a lower bound only.

Syntax: clamp_min(v instant-vector, min scalar)

clamp_min(process_start_time_seconds,10)

day_of_month()

Returns the day of the month (1–31) for each timestamp in the input time series.

day_of_month(vector(1805308033))

day_of_week()

Returns the day of the week (0–6, where 0 is Sunday) for each timestamp in the input time series.

day_of_week(vector(1805308033))

day_of_year()

Returns the day of the year (1–365) for each timestamp in the input time series.

day_of_year(vector(1805308033))

delta()

Returns the difference between the first and last data points within the specified time range. Use with gauges.

delta(go_memstats_heap_released_bytes[1m])

deriv()

Returns the per-second derivative of each time series in the range vector, calculated using simple linear regression. Use with gauges.

deriv(go_memstats_heap_released_bytes[1m])

exp()

Returns the exponential function e^x for each data point in the input time series.

exp(go_memstats_lookups_total)

floor()

Rounds each data point down to the nearest integer.

floor(go_memstats_heap_released_bytes)

holt_winters()

Produces a smoothed value for each time series using double exponential smoothing (Holt-Winters algorithm). The smoothing factor sf controls how much weight is given to older data (lower = more weight on old data); the trend factor tf controls how strongly trends are followed. Both sf and tf must be between 0 and 1. Use with gauges.

Syntax: holt_winters(v range-vector, sf scalar, tf scalar)

holt_winters(go_memstats_heap_released_bytes[3m],0.2,0.5)

rate()

Returns the per-second average rate of increase of the counter over the specified time range. Accounts for counter resets. Use with counters.

rate(go_memstats_mallocs_total[3m])

idelta()

Returns the difference between the last two data points within the specified time range.

idelta(go_memstats_mallocs_total[3m])

increase()

Returns the total increase of a counter over the specified time range. Counter resets (where the value drops to zero and resumes counting) are automatically accounted for. Use with counters only.

increase(go_memstats_mallocs_total[3m])

irate()

Returns the per-second instantaneous rate of increase, calculated from the last two data points in the range. Use with fast-moving counters and for graphing. For alerting or slow-moving counters, use rate() instead.

irate(go_memstats_mallocs_total[3m])

hour()

Returns the hour of the day (0–23 UTC) for each timestamp in the input time series.

hour(vector[1705308033])

minute()

Returns the minute of the hour (0–59 UTC) for each timestamp in the input time series.

minute(vector[1705308033])

month()

Returns the month of the year (1–12 UTC) for each timestamp in the input time series.

month(vector[1705308033])

resets()

Returns the number of counter resets within the specified time range. A reset occurs when the counter value drops between two consecutive data points. Use with counters.

resets(go_memstats_heap_sys_bytes[5m])

round()

Rounds each data point to the nearest multiple of to_nearest. If to_nearest is omitted, rounds to the nearest integer.

Syntax: round(v instant-vector, to_nearest=1 scalar)

round(go_memstats_heap_sys_bytes)