! exec pint --no-color lint rules
! stdout .
cmp stderr stderr.txt

-- stderr.txt --
level=INFO msg="Loading configuration file" path=.pint.hcl
level=INFO msg="Finding all rules to check" paths=["rules"]
level=INFO msg="Checking Prometheus rules" entries=4 workers=10 online=true
Bug: required annotation not set (alerts/annotation)
  ---> rules/1.yml:22-23 -> `Example_High_Restart_Rate` [+1 duplicates]
23 | expr: sum(rate(kube_pod_container_status_restarts_total{namespace="example-app"}[5m])) > ( 3/60 )
           ^^^ `summary` annotation is required.

Bug: required label not set (rule/label)
  ---> rules/1.yml:22-23 -> `Example_High_Restart_Rate` [+1 duplicates]
23 | expr: sum(rate(kube_pod_container_status_restarts_total{namespace="example-app"}[5m])) > ( 3/60 )
           ^^^ `priority` label is required.

Fatal: PromQL syntax error (promql/syntax)
  ---> rules/1.yml:25 -> `Invalid Query`
25 | expr: sum(rate(kube_pod_container_status_restarts_total{namespace="example-app"}[5m]) / x
                                                                                             ^
                                                                     unclosed left parenthesis

Fatal: This rule is not a valid Prometheus rule: `duplicated expr key`. (yaml/parse)
  ---> rules/1.yml:28
 28 |             expr: sum(rate(kube_pod_container_status_restarts_total{namespace="example-app"}[5m])) > ( 3/60 )
      ^^^ This rule is not a valid Prometheus rule: `duplicated expr key`.

level=INFO msg="Some problems are duplicated between rules and all the duplicates were hidden, pass `--show-duplicates` to see them" total=6 duplicates=2 shown=4
level=INFO msg="Problems found" Fatal=2 Bug=4
level=ERROR msg="Execution completed with error(s)" err="found 6 problem(s) with severity Bug or higher"
-- rules/1.yml --
---
kind: ConfigMap
apiVersion: v1
metadata:
  name: example-app-alerts
  labels:
  app: example-app
data:
  alerts: |
    groups:
      - name: example-app-alerts
        rules:
          - alert: Example_Is_Down
            expr: kube_deployment_status_replicas_available{namespace="example-app"} < 1
            for: 5m
            labels:
              priority: "2"
              environment: production
            annotations:
              summary: "No replicas for Example have been running for 5 minutes"

          - alert: Example_High_Restart_Rate
            expr: sum(rate(kube_pod_container_status_restarts_total{namespace="example-app"}[5m])) > ( 3/60 )
          - alert: Invalid Query
            expr: sum(rate(kube_pod_container_status_restarts_total{namespace="example-app"}[5m]) / x
          - alert: Duplicated Expr
            expr: sum(rate(kube_pod_container_status_restarts_total{namespace="example-app"}[5m])) > ( 3/60 )
            expr: sum(rate(kube_pod_container_status_restarts_total{namespace="example-app"}[5m])) > ( 3/60 )

-- .pint.hcl --
parser {
  relaxed = [".*"]
}
rule {
  match { kind = "alerting" }
  label "priority" {
    severity = "bug"
    value    = "(1|2|3|4|5)"
    required = true
  }
  annotation "summary" {
    severity = "bug"
    required = true
  }
}
