Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promtail to set journal target symbolic priority #2084

Closed
gtrubach opened this issue May 16, 2020 · 1 comment · Fixed by #2087
Closed

Promtail to set journal target symbolic priority #2084

gtrubach opened this issue May 16, 2020 · 1 comment · Fixed by #2087
Labels
component/agent good first issue These are great first issues. If you are looking for a place to start, start here! help wanted We would love help on these issues. Please come help us! type/enhancement Something existing could be improved

Comments

@gtrubach
Copy link

Hi!

Is your feature request related to a problem? Please describe.
I want to display journal logs in grafana by using promtail and loki. Promtail extracts logs fine but journal contains priority in number format, not symbolic. So if I use the following scrape config:

- job_name: systemd-journal
  journal:
    max_age: 12h
    labels:
      job: systemd-journal
    path: /var/log/journal
  relabel_configs:
  - source_labels:
    - __journal__systemd_unit
    target_label: systemd_unit
  - source_labels:
    - __journal_priority
    target_label: level

level will be numeric and grafana will show unknown log level for it.

Describe the solution you'd like
It would be great if numeric priority will be transformed to symbolic as it's done for syslog target. In this case I will be able to map it to level label which can be read by grafana and shown correctly.

Describe alternatives you've considered
I tried to set it up using pipelines but I wasn't successful in it.

Additional context
Note the level label (6 is an info):
image

@cyriltovena cyriltovena added component/agent type/enhancement Something existing could be improved good first issue These are great first issues. If you are looking for a place to start, start here! help wanted We would love help on these issues. Please come help us! labels May 16, 2020
@gtrubach
Copy link
Author

It still will be cool to have it out of the box, but I managed to do a workaround using pipeline stage:

pipeline_stages:
- job_name: systemd-journal
  journal:
    max_age: 12h
    labels:
      job: systemd-journal
    path: /var/log/journal
  relabel_configs:
  - source_labels:
    - __journal__systemd_unit
    target_label: systemd_unit
  - source_labels:
    - __journal_priority
    target_label: level
  pipeline_stages:
  - template:
      source: level
      template: '{{ if eq .Value "0" }}{{ Replace .Value "0" "emerg" 1 }}{{ else if eq .Value "1" }}{{ Replace .Value "1" "alert" 1 }}{{ else if eq .Value "2" }}{{ Replace .Value "2" "crit" 1 }}{{ else if eq .Value "3" }}{{ Replace .Value "3" "err" 1 }}{{ else if eq .Value "4" }}{{ Replace .Value "4" "warning" 1 }}{{ else if eq .Value "5" }}{{ Replace .Value "5" "notice" 1 }}{{ else if eq .Value "6" }}{{ Replace .Value "6" "info" 1 }}{{ else if eq .Value "7" }}{{ Replace .Value "7" "debug" 1 }}{{ end }}'
  - labels:
      level:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/agent good first issue These are great first issues. If you are looking for a place to start, start here! help wanted We would love help on these issues. Please come help us! type/enhancement Something existing could be improved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants