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

Fix warning on nil tag

Open cleroymira-unabiz opened this issue 5 months ago • 3 comments

Hi,

This aims at fixing warning we see in logs:

{"time":"2025-06-23","level":"warn","message":"send an error event stream to @ERROR: error_class=NoMethodError error=\"undefined method `split' for nil:NilClass\\n\\n          tags = tag.split('.')\\n                    ^^^^^^\" location=\"/fluentd/vendor/bundle/ruby/3.1.0/gems/fluent-plugin-prometheus-2.1.0/lib/fluent/plugin/prometheus/placeholder_expander.rb:42:in `build_tag'\" tag=nil","worker_id":0

I hope it is not too naive.

Thanks!

cleroymira-unabiz avatar Jun 23 '25 09:06 cleroymira-unabiz

Can you add test cases?

Watson1978 avatar Jun 30 '25 01:06 Watson1978

Thanks! It appears that it is usually impossible for tag to be nil. Can you please provide a simple way to reproduce that error?

daipom avatar Jun 30 '25 01:06 daipom

Hi,

Thanks! It appears that it is usually impossible for tag to be nil. Can you please provide a simple way to reproduce that error?

It comes from a misconfiguration: we forgot "key" in a

<filter message>
  @type prometheus
  <metric>
    name message_foo_counter
    type counter
    desc The total number of foo in message.
    #key foo
  </metric>
</filter>

cleroymira-unabiz avatar Jul 08 '25 11:07 cleroymira-unabiz