Conditional logs labeling

Hello! I am trying to conditionally apply a label on logs going through a loki.process block inside my Alloy config.

loki.process "pod_logs" {
  stage.json {
    expressions = { "loggercontent"  = "logger" }
  }
  stage.labels {
    values = { "loggerlabel" = "loggercontent" }
  }
  stage.match { // Apply conditionally, only if logger == "pgaudit"
    selector = "{loggerlabel=\"pgaudit\"}"
    stage.labels {
      values = { "pgaudit" = "true" }
    }
  }
  forward_to = [loki.write.default.receiver]
}

I thought I could do this, according to the docs of stage.match:

It supports all the same stage.NAME blocks as the in the top level of the loki.process component.

So I thought I could use stage.labels within stage.match but maybe I’m missing something here?

If you are looking to set a static value to label, use stage.static_labels.