diff --git a/docs/configuration/recording_rules.md b/docs/configuration/recording_rules.md index 4cf801b97..4416988d4 100644 --- a/docs/configuration/recording_rules.md +++ b/docs/configuration/recording_rules.md @@ -62,7 +62,7 @@ groups: - name: example rules: - record: job:http_inprogress_requests:sum - expr: sum(http_inprogress_requests) by (job) + expr: sum by (job) (http_inprogress_requests) ``` ### `` diff --git a/docs/migration.md b/docs/migration.md index 2c1a8848b..3bc18ddd5 100644 --- a/docs/migration.md +++ b/docs/migration.md @@ -88,7 +88,7 @@ An example of a recording rule and alert in the old format: ``` job:request_duration_seconds:histogram_quantile99 = - histogram_quantile(0.99, sum(rate(request_duration_seconds_bucket[1m])) by (le, job)) + histogram_quantile(0.99, sum by (le, job) (rate(request_duration_seconds_bucket[1m]))) ALERT FrontendRequestLatency IF job:request_duration_seconds:histogram_quantile99{job="frontend"} > 0.1 @@ -105,8 +105,7 @@ groups: - name: example.rules rules: - record: job:request_duration_seconds:histogram_quantile99 - expr: histogram_quantile(0.99, sum(rate(request_duration_seconds_bucket[1m])) - BY (le, job)) + expr: histogram_quantile(0.99, sum by (le, job) (rate(request_duration_seconds_bucket[1m]))) - alert: FrontendRequestLatency expr: job:request_duration_seconds:histogram_quantile99{job="frontend"} > 0.1 for: 5m diff --git a/docs/querying/api.md b/docs/querying/api.md index 60827aa7a..bd1c67987 100644 --- a/docs/querying/api.md +++ b/docs/querying/api.md @@ -523,7 +523,7 @@ $ curl http://localhost:9090/api/v1/rules { "health": "ok", "name": "job:http_inprogress_requests:sum", - "query": "sum(http_inprogress_requests) by (job)", + "query": "sum by (job) (http_inprogress_requests)", "type": "recording" } ], diff --git a/docs/querying/functions.md b/docs/querying/functions.md index 7481e71ed..419823430 100644 --- a/docs/querying/functions.md +++ b/docs/querying/functions.md @@ -166,11 +166,11 @@ around the `rate()` function. Since the `le` label is required by `histogram_quantile()`, it has to be included in the `by` clause. The following expression aggregates the 90th percentile by `job`: - histogram_quantile(0.9, sum(rate(http_request_duration_seconds_bucket[10m])) by (job, le)) + histogram_quantile(0.9, sum by (job, le) (rate(http_request_duration_seconds_bucket[10m]))) To aggregate everything, specify only the `le` label: - histogram_quantile(0.9, sum(rate(http_request_duration_seconds_bucket[10m])) by (le)) + histogram_quantile(0.9, sum by (le) (rate(http_request_duration_seconds_bucket[10m]))) The `histogram_quantile()` function interpolates quantile values by assuming a linear distribution within a bucket. The highest bucket