No data transfer via telegraf from MQTT

Hey there,

I have a small problem concerning the configuration of telegraf to send data to the infux. My configs work for two out of three cases and I simply can’t figure out the problem.

The data arrive like that :

And my config looks like this:

Broker URLs for the MQTT server or cluster. To connect to multiple

clusters or standalone servers, use a seperate plugin instance.

servers = [“tcp://localhost:1883”]

Topics that will be subscribed to.

topics = [

topic_tag = “”
max_undelivered_messages = 10000
persistent_session = true
client_id = “***2”

Username and password to connect MQTT server.

username = “"
password = "
data_format = “json_v2”
path = “@this
included_keys = [“AS_power_in”,“AS_Total_in”,]

urls = [“http://...:****”]

Token for authentication.

token = “$INFLUX_TOKEN”

organization = “***”

Destination bucket to write into.

bucket = “***”
exclude_bucket_tag = false
user_agent = “telegraf”
debug = true
quiet = false
interval = “10s”
round_interval = false
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = “2s”
flush_interval = “10s”
flush_jitter = “1s”
precision = “”
qos = 1

It would be great if someone would have an idea on what I possibly did wrong.
Thank you so much in advance!


Your JSON is a little difficult as you have two different formats. Two lines have an AS child, while the first line has data in the root + a Wifi element. What data are you interested in collecting?

You can use xpath to more generally collect the data:

files = ["metrics.json"]
data_format = "xpath_json"
xpath_native_types = true

  metric_name = "'metric'"
  field_selection = "/descendant::*"
  timestamp = "/Time"
  timestamp_format = "2006-01-02T15:04:05"

Which produces:

metric Sleep=50,AP=1,LinkCount=28,Heap=1,LoadAvg=19,Time="2024-06-25T09:44:26",UptimeSec=1,Wifi="map[AP:1 BSSId: Channel:1 Downtime:0T00:06:44 LinkCount:28 Mode:11n RSSI:36 SSId: Signal:-82]",RSSI=36,Uptime="10T17:51:48",BSSId="",Mode="11n",Signal=-82,MqttCount=1,POWER="OFF",SleepMode="Dynamic",Channel=1,Downtime="0T00:06:44",SSId="" 1719308666000000000
metric power_in=1,power_out=0,Time="2024-06-25T09:44:26",AS="map[Total_in:3.1 Total_out:0 power_in:1 power_out:0]",Total_in=3.1,Total_out=0 1719308666000000000
metric AS="map[power_in:1]",power_in=1,Time="2024-06-25T09:44:31" 1719308671000000000