Skip to content

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

@Thidjs

Description

@Thidjs

Relevant conf

telegraf.conf

[[inputs.http]]
urls = [“https://api-url”]
method = “GET”
data_format = “json”
json_query = “stats”
string_fields = [“paid”]

json response

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

System info

Windows 10 fully updated
Telegraf latest nightly (7 sept)

Steps to reproduce

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!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugunexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions