How does the Json parser works in telegraf

telegraf
#1

Hello Community,

i was trying to get out some data from a db with telegraf. Unfortunately the https://github.com/influxdata/telegraf/pull/2785 will take some more time or never come to life who knows. Nevertheless i tried than to use the Inputs.exec plugin with my python wrapper script for the SQL queries which produces a JSON for telegraf. So Far so good but for any strange reason only the first Key-value-pair gets processed by telegraf. So i created a test.json out of my python script and used the Inputs.file plugin.
So in my case i use the following test.json
{“test_integer”: 78698, “test_string1”: “test”, “test_string2”: “Test-testo-testi”}
And it parsed to the following InfluxDB Line Protocol:
file,host=testserver test_integer=78698 1552909841000000000
Should the expected behavior not be according to the doku to parse the JSON not in the following
file,host=testserver test_integer=78698,test_string1=“test”,test_string2=“Test-testo-testi” 1552909841000000000
Please can someone verify or give me a hint why this is the behavior. I mean if my best bet is to create directly a InfluxDB Line Protocol or do i just misunderstood how the Parser works ?
Thanks for the help.

#2

Are you specifically trying to store strings? The default JSON processors will avoid that and only store floats/integers

#3

Hi Esity,

thanks for the hint. I reread the docu again and understand my error. After playing around with the additional json parameters in the telegraf config i got it working as intended. The only question from me left is does the json parser sort the input directly as intended in the docs? I think he does cause it doesn’t matter how the json values were arranged it always were produced the same Influxdb line protocol line.

Thanks for the help.