MQTT input sensorId dynamically set InfluxDB output server-url and organization-id

Dear Community,

question on how to implement such a telegraf setup: Want to deliver sensor data from MQTT to different InfluxDb servers and organizations depending on which organization owns which sensor id. The information which sensor-id belongs to which server-url and which organization-id I store in PostgreSQL and changes only seldomly.


  • having a MQTT input, which is collecting all data for all sensors.
  • having multiple InfluxDBs and different organizations

Which setup to choose?

  • processor with execd to lookup in PostgreSQL (caching possible?)
  • or different telegraf.conf with fiters? Do I need to restart telegraf process each time?

Is there a recommendation how to do that?


If you need to fetch the “destination” info externally (from Postgres), and merge it with the incoming data I see no other way than the execd processor.

Using filtered outputs will probably work, but it’s not that handy and flexible as you will need to keep editing the conf when a sensor is added and moved (and deleted to keep the conf clean). it also requires a Telegraf restart to refresh the config. (note this is not 100% true, see --watch-config here)

For routing the data to different outputs I’d use the bucket tag option

The value of this tag will be used to determine the bucket. If this
tag is not set the ‘bucket’ option is used as the default.

For it to work the routing info must be present as a tag, I usually add it statically via config file, but given your setup, it will require filtering and processing unless you can add it directly to the data sent by the sensors.

About the “organizations”, I see no way of doing automatic routing, therefore the only option is to have several outputs with proper filtering. (you can use a dedicated tag too to make it easier)

I’ve opened an issue about organization routing

Thank you Giovanni. This is what I going to setup then.
Haven’t written a processor with execd yet. Let’s see.
Regards Toby