All Products
Search
Document Center

Simple Log Service:PromQL function usage examples

Last Updated:Apr 01, 2025

Simple Log Service provides PromQL functions to process metrics. This topic introduces common examples of PromQL functions.

abs()

Calculates the absolute value of all points in time series data.

avg(container_network_receive_bytes_total{})

changes()

Counts the number of times a value changes within the input time range.

changes(demo_api_request_duration_seconds_count[1m])

absent()

Checks whether data points are missing at the corresponding time. If data is missing, it returns 1.

absent(test_metrics)

absent_over_time()

Checks whether data points are missing within the input time range. If data is missing, it returns 1.

absent_over_time(test_metrics[1m])

ceil()

Calculates the ceiling value of all time series data points at the specified time.

ceil(process_start_time_seconds)

clamp()

This function requires upper and lower limit values. If the actual metric value exceeds this range, it takes the input maximum and minimum values.

clamp(process_start_time_seconds,10,20)

clamp_max()

This function is similar to the clamp() function, but only limits the maximum value.

clamp_max(process_start_time_seconds,20)

clamp_min()

This function is similar to clamp(), but only limits the minimum value.

clamp_min(process_start_time_seconds,10)

day_of_month()

This function requires a time series metric value representing a timestamp. It calculates which day of the month the corresponding timestamp is.

day_of_month(vector(1805308033))

day_of_week()

This function requires a time series metric value representing a timestamp. It calculates which day of the week the corresponding timestamp is.

day_of_week(vector(1805308033))

day_of_year()

This function requires a time series metric value representing a timestamp. It calculates which day of the year the corresponding timestamp is.

day_of_year(vector(1805308033))

delta()

Calculates the difference between the first and last values in the input time range.

delta(go_memstats_heap_released_bytes[1m])

deriv()

Calculates the second derivative of each time series in a time interval.

deriv(go_memstats_heap_released_bytes[1m])

exp()

Performs exponential calculation.

exp(go_memstats_lookups_total)

floor()

Calculates the floor value of all time series data points at the specified time.

floor(go_memstats_heap_released_bytes)

holt_winters()

Calculates a smoothed value based on data points in the input time range. The calculation method is based on the Holt-Winters algorithm.

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

rate()

Calculates the rate of change of metric values within the input time range.

rate(go_memstats_mallocs_total[3m])

idelta()

Calculates the difference between the last two values in the input time range.

idelta(go_memstats_mallocs_total[3m])

increase()

Calculates the increase in metric values within the input time range. This function is only suitable for incrementing numeric metrics. If the value decreases within the time range, it will be cumulatively added.

increase(go_memstats_mallocs_total[3m])

irate()

Calculates the rate of change of metric values within the input time range, but only uses the last two values for calculation.

irate(go_memstats_mallocs_total[3m])

hour()

This function requires a time series metric value representing a timestamp. It calculates which hour of the day the corresponding timestamp is.

hour(vector[1705308033])

minute()

This function requires a time series metric value representing a timestamp. It calculates which minute of the hour the corresponding timestamp is.

minute(vector[1705308033])

month()

This function requires a time series metric value representing a timestamp. It calculates which month of the year the corresponding timestamp is.

month(vector[1705308033])

resets()

Counts the number of times the metric point value decreases within the input time range.

resets(go_memstats_heap_sys_bytes[5m])

round()

This function requires an additional parameter value to_nearest. It calculates the value closest to an integer multiple of to_nearest for the metric value.

round(go_memstats_heap_sys_bytes)