Promtail 2.3.0 - Label filtering no longer works with match stage

I have the following match stage in my Promtail configuration:

  - match:
      selector: '{loglevel="ERROR"} !~ <bunch of regex>  | type != "usage" and type != "repair"'
      stages:
      - template:
          source: errorCorrected
          template: 'corrected'
      - labels:
          errorCorrected:
      - metrics:
          errors_corr:
            type: counter
            description: "Corrected total number of error messages"
            prefix: app_log_
            max_idle_duration: 24h
            source: loglevel
            config:
              match_all: true
              action: inc

With Promtail 2.3.0, I get the following error when loading this config:

invalid match stage config: invalid selector syntax for match stage: parse error at line 1, col 164: syntax error: unexpected IDENTIFIER, expecting != or !~ or |~ or |=

Column 164 corresponds to the | character in the above selector LogQL query.

This config worked without issues on Promtail 2.2.0. Are label filters no longer allowed in the selector for the match pipeline stage?

Thanks.

Experiencing the same problem – how did you resolve?
The odd thing is that the query works from Grafana direct, but not as a selector/label filter in Promtail config.

Hey, thanks for reminding me to post back. Yes, I did resolve! Basically, I moved the label filter right to the beginning of the selector. So my match line now looks as follows:

  - match
      selector: '{loglevel="ERROR",type!="usage",type!="repair"} !~ <bunch of regex>
      stages:
        ...

It works with Promtail 2.3 and 2.4. Hope this helps you. Thanks!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.