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

-- stderr.txt --
level=INFO msg="Loading configuration file" path=.pint.hcl
level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl
level=INFO msg="Finding all rules to check" paths=["rules"]
level=DEBUG msg="File parsed" path=rules/0001.yaml rules=1
level=DEBUG msg="Glob finder completed" count=1
level=INFO msg="Checking Prometheus rules" entries=1 workers=10 online=true
level=DEBUG msg="Generated all Prometheus servers" count=0
level=DEBUG msg="Found recording rule" path=rules/0001.yaml record=colo_job:up:byinstance lines=6-7 state=noop
level=DEBUG msg="Configured checks for rule" enabled=["promql/syntax","alerts/for","alerts/comparison","alerts/template","promql/fragile","promql/regexp","promql/impossible","promql/aggregate(job:true)"] path=rules/0001.yaml rule=colo_job:up:byinstance
Bug: required label is being removed via aggregation (promql/aggregate)
  ---> rules/0001.yaml:7 -> `colo_job:up:byinstance`
7 |     expr: sum(byinstance) by(instance)
                              ^^ 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="Problems found" Bug=1
level=ERROR msg="Execution completed with error(s)" err="found 1 problem(s) with severity Bug or higher"
-- rules/0001.yaml --
groups:
- name: foo
  rules:

  # pint disable promql/aggregate(job:true)
  - record: colo_job:up:byinstance
    expr: sum(byinstance) by(instance)

-- .pint.hcl --
rule {
    locked = true
    aggregate ".+" {
        keep     = [ "job" ]
        severity = "bug"
    }
}
