# Alert rule merges for and labels via <<: *defaults, expr uses anchor and alias.

exec pint --no-color lint --show-duplicates 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
Warning: always firing alert (alerts/comparison)
  ---> rules/rules.yml:6 -> `first`
6 |   expr: &e up
               ^^
               This query doesn't have any condition and so this alert will always fire if it matches
               anything.

Warning: always firing alert (alerts/comparison)
  ---> rules/rules.yml:9 -> `second`
9 |   expr: *e
             ^
             This query doesn't have any condition and so this alert will always fire if it matches
             anything.

level=INFO msg="Problems found" Warning=2
-- rules/rules.yml --
- &defaults
  for: 5m
  labels:
    severity: warning
- alert: first
  expr: &e up
  <<: *defaults
- alert: second
  expr: *e
  <<: *defaults
-- .pint.hcl --
parser {
  relaxed = ["rules/.*"]
}
rule {
  for {
    severity = "bug"
    min      = "5m"
  }
  label "severity" {
    severity = "bug"
    value    = "critical|warning|info"
    required = true
  }
}

