Need help with parsing JSON with strings in Telegraf inputs.http

#1

Hi all,
I’m facing difficulties in parsing a JSON http response with strings.

my JSON response looks like this:

{
“stats”: {
“hashes”: “1104589883”,
“lastShare”: “1536248906”,
“balance”: “91967”,
“paid”: “8520900”,
“minPayoutLevel”: “200000”,
“hashrate”: “1.91 KH”
}
“charts”: {
“payments”: [
[
1535688385,
“184800”
],
[
1535697940,
“123300”
]
]
}

my inputs.http looks like this:
urls = [“api-url”]
method = “GET”
data_format = “json”
json_query = “stats”
string_fields = [“paid”]

I want to use the json_query, because I don’t need the “charts” stuff, only the stats-portion.
The issue is that when I leave the json_query out, it only parses the charts-part like charts_payments_0_0 with as field the numeric part like 1535688385.
When I enable the JSON query nothing gets parsed at all.

Who knows what to change? Unfortunately I cannot change the JSON response, so I have to deal with the strings…

Thanx in advance!!

#2

Answered on github: https://github.com/influxdata/telegraf/issues/4650