-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InfluxDB Database/Measurement Settings Based on MQTT Topic #6145
Comments
@orcunbaslak could you give an example of how this would differ from the current behavior of the https://github.com/influxdata/telegraf/tree/master/plugins/inputs/mqtt_consumer#tags Or perhaps some more details on your usecase, so that we can understand how the current plugin doesn't support it. |
Hello, Let me try to make it more clear. Let's say I have 1.000 IoT devices. So I want [[inputs.mqtt_consumer]] to listen to '#' and when it receives a message from device1 in the topic /db1/device2, It sends this message to [[outputs.influxdb]] with the appropriate database and measurement. However with the name_pass setting; measurement is the same for all incoming messages which is something like mqtt_consumer_xxxx and database is what we've set in [[outputs.influxdb]]. I'd like to extract measurement name and database name from the topic and use the data shared in that topic go to exactly to that database/measurement pair (like passing a variable to # database_tag = ""). I don't know If that's doable in this current state but README files doesnt give the documentation needed for such config if it is possible. |
The mqtt_consumer does not support setting the measurement from the topic. Your best bet is to use an input You could however split the topic into two tags using the regex processor, and then use the results with the [[processors.regex]]
[[processors.regex.tags]]
key = "topic"
pattern = '^/(\w+)/(\w+)/$'
replacement = "${1}"
result_key = "influxdb_database"
[[processors.regex.tags]]
key = "topic"
pattern = '^/(\w+)/(\w+)/$'
replacement = "${2}" |
Hi @danielnelson , Can we use Processor to Create Fields in db? Eg. I have device_id in the topic, Which will be split using regex processor. Now rather than setting into tags now i want to store it in |
@bamne123 The regex processor can operate on tags or fields, but it can't convert tags to fields. What you cando is use the If you have more questions please ask at the InfluxData Community site. |
Feature Request
Opening a feature request kicks off a discussion.
Proposal: Telegraf will parse the topic message and move it to appropriate database/measurement based on the MQTT topic. Like /db_1/measurement_1/# will forward all the messages in that topic to those databases/measurements.
Current behavior: Not that I know of.
Desired behavior: As I explained above.
Use case:
Well, I plant to use MQTT as a communication hub for 1.000 IoT devices. I cannot go to telegraf.conf each time and create a configuration for each topic to be parsed by namepass= and moved to their respective databases/measurments. That should be done on the fly.
Thanks.
The text was updated successfully, but these errors were encountered: