Change Telegraf MQTT Consumer interval

Hello,

I have a pretty simple problem that I don’t know how to handle.
I use telegraf to subscribe to matt-topics, however they are being published way too often (and I cannot change that)
This results in way too many metrics in my InfluxDB. Setting up “interval” in the [agent] section does not seem to change anything… What is the best way to handle this?
Thank you very much!

@hermann4 MQTT is a so called “Service plugin” or “listener” where the data-collection is event-based and not controlled by Telegraf. Thus the interval does not have any meaning for those plugins usually.

To reduce the number of metrics, you could aggregate them in Telegraf for example by only using the last one or by averaging the data. Here the period controls how often the aggregates are emitted.

Does that help?

You could also subsequently reduce the amount of data in influx by having a short retention period for the original data (like a few hours) and creating a second reduced dataset with longer retention period via continuous queries.

Thank you very much for your answers, until now I didn’t know that in some plugins in the interval is not really doing anything. I managed to write a small program in python which I can use with the execd plugin, and there I can configure how often the mqtt topics are being handed over to telegraf.

@hermann4 huh? Why didn’t you use the final aggregator that is doing exactly what you want, it gives the last record in a user-specified period. This is the interval you are looking for… Anyway, glad you found a way…

I‘ll check. Do you know how it handles the different topics that are being emitted? In the documentation they are talking about „contagious series“, but I am not sure whether they distinguish between the different topics of one host…

A series is defined by the measurement name and the tag key/value set. As topic is a tag, you will get one output per topic and period.

Ok now I get it. I’ll try it out, since it may be more robust than my solution. Thank you very much!

1 Like