telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

feat(outputs.mqtt): Enhance routing capabilities

Open serroba opened this issue 2 years ago • 4 comments

  • [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: image

serroba avatar Nov 11 '22 07:11 serroba

@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?

serroba avatar Nov 14 '22 20:11 serroba

I have re-tested after the refactor to use the go-template approach image

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" }}'

serroba avatar Nov 15 '22 04:11 serroba

@srebhan @powersj is there anything else I can do to help with the review? Thanks in advance

serroba avatar Nov 18 '22 09:11 serroba

@srebhan I was wondering if you have any further feedback on this PR, I'd appreciate your thoughts

serroba avatar Jan 07 '23 21:01 serroba

Thank you for all your help @srebhan

serroba avatar Jan 12 '23 20:01 serroba

Thank you @srebhan for all the support and helping make this happen 🙇

serroba avatar Jan 17 '23 03:01 serroba