rate(), which calculates the
per-second average rate of increase of the multiple time series in a range vector.
The following query calculates the per-second average rate of increase over the last
10 minutes for the matching metric name with a device label whose value is equal
to eth0:
Aggregating time series
Use PromQL aggregation functions to reduce the elements in a vector returned by a query. For example, a popular aggregation function issum(), which totals the values of
resulting time series from a query and returns one element.
The following query returns the total values of all time series with an offset of
five minutes ago that match the metric name with a value for the device label
that matches the value eth0:
avg(), which averages the values of resulting time
series from a query and returns one element.
You can group time series by labels, returning an element for each unique value of
the label using the by or without clause in a query.
by: Groups time series by the labels you specify.without: Groups or every other labels that has differing values.
device label equal to eth0 grouped by unique
values for the k8s_cluster label:
The interval you define in functions such as
rate() and increase() must be greater
than or equal to the scrape interval of the metrics which you apply the function
to. The recommendation is to use at least twice the scrape interval.Querying histograms
The Chronosphere Observability Platform histogram metric type persists a histogram as one data point and one time series. Query methods depend on the type of histogram you’re querying.Querying histogram metric types
A histogram of the histogram metric type is a single structured value that contains all of the information about the histogram. The Observability Platform histogram metric type supports Prometheus native histograms and OpenTelemetry exponential histograms. To query histograms in Observability Platform, use PromQL histogram functions. The following querying examples use a histogram metric namedhttp_request_duration_seconds.
If the metric being queried instead uses delta temporality, replace uses of the
rate() function in these examples with sum_per_second() and ensure that the
step value equals the sliding time window’s value. For more information, see
Querying delta temporality metrics.
Rate of HTTP requests
Use thehistogram_count() function to calculate the rate of HTTP requests:
Average HTTP request duration
Use thehistogram_avg() function to query the average HTTP request duration:
90th percentile HTTP request duration
Use thehistogram_quantile() function to query the 90th percentile HTTP request
duration by HTTP method and request path:
Percentage of HTTP requests under given latency
Service level objectives are commonly defined in tolerances by percentile, such as delivering 90% of requests in less than 200 ms and 99% of requests in less than 500 ms. Use thehistogram_fraction() function to calculate the percentage of requests
with responses in 200 ms or less:
Querying classic Prometheus histograms
If you’re querying a histogram with a metric name ending in_bucket, you’re querying
a classic Prometheus histogram.
A classic Prometheus histogram is composed of individual counter time series and
stored as separate time series. For example, if your histogram aggregates HTTP
request observations and is named http_request_duration_seconds, the resulting
time series is:
http_request_duration_seconds_bucketwith a time series for each unique bucket. The time series has a label namedlewhose value represents the bucket’s upper boundary.http_request_duration_seconds_sum, the sum of all observed values.http_request_duration_seconds_count, the total count of all observed values.
http_request_duration_seconds as an example, you can write the following
PromQL queries:
Rate of HTTP requests (legacy)
Use therate() function and the _count time series to calculate the rate of HTTP
requests: