! 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=2 workers=10 online=true
Bug: required annotation not set (alerts/annotation)
  ---> rules/0001.yml:6-13 -> `InstanceDown` [+1 duplicates]
13 |       description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes."
           ^^^ `link` annotation is required.

Warning: required label is being removed via aggregation (promql/aggregate)
  ---> rules/0001.yml:17 -> `APIHighRequestLatency`
17 |     expr: sum by (instance) (http_inprogress_requests) > 0
                   ^^^ Query is using aggregation with `by(instance)`, only labels included inside `by(...)` will be present on the results.
                       `job` label is required and should be preserved when aggregating all rules.

level=INFO msg="Some problems are duplicated between rules and all the duplicates were hidden, pass `--show-duplicates` to see them" total=3 duplicates=1 shown=2
level=INFO msg="Problems found" Bug=2 Warning=1
level=ERROR msg="Execution completed with error(s)" err="found 2 problem(s) with severity Bug or higher"
-- rules/0001.yml --
groups:
- name: example
  rules:

  # Alert for any instance that is unreachable for >5 minutes.
  - alert: InstanceDown
    expr: up == 0
    for: 5m
    labels:
      severity: page
    annotations:
      summary: "Instance {{ $labels.instance }} down"
      description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes."

  # Alert for any instance that has a median request latency >1s.
  - alert: APIHighRequestLatency
    expr: sum by (instance) (http_inprogress_requests) > 0
    for: 10m
    annotations:
      summary: "High request latency on {{ $labels.instance }}"
      description: "{{ $labels.instance }} has a median request latency above 1s (current value: {{ $value }}s)"

-- .pint.hcl --
rule {
    aggregate ".+" {
        keep = [ "job" ]
    }
}
rule {
    aggregate "colo(?:_.+)?:.+" {
        strip = [ "instance" ]
    }
    annotation "link" {
        required = true
        severity = "bug"
    }
}
