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: Add Entry variable to template #2105

Merged
merged 1 commit into from
May 26, 2020

Conversation

fatpat
Copy link
Contributor

@fatpat fatpat commented May 21, 2020

The new Entry variable is the log message that could be needed in template.

What this PR does / why we need it:
It permits to access the log line (entry) from template pipelines using the Entry variable.

For exemple, to convert a log line to lowercase:

  • template:
    source: message
    template: '{{ ToLower .Entry }}'
  • output:
    source: message

Which issue(s) this PR fixes:
N/A

Special notes for your reviewer:

Checklist

  • Documentation added
  • Tests updated

The new Entry variable is the log message that could be needed in template.

For instance, if I want to convert all my log line to lowercase:
- template:
    source: message
    template: '{{ ToLower .Entry }}'
@codecov-commenter
Copy link

Codecov Report

Merging #2105 into master will decrease coverage by 0.21%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2105      +/-   ##
==========================================
- Coverage   61.43%   61.22%   -0.22%     
==========================================
  Files         146      146              
  Lines       11187    11188       +1     
==========================================
- Hits         6873     6850      -23     
- Misses       3767     3789      +22     
- Partials      547      549       +2     
Impacted Files Coverage Δ
pkg/logentry/stages/template.go 86.95% <100.00%> (+0.28%) ⬆️
pkg/promtail/positions/positions.go 47.32% <0.00%> (-13.40%) ⬇️
pkg/promtail/targets/tailer.go 73.86% <0.00%> (-4.55%) ⬇️
pkg/promtail/targets/filetarget.go 68.67% <0.00%> (-1.81%) ⬇️
pkg/logql/evaluator.go 90.69% <0.00%> (-0.59%) ⬇️

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cyriltovena cyriltovena merged commit 665712f into grafana:master May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants