Collecting data from MQTT via telegraf and save them in influxdb

Hello!

I’m new in using telegraf and struggling with collecting data via mqtt and/or writing the data into the DB.

I want to read the data from an mqtt broker which is installed on the same system as telegraf and influxdb. When starting telegraf service the DB gets created (i prooved that by deleting the DB and starting service again).

But no data gets stored in the DB…

Here is my config

[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = ""
  logtarget = "file"
  logfile = "/var/log/telegraf/telegraf-vrm.log"
  logfile_rotation_max_size = "10MB"
  logfile_rotation_max_archives = 5
  omit_hostname = true

[[outputs.influxdb]]
  urls = ["http://192.168.1.25:8086"]
  database = "Fronius_Symo_6.0-3M"
  user_agent = "telegraf-fronius"

[[inputs.mqtt_consumer]]
   servers = ["tcp://192.168.1.25:1883"]
   qos = 0
   
   topics = ["#"]

   username = "loxberry"
   password = "******"   

   data_type = "float"
   data_format = "json"
   persistent_session = false
   client_id = "telegraf-fronius"

Output of

telegraf --config telegraf.conf --debug

 2021-05-21T14:38:11Z I! Starting Telegraf 1.18.2
2021-05-21T14:38:11Z E! Unable to open /var/log/telegraf/telegraf-vrm.log (open /var/log/telegraf/telegraf-vrm.log: no such file or directory), using stderr
2021-05-21T14:38:11Z I! Loaded inputs: mqtt_consumer
2021-05-21T14:38:11Z I! Loaded aggregators:
2021-05-21T14:38:11Z I! Loaded processors:
2021-05-21T14:38:11Z I! Loaded outputs: influxdb
2021-05-21T14:38:11Z I! Tags enabled:
2021-05-21T14:38:11Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"", Flush Interval:10s
2021-05-21T14:38:11Z D! [agent] Initializing plugins
2021-05-21T14:38:11Z D! [agent] Connecting outputs
2021-05-21T14:38:11Z D! [agent] Attempting connection to [outputs.influxdb]
2021-05-21T14:38:11Z D! [agent] Successfully connected to outputs.influxdb
2021-05-21T14:38:11Z D! [agent] Starting service inputs
2021-05-21T14:38:11Z I! [inputs.mqtt_consumer] Connected [tcp://192.168.1.25:1883]
2021-05-21T14:38:21Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics
2021-05-21T14:38:31Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics
2021-05-21T14:38:41Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics
2021-05-21T14:38:51Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics

Thank you very much.
Hope you can help.

to fast you are using json.

In y system if message are malformed the logfile reports this as unaible to parse.
Since there is nothing about this and the buffer is empty i think there is no data send to telegraf.

Other thing is you could fix the error about the log file location