telegraf
telegraf copied to clipboard
feat(outputs.mqtt): Enhance routing capabilities
- [x] Updated associated README.md.
- [x] Wrote appropriate unit tests.
- [x] Pull request title or commits are in conventional commit format
resolves #12221
The objective was to add more flexibility to the MQTT output plugin. The work in this PR adds placeholders and effective support for:
- backward compatibility behaviour and respect default previous topic name
- adds support to add hard-coded strings as part of the topic
- by extension of the above, adds support to use environment variables
- adds support to use tags as part of the topic name.
Not sure if this helps, but here some evidence of the results after some local testing:
@srebhan thank you very much for your review and time dedicated to provide good feedback. I do wonder still though if you have some advice WRT the failing integration test. It seems unrelated to my changes. Is this due to some flakiness on the suite? or should I fix something on my end?
I have re-tested after the refactor to use the go-template approach
Things are still working as expected and I believe the code is much simpler now
The local topic I run was:
topic = '{{ .TopicPrefix }}/fixed-value/{{ .Hostname }}/{{ .PluginName }}/{{ .Tag "slave_id" }}/{{ .Tag "name" }}/${TERM_SESSION_ID}/<pluginname>/{{ .Tag "invalid" }}'
@srebhan @powersj is there anything else I can do to help with the review? Thanks in advance
@srebhan I was wondering if you have any further feedback on this PR, I'd appreciate your thoughts
Download PR build artifacts for linux_amd64.tar.gz, darwin_amd64.tar.gz, and windows_amd64.zip. Downloads for additional architectures and packages are available below.
:relaxed: This pull request doesn't significantly change the Telegraf binary size (less than 1%)
:package: Click here to get additional PR build artifacts
Artifact URLs
Thank you for all your help @srebhan
Thank you @srebhan for all the support and helping make this happen 🙇