Promtail configuration

Hi Grafana Community,

I am configuring Loki and I got stuck in the Promtail yaml configuration file. I have a label that can get a wide range of values, but I still have to keep it in the log line for the analysis on Grafana. Hence, my idea is to drop that label from the labelk defined in the static config and integrate it into the log line so that Loki can get it as “Detected filed”.

The config-promtail.yml looks like this:

scrape_configs:
  - job_name: promtail
    pipeline_stages:
    - json:
        expressions:
          level: level
          timestamp: '"@timestamp"'
    - labels:
        level:
    - labeldrop:
      - hostname
    - template:
        source: message
        template: '{{ omit (mustFromJson .Entry) "a_filed" "@timestamp" "@another_filed" | mustToJson }}' 
    - output:
        source: message
    static_configs:
    - targets:
      - localhost
      labels:
        hostname: host

The stage “pack” does not suit my problem, but I was thinking of another template stage where I redefine hostname and then I add it into .Entry

Any advice? Thank you very much, I’d appreciate your help a lot!

I am using grafana 9.2.0, loki 3.0.1 and promtail 2.5.0

1 Like

Hi, did you ever find a solution to this?

1 Like

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