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