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"
}
}
}