fluent-plugin-prometheus icon indicating copy to clipboard operation
fluent-plugin-prometheus copied to clipboard

[question] how to grep key value and increment counter

Open kid101 opened this issue 6 years ago • 2 comments

{ "foo": "some value", "bar": "some value", "baz": "some value" }

In the readme it shows the key as foo and the plugin will count the message that contains foo key and increment the counter. How do I grep the value of foo to find hello, and if hello exists then increase the counter?

kid101 avatar Jun 25 '19 13:06 kid101

need something similar.

my filter:

<filter mylabel>
  @type prometheus
  <metric>
    name router_codes
    type counter
    desc Counter of errors from Heroku Router
    <labels>
      tag ${tag}
      code ${router.code}
      dyno ${router.dest_dyno}
    </labels>
  </metric>
</filter>

Our logs are a mixed bag of data (heroku logs). Need to count on records that exist only. like only if the key exists. if it doesn't exist it just floods the fluentd logs, and pollutes prometheus data:

2020-07-29 20:03:20 +0000 [warn]: unknown placeholder `${router.code}` found
2020-07-29 20:03:20 +0000 [warn]: unknown placeholder `${router.dest_dyno}` found
2020-07-29 20:03:20 +0000 [warn]: unknown placeholder `${router.code}` found
2020-07-29 20:03:20 +0000 [warn]: unknown placeholder `${router.code}` found
2020-07-29 20:03:20 +0000 [warn]: unknown placeholder `${router.code}` found
2020-07-29 20:03:20 +0000 [warn]: unknown placeholder `${router.code}` found
2020-07-29 20:03:21 +0000 [warn]: unknown placeholder `${router.code}` found

image

i5okie avatar Jul 29 '20 20:07 i5okie

Is there a pre-existing solution to this in 2021, or should I look at writing a pull request?

bradbeattie avatar Oct 24 '21 15:10 bradbeattie