Skip to content

Regex parsing issues in matchers for expressions broken down into multiple lines. #4470

@aned

Description

@aned

Alertmanager version 0.28.1

It appears that if the regex expression is broken into multiple lines, when the new line starts with .* it breaks things.
amtool config check doesn't result in any errors, no error logs when running the "broken regex" config file.

In the example bellow it doesn't match anything .*BGP.* and anything after it.

    - matchers:
        - team = "netops"
      routes:
      - matchers:
          - alertname =~ "ping_fail|PeerDownORFlappingJuniper|ServiceMonitorLowAvailability|ReadOnlyFileSystem|
                          PowerSupplyBad.*|*|TooMuchTrafficTowardsLBorFW|BGPTooManySessionsDown.*|BGPDrained.*|
                          .*BGP.*|FanStateBad.*|NodeLowFreeMem|InputDiscardsHighSonic|TempHigh.*|
                          TempHigh.*|.*Interface.*|.*ErrorsRate.*"
        receiver: abc
        continue: true

This is working as expected

    - matchers:
        - team = "netops"
      routes:
      - matchers:
          - alertname =~ "ping_fail|PeerDownORFlappingJuniper|ServiceMonitorLowAvailability|ReadOnlyFileSystem|
                          PowerSupplyBad.*|*|TooMuchTrafficTowardsLBorFW|BGPTooManySessionsDown.*|BGPDrained.*|
                          FanStateBad.*|NodeLowFreeMem|InputDiscardsHighSonic|TempHigh.*|.*BGP.*|
                          TempHigh.*|.*Interface.*|.*ErrorsRate.*"
        receiver: abc
        continue: true

To test, "bad" regex string:

./amtool config routes test --config.file=alertmanager-config.yml   alertname=BGPAdminDown   team=netops   production_state=production   severity=info
receiver_A,netops-info

"normal" regex string:

./amtool config routes test --config.file=alertmanager-config.yml   alertname=BGPAdminDown   team=netops   production_state=production   severity=info
receiver_A,abc,netops-info

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions