From c792af3ad0f34309549347835627624a44afe5ba Mon Sep 17 00:00:00 2001 From: lpugoy <44182754+lpugoy@users.noreply.github.com> Date: Thu, 4 May 2023 22:35:36 +1000 Subject: [PATCH] grafana-mixin: Fix expression for GrafanaRequestsFailing alert (#63382) Fix expression for GrafanaRequestsFailing alert The intent of the alert is to get the ratio of 5xx to all status codes [^1]. With the original expression, the left hand side can have more than one row with the same labels except for the status code. This results in a promql error because it is doing a many-to-one matching. Doing a sum on the left hand side first should preserve the intent of the alert and resolve the issue. [^1]: https://github.com/grafana/grafana/pull/43116 --- grafana-mixin/alerts/alerts.libsonnet | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grafana-mixin/alerts/alerts.libsonnet b/grafana-mixin/alerts/alerts.libsonnet index fbd957b4fb9..1c92a59bf51 100644 --- a/grafana-mixin/alerts/alerts.libsonnet +++ b/grafana-mixin/alerts/alerts.libsonnet @@ -11,8 +11,8 @@ { alert: 'GrafanaRequestsFailing', expr: ||| - 100 * namespace_job_handler_statuscode:grafana_http_request_duration_seconds_count:rate5m{handler!~"/api/datasources/proxy/:id.*|/api/ds/query|/api/tsdb/query", status_code=~"5.."} - / ignoring (status_code) group_left + 100 * sum without (status_code) (namespace_job_handler_statuscode:grafana_http_request_duration_seconds_count:rate5m{handler!~"/api/datasources/proxy/:id.*|/api/ds/query|/api/tsdb/query", status_code=~"5.."}) + / sum without (status_code) (namespace_job_handler_statuscode:grafana_http_request_duration_seconds_count:rate5m{handler!~"/api/datasources/proxy/:id.*|/api/ds/query|/api/tsdb/query"}) > %(grafanaRequestsFailingThresholdPercent)s ||| % $._config,