fluent-plugin-prometheus
fluent-plugin-prometheus copied to clipboard
Fix warning on nil tag
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!
Can you add test cases?
Thanks!
It appears that it is usually impossible for tag to be nil.
Can you please provide a simple way to reproduce that error?
Hi,
Thanks! It appears that it is usually impossible for
tagto 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>