apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: grafana-rules
  namespace: logging
spec:
  groups:
    - name: grafana.rules
      interval: 15s
      rules:
        - alert: GrafanaHighErrorRate
          expr: |
            (
              sum(rate(grafana_http_request_total{status=~"5.."}[5m]))
              /
              sum(rate(grafana_http_request_total[5m]))
            ) > 0.05
          for: 10m
          labels:
            severity: warning
          annotations:
            summary: "High error rate on Grafana"
            description: "5xx error rate exceeded 5% for 10 minutes. Value: {{ $value | humanizePercentage }}"
