Using Label.Process and Label.Json in Grafana River Flow Unable to add custom labels to json

I am parsing an nginx log that outputting JSON and using river flow to process these.
I want to dynamically add the label of [status] ( which is the nginx status code 200, 204 etc ) which exists in the log entry.
There are NO errors in the grafana log; no errors in the monitoring UI and all dependencies are there as expected
But the logs are never labelled with status; only “app” and “instance” are there?

My river config below is

local.file_match "nginx2" {
	path_targets = [
		{__path__ = "/var/log/nginx/*.json", "instance" = "instance1", "app" = "myapp" }]
}

loki.source.file "nginx2" {
	targets    = local.file_match.nginx2.targets
	forward_to = [loki.process.nginx2.receiver]
}

loki.process "nginx2" {
  forward_to = [loki.write.endpoint.receiver]
 stage.json {
      // extract the status from the json to local map 
      expressions = {"status" = "status" }
  }

  stage.labels {
       // label the log row with the status which should appear as "mystatus"
	values = {  "mystatus" = "status" }
  }

loki.write "endpoint" {
	endpoint {
		url = "http://myloki:3100/loki/api/v1/push"
	}
}
}

Don’t see anything obvious wrong. Do you have an example logline?

Thanks for your reply…

[ solved ] The logline was wrong it had a trailing comma.
The Grafana UI could convert to json via | json and everything looked find but the river agent didnt like it. Nor did it throw any warnings or errors.

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