Hi
I’m a bit new … I have Hassio running on Pi3B with plugins:
Mosquitto/MQTT
Influx-DB
Grafana
Telegraf
When I define a sensor in Hassio that reads an MQTT topic … all works well … and Hassio puts this new sensor values into the Influx-DB … I do not need to do anything. This works fine.
With Grafana I can look into the data of Influx DB … all works fine.
I would like to configure “something” in Hassio so that ALL MQTT data from for example the topic “test/#” go to the Influx-DB without me needing to define 1 by 1 all these topics as a sensor in Hassio (too much work and overcrowding my “Overview” and “History” screens with useless data).
Normally Telegraf should be able to do this BUT I can not find the “standard” config file AND the config area on the screen of the Telegraf plugin does not accept any of my added statements to send MQTT data to Influx-DB.
I tried many things (with my limited knowledge) but failed … any help very welcome
influxdb records states of sensors, so I think the short answer is “no”.
However a well behaved mqtt component should be creating entities automatically in home assistant, via mqtt discovery, so there shouldn’t be much work involved for you.
Influxdata has a program called telegraf that can connect to a broker and store messages directly in the influx database (along with many other things). I doubt if this is available on hassio, but if you have another computer, you could still run it there.
I did find the “telegraf” add-on and installed it … it works with the build-in “ping” example … see the content of the “Config screen” on the add-on screen in HA … hereafter.
If I add extra code to store the MQTT data … push the “save” button and then the “restart” button on the telegraf add-on screen in HA … it restarts “telegraf” BUT my code is dropped … and it shows again the above config statements. …
@nickrout
I’m happy that HA does not create entities for all the topics that the Mosquitto MQTT add-on is treating … that would cause many sensors etc. that are not needed in HA.
I do not know why MQTT does not do what it is supposed to do … auto-create … I did not do anything to prevent it.
The only thing I would like to do is send many MQTT messages to Influx … for “nice” visual analysis with Grafana afterwards.
Most of these MQTT data are not used in HA for any purpose.
The few MQTT data I need in HA … I created a sensor and that works fine.
I am not sure what you mean. This is the section in telegraf.conf that you need to uncomment and edit. What did you edit it to?
# # Read metrics from MQTT topic(s)
# [[inputs.mqtt_consumer]]
# ## MQTT broker URLs to be used. The format should be scheme://host:port,
# ## schema can be tcp, ssl, or ws.
# servers = ["tcp://localhost:1883"]
#
# ## MQTT QoS, must be 0, 1, or 2
# qos = 0
# ## Connection timeout for initial connection in seconds
# connection_timeout = "30s"
#
# ## Topics to subscribe to
# topics = [
# "telegraf/host01/cpu",
# "telegraf/+/mem",
# "sensors/#",
# ]
@gpbenton
Hi, I have searched the whole RPi3B (where HA with “telegraf” plugin are installed) using PuTTY and can not find any. The same search can find many other *.conf files as seen hereafter.
If I was able to work with a telegraf.conf file (as you said) I think the problem will be solved.
When I “restart” telegraf on its HA add-on screen it gives the LOG message :
" 2018/11/18 16:51:36 I! Using config file: /etc/telegraf/telegraf.conf "
I think this means that he is NOT using a .conf … right ?
… so I created the directory /etc/telegraf and restarted telegraf => no result = no .conf written and the same LOG message.
I also created a telegraf.conf in that dir and restarted … no result and same LOG message …
What now ?
PuTTY search for the telegraf.conf file:
core-ssh:/# cd /
core-ssh:/# find -name “*.conf”
./etc/modprobe.d/i386.conf
./etc/modprobe.d/kms.conf
./etc/modprobe.d/blacklist.conf
./etc/modprobe.d/aliases.conf
./etc/sysctl.conf
./etc/sysctl.d/00-alpine.conf
./etc/udhcpd.conf
./etc/resolv.conf
./etc/ca-certificates.conf
./share/mosquitto/mosquitto.conf
./config/.ios.conf
core-ssh:/#
Screenshot of the HA telegraf add-on plugin (with the log message):
I don’t know much about hassio, but I don’t think the addons configuration file is stored in the core-ssh container. Here is the complete section from mine (on hassbian). You just need to copy the bits you need into your addons configuration
# # Read metrics from MQTT topic(s)
# [[inputs.mqtt_consumer]]
# ## MQTT broker URLs to be used. The format should be scheme://host:port,
# ## schema can be tcp, ssl, or ws.
# servers = ["tcp://localhost:1883"]
#
# ## MQTT QoS, must be 0, 1, or 2
# qos = 0
# ## Connection timeout for initial connection in seconds
# connection_timeout = "30s"
#
# ## Topics to subscribe to
# topics = [
# "telegraf/host01/cpu",
# "telegraf/+/mem",
# "sensors/#",
# ]
#
# # if true, messages that can't be delivered while the subscriber is offline
# # will be delivered when it comes back (such as on service restart).
# # NOTE: if true, client_id MUST be set
# persistent_session = false
# # If empty, a random client ID will be generated.
# client_id = ""
#
# ## username and password to connect MQTT server.
# # username = "telegraf"
# # password = "metricsmetricsmetricsmetrics"
#
# ## Optional TLS Config
# # tls_ca = "/etc/telegraf/ca.pem"
# # tls_cert = "/etc/telegraf/cert.pem"
# # tls_key = "/etc/telegraf/key.pem"
# ## Use TLS but skip chain & host verification
# # insecure_skip_verify = false
#
# ## Data format to consume.
# ## Each data format has its own unique set of configuration options, read
# ## more about them here:
# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
# data_format = "influx"
Hi, thanks for the advice.
It seems to me that the pluging can not be configured easily … or at least nobody gave feedback on my post …
… so I followed the good advice from gpbenton and used Docker with a telegraf container to do the job.
I has taken a lot of effort … but it works now.
Some feedback that could be useful for readers :
May MQTT data are INT, FLOAT and STRING … but I did not separate them => problems.
The solution was to use 2 Docker-telegraf containers where one writes to a first InfluxDB with : data_format = “float” … both INT & FLOAT come in well ! …
and the other writes to as different InfluxDB with : data_format = “string”.
Only with the first DB one can make graphs as all data in the second DB is present BUT as STRING.
I configured Telegraf with inputs_mqtt and works fine. Actually i have a Telegraf container connected with my broker taking topics from an agent. I suposse if i configure another inputs_mqtt in the same telegraf.conf i will recolect topics from another agent. Then with only one Telegraf container must be enought to recolect all my agents topics
@nasked I am interested to hear how you are getting on with the Telegraf MQTT connector? I have a couple of sensors which push out data at a very high rate over MQTT (200 Hz) and want to find a robust solution to store this data
Excuse my, but i have not see your notification. I can show you my blog about grafana. I’m not sure if your rate at 200 Mhz can be record at influxdb, by default telegraf take data each 10 second, but you can change this parameter at telefraf.conf
You can check my blog. Is in spanish but if you have any doubt do not hesitate to contact me. I’ll try to explain in my bad english to help you.
i have a question … i m unable to store message in influxdb from through telegraf… i cannot find the standard config file for the telegraf plugin that can send my mqtt data in to influxdb…
i tried many things but failed , please help me.