Trouble with Mutating Data in JSON File - Telegraf

Hello,

I’m trying to get my InfluxDB up and running but I’m having a real hard time pulling data from a JSON file that I have. All the data is in StringType and the Telegraf httpjson plugin only takes NumberType. I’ll give a snippet of what it looks like below. My question is is there any way to tell Influx/Telegraf to mutate the values coming in from StringType to a NumberType like you can with Grok in ElasticSearch? I’ve looked all around but to no avail.

Thank you in advance!

Snippet of JSON File:

[{"source":"engine","name":"Disconnected PV count","value":"63"},{"source":"engine","name":"Connected PV count","value":"108602"},{"source":"engine","name":"Paused PV count","value":"66957"},{"source":"engine","name":"Total channels","value":"394875"},{"source":"engine","name":"Approx pending jobs in engine queue","value":"1"},...]

Indeed it looks like the http json plugin from telegraf accepts only number types.

I cant find any code that support mutating in telegraf, like the logparser that support grok.

I would suggest to change the source input and remove the quotes:

[{"source":"engine","name":"Disconnected PV count","value":63}]

Or else if it is a single source, put a service in between and transform it with something like jq.

1 Like