Helm Loki Stack additional promtail config

2.3k Views Asked by At

I install loki and prometheus using helm. However, I would like to replace the logs in one place. I have used: helm show values grafana/loki-stack > loki-stack-values.yml to output the values and came to the following result:

loki:
  enabled: true
  isDefault: true

promtail:
  enabled: true
  config:
    lokiAddress: http://{{ .Release.Name }}:3100/loki/api/v1/push
      prometheusSpec:
        additionalScrapeConfigs:
          - match:
              selector: '{name="promtail"}'
              stages:
              # The regex stage parses out a level, timestamp, and component. At the end
              # of the stage, the values for level, timestamp, and component are only
              # set internally for the pipeline. Future stages can use these values and
              # decide what to do with them.
              - regex:
                  expression: '.*level=(?P<level>[a-zA-Z]+).*ts=(?P<timestamp>[T\d-:.Z]*).*component=(?P<component>[a-zA-Z]+)'



Actually, everything would work great. But my output is really weird so I try to add the the additionalScapeConfig

2022-05-06 18:31:55 
{"log":"2022-05-06T18:31:55,003 \u001b[36mDEBUG\u001b[m

So to the question:

How can I use helm install dlp-dev-loki grafana/loki-stack --values loki-stack-values.yml -n dev. and additional scape configs for promtail.

1

There are 1 best solutions below

0
On

According to the docs, promtail pipelines, The timestamp stage takes the timestamp extracted from the regex stage and promotes it to be the new timestamp of the log entry, the timestamp should be parsing it as an RFC3339Nano-formatted value. Add the below to the config file below regex.

- timestamp:
    format: RFC3339Nano
    source: timestamp