How to Parse JSON Data using telegraf and push to influxdb

My task is, I have to read a JSON File using telegraf and the same thing to push to INFLUXDB and visualize it in the chronograph.I tried, but unable to do so.

That too, I couldn’t find any documentation which can help me.

Kindly guide me.

Thanks & Regards,
Venkat.

how you are getting/reading Json data ? Elaborate more please.

you can have Python script to read Json data and convert it to Line Protocol to POST it on InfluxDB using curl.

1 Like

Thank You for info.

Actually Some real time data generated is getting saved in MySQL.Before
getting saved, it seems a JSON file is generated which I have to read and save it into InfluxDB.

The JSON file is continuously updated, which has to be continuously saved into the influxDB.

Can you please throw some light on it ?

Thanks & Regards,
Venkat

First option what you mentioned is using Telegraf, which I yet to use.

I wrote python script to read input Json file and parse it for line protocol, python can read file continusualy and convert it to line protocol.

Or, let me test telegraf next week and will update here.

Hi Venkat,

Did you find out solution to read from JSON to telegraf and then push it to influxdb? I am struggling to do the same.

If you would share your ideas it would be great. Thanking you in advance.

Regards,

Kabin

Hi All,
Even I have a similar problem that I am trying to solve. I have a curl command which would fetch some metrics as a JSON response. I am storing the JSON response into a variable. Example like the below:
{
“component”: {
“key”: “MY_PROJECT:ElementImpl.java”,
“name”: “ElementImpl.java”,
“qualifier”: “FIL”,
“language”: “java”,
“path”: “src/main/java/com/sonarsource/markdown/impl/ElementImpl.java”,
“measures”: [
{
“metric”: “complexity”,
“value”: “12”,
“period”: {
“value”: “2”,
“bestValue”: false
}
},
{
“metric”: “new_violations”,
“period”: {
“value”: “25”,
“bestValue”: false
}
},
{
“metric”: “ncloc”,
“value”: “114”,
“period”: {
“value”: “3”,
“bestValue”: false
}
}
]
},
“metrics”: [
{
“key”: “complexity”,
“name”: “Complexity”,
“description”: “Cyclomatic complexity”,
“domain”: “Complexity”,
“type”: “INT”,
“higherValuesAreBetter”: false,
“qualitative”: false,
“hidden”: false,
“custom”: false
},
{
“key”: “ncloc”,
“name”: “Lines of code”,
“description”: “Non Commenting Lines of Code”,
“domain”: “Size”,
“type”: “INT”,
“higherValuesAreBetter”: false,
“qualitative”: false,
“hidden”: false,
“custom”: false
},
{
“key”: “new_violations”,
“name”: “New issues”,
“description”: “New Issues”,
“domain”: “Issues”,
“type”: “INT”,
“higherValuesAreBetter”: false,
“qualitative”: true,
“hidden”: false,
“custom”: false
}
],
“period”: {
“mode”: “previous_version”,
“date”: “2016-01-11T10:49:50+0100”,
“parameter”: “1.0-SNAPSHOT”
}
}

However, I need only the metric and the value. Example: complexity=12, new_violations=25 etc etc. This will help me push the data into influxDB using curl is my understanding. Could you please guide and correct me if I am wrong.