Simple Log Service (SLS) provides PromQL functions to process metrics in Metricstores. This topic describes common examples of PromQL functions.
abs()
The abs() function calculates the absolute value of all points in time series data.
abs(container_network_receive_bytes_total{})changes()
The changes() function counts the number of times the value changes within the input time range.
changes(demo_api_request_duration_seconds_count[1m])absent()
The absent() function checks whether data points are missing at the corresponding time for each time series. If data is missing, it returns 1.
absent(test_metrics)absent_over_time()
The absent_over_time() function 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()
The ceil() function calculates the ceiling value of all time series data points at the specified time point.
ceil(process_start_time_seconds)clamp()
The clamp(v instant-vector, min scalar, max scalar) function requires upper and lower limit values. If the actual metric value exceeds this range, it directly takes the input maximum and minimum values.
clamp(process_start_time_seconds,10,20)clamp_max()
The clamp_max(v instant-vector, max scalar) function is similar to the clamp function, but only limits the maximum value.
clamp_max(process_start_time_seconds,10)clamp_min()
The clamp_min(v instant-vector, min scalar) function is similar to the clamp function, but only limits the minimum value.
clamp_min(process_start_time_seconds,10)day_of_month()
The day_of_month() function requires a time series metric value representing a timestamp. This function calculates which day of the month the corresponding timestamp is.
day_of_month(vector(1805308033))day_of_week()
The day_of_week() function requires a time series metric value representing a timestamp. This function calculates which day of the week the corresponding timestamp is.
day_of_week(vector(1805308033))day_of_year()
The day_of_year() function requires a time series metric value representing a timestamp. This function calculates which day of the year the corresponding timestamp is.
day_of_year(vector(1805308033))delta()
The delta() function calculates the difference between the first and last values in the input time range.
delta(go_memstats_heap_released_bytes[1m])deriv()
The deriv() function calculates the second derivative of each time series in a time interval.
deriv(go_memstats_heap_released_bytes[1m])exp()
The exp() function performs exponential calculations.
exp(go_memstats_lookups_total)floor()
The floor() function calculates the floor value of all time series data points at the specified time point.
floor(go_memstats_heap_released_bytes)holt_winters()
The holt_winters() function calculates a smoothed value based on the data points in the input time range. The calculation method is based on the holt_winter algorithm.
holt_winters(go_memstats_heap_released_bytes[3m],0.2,0.5)rate()
The rate function calculates the rate of change of metric value points within the input time range.
rate(go_memstats_mallocs_total[3m])idelta()
The idelta() function calculates the difference between the last two values in the input time range.
idelta(go_memstats_mallocs_total[3m])increase()
The increase() function calculates the increase in metric value points within the input time range. This function is only applicable to incrementing numeric metrics. If the value decreases within the time range, it will be cumulatively added.
increase(go_memstats_mallocs_total[3m])irate()
The irate function calculates the rate of change of metric value points within the input time range, but the irate function only uses the last two values for calculation.
irate(go_memstats_mallocs_total[3m])hour()
The hour() function requires a time series metric value representing a timestamp. This function calculates which hour of the day the corresponding timestamp is.
hour(vector[1705308033])minute()
The minute() function requires a time series metric value representing a timestamp. This function calculates which minute of the hour the corresponding timestamp is.
minute(vector[1705308033])month()
The month() function requires a time series metric value representing a timestamp. This function calculates which month of the year the corresponding timestamp is.
month(vector[1705308033])resets()
The resets function counts the number of times the metric point value decreases within the input time range.
resets(go_memstats_heap_sys_bytes[5m])round()
The round() function requires an additional parameter value to_nearest. This function calculates the value closest to an integer multiple of to_nearest for the metric value.
round(go_memstats_heap_sys_bytes)