Level label automatically added

Hi,

i’m trying to monitor nextcloud log with Alloy and Loki and i’m facing issues. It seems that Alloy automatically add a “level” label that is always set to “info”, even if Nextcloud logs contains a “level” label set to “1”, or “2”, etc …

Here are 2 screenshots showing the output in grafana of the logs, focusing of a log with log level = 2.
The first one is without pipeing the ouput to JSON (the log level label is already here set to “info”), the second one is after pipeing the output to JSON (the level label didn’t changed).


Here is my alloy config

local.file_match "nextcloud_log" {
  path_targets = [
    {__path__    = "/var/log/nextcloud/{nextcloud,audit}.log",
    job = "nextcloud_log",
    sync_period = "5s"},
    ]
}

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

// ==> I tried with and without this process stage without success
loki.process "process_nextcloud_log" {
    forward_to = [loki.write.endpoint.receiver]

    stage.label_drop {
        values = ["level"]
    }
}

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

Do you have any idea on what is going on? Thanks in advance !

I am not very familiar with how Loki detects log levels, but I think using a number to represent log levels is rather ambiguous (for example I wouldn’t know what “2” means).

That said, you can still set your own levels label using alloy. You’d have to do a bit of work, the logi would look something like this:

  1. stage.json
  2. match level = 1, set label level = <something_1>
  3. match level = 2, set label level = <something_2>
  4. continue until you exhaust the level numbers