Invert regex in drop action

The drop stage uses RE2 (see drop | Grafana Loki documentation), so when testing you’ll want to make sure you select golang and version 2.

It’s a pain in general to write regex not containing something. So I recommend you to do it the other way around. Mock logic below:

  1. Use regex to group capture string oom-killer.
  2. Use match stage to match the group capture for anything that’s not oom-killer, then drop.
  3. Whatever else can be put after the match/drop stage.

Mock config (not tested):

pipeline_stages:
  - regex:
      expression: ".*(?P<drop_key>oom-killer).*"
  - labels:
      drop_key:
  - match:
      selector: '{drop_key!="oom-killer"}'
      action: drop

<whatever else>
1 Like