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: Ignore dropped entries in subsequent metric-stages in pipelines. #1743

Merged
merged 2 commits into from
Feb 26, 2020
Merged

Promtail: Ignore dropped entries in subsequent metric-stages in pipelines. #1743

merged 2 commits into from
Feb 26, 2020

Conversation

dtennander
Copy link
Contributor

@dtennander dtennander commented Feb 25, 2020

What this PR does / why we need it:
This PR makes the metric stage in Promtail ignore dropped entries.

This allows users to define a pipeline like this:

pipeline_stages:
      - match:
          selector: '{app="promtail"} |= "thing we don't want to log"'
          action: drop
      - metrics:
          log_lines_total:
            type: Counter
            description: "total number of logged lines"
            config:
              match_all: true
              action: inc

In general this also fixes the issue were the above config today would generate an error message like this:

missmatch metrics: gathering metrics failed: "__drop__" is not a valid label name for metric "promtail_custom_log_lines_total"

Which issue(s) this PR fixes:
Doesn't fix a GH-Issue 😢

Special notes for your reviewer:
I also have a branch feature/metrics-on-dropped that solves this issue by removing labels with the prefix __ instead. But I do believe that this PR solves the problem in a more predictable way.

Checklist

  • Documentation added
  • Tests updated

David Tennander added 2 commits February 25, 2020 23:25
Before this change a "metric" stage after a "match" stage with `action: drop` would result in an error.
This specifies the behavior in the docs and adds logic to ignore dropped entries.
@claassistantio
Copy link

claassistantio commented Feb 25, 2020

CLA assistant check
All committers have signed the CLA.

@codecov-io
Copy link

Codecov Report

Merging #1743 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1743      +/-   ##
==========================================
+ Coverage   64.22%   64.25%   +0.02%     
==========================================
  Files         121      121              
  Lines        9083     9085       +2     
==========================================
+ Hits         5834     5838       +4     
+ Misses       2846     2845       -1     
+ Partials      403      402       -1
Impacted Files Coverage Δ
pkg/logentry/stages/metrics.go 60.32% <100%> (+0.43%) ⬆️
pkg/ingester/transfer.go 66.42% <0%> (+1.42%) ⬆️

@dtennander dtennander requested review from slim-bean and removed request for slim-bean February 25, 2020 23:11
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 Awesome thank you for this.

@cyriltovena cyriltovena merged commit 5139aa1 into grafana:master Feb 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.

4 participants