! 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=1 workers=10 online=true
Warning: required label is being removed via aggregation (promql/aggregate)
  ---> rules/0001.yml:5 -> `colo:http_inprogress_requests:sum`
5 |       expr: sum by (instance) (http_inprogress_requests)
                    ^^^ 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.

Bug: label must be removed in aggregations (promql/aggregate)
  ---> rules/0001.yml:5 -> `colo:http_inprogress_requests:sum`
5 |       expr: sum by (instance) (http_inprogress_requests)
                        ^^^^^^^^ `instance` label should be removed when aggregating `^colo(?:_.+)?:.+$` rules.

level=INFO msg="Problems found" Bug=1 Warning=1
level=ERROR msg="Execution completed with error(s)" err="found 1 problem(s) with severity Bug or higher"
-- rules/0001.yml --
groups:
  - name: example
    rules:
    - record: colo:http_inprogress_requests:sum
      expr: sum by (instance) (http_inprogress_requests)

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