Telegraf parse JSON

My json looks like:
{
“devList”: [
{
“devId”: 264,
“devNo”: “2”,
“varList”: [
{
“varName”: “SXJSFYC1”,
“varValue”: “1”,
“readTime”: “2018-11-12 16:08:26”,
“varId”: 5269,
“isWarn”: 0
},
{
“varName”: “SXJSFSZDQH1”,
“varValue”: “0”,
“readTime”: “2018-11-12 16:08:26”,
“varId”: 5270,
“isWarn”: 0
},
{
“varName”: “CSYL”,
“varValue”: “0.40”,
“readTime”: “2018-11-12 16:08:26”,
“varId”: 5266,
“isWarn”: 0
},
{
“varName”: “SSLL”,
“varValue”: “5.6”,
“readTime”: “2018-11-12 16:08:26”,
“varId”: 5267,
“isWarn”: 0
},
{
“varName”: “SBYC1”,
“varValue”: “1”,
“readTime”: “2018-11-12 16:08:26”,
“varId”: 5268,
“isWarn”: 0
},
{
“varName”: “SXJSFGZ1”,
“varValue”: “0”,
“readTime”: “2018-11-12 16:08:26”,
“varId”: 5271,
“isWarn”: 0
},
{
“varName”: “ZD”,
“varValue”: “0.058”,
“readTime”: “2018-11-12 16:08:26”,
“varId”: 5272,
“isWarn”: 0
},
{
“varName”: “YL”,
“varValue”: “0.50”,
“readTime”: “2018-11-12 16:08:26”,
“varId”: 5273,
“isWarn”: 0
},
{
“varName”: “PH”,
“varValue”: “7.47”,
“readTime”: “2018-11-12 16:08:26”,
“varId”: 5274,
“isWarn”: 0
},
{
“varName”: “DXL”,
“varValue”: “137.8”,
“readTime”: “2018-11-12 16:08:26”,
“varId”: 5275,
“isWarn”: 0
},
{
“varName”: “LJLL”,
“varValue”: “10929.92”,
“readTime”: “2018-11-12 16:08:26”,
“varId”: 5276,
“isWarn”: 0
}
]
}
],
“cmdId”: 103,
“gwSn”: “WG285LL0718100800112”,
“gwName”: “”
}

I want to store data into influxdb like(one row):
devId devNO varName varValue readTime varId isWarn

However I’m unclear about what values I should use in telegraf.conf.Some guidance would be appreciated!

So you will probably want to use the JSON input via Telegraf
httpjson will make an http request to the web server which should produce this JSON.

Next you have to think about how your data is structured. You have a measurement, multiple tags and multiple fields for a given timestamp.

If you look at the bottom of the page I sent you, you can see examples of how to pull in JSON. Give this an attempt, see what data goes to InfluxDB and/or what errors Telegraf throws and then ask future questions based on that

Hi Esity,
I use mqtt plugins to receive data from IoT gateway, the data format is json like above.
I want to parse it and store a measurement into influxdb.
the measurement should have the fields:devId, devNO ,varName ,varValue ,readTime ,varId ,isWarn

Okay so you are going to add a JSON parser to the mqtt consumer plugin.

This page will give you some example on how to do it. I would recommend setting a telegraf instance to

  1. Read the data with the MQTT input plugin
  2. Parse the JSON via the JSON Parser
  3. Use the File Output plugin and write the data to the file
  4. Make updates until the output file matches the format you want

It will be trial and error but that way you can learn more about parsers within Telegraf