Hi,
Help. I am trying to store the JSON data from an HTTP request in an InfluxDB using Telegraf.
I get all the numeric data, but I cant seem to get the string data, or set any tags ?
I am reading JSON from various IoT devices running an open source firmware called Tasmota.
The status is retrieve via HTTP like this: http://temp03.local/cm?cmnd=status%200
Here’s a sample of the JSON output:
{
"Status": {
"Module": 0,
"DeviceName": "Temp03",
"FriendlyName": [
"Temp03"
],
"ButtonTopic": "0",
"Power": 0,
"LedState": 1,
"SensorRetain": 0,
"PowerRetain": 0
},
"StatusNET": {
"Hostname": "temp03-1234",
"IPAddress": "10.1.0.75",
"Gateway": "10.1.0.1"
}
}
}
Here is my telegraf config:
[[inputs.http]]
urls = ["http://temp03.local/cm?cmnd=status%200"]
data_format = "json"
json_query = ""
tag_keys = ["Hostname"]
json_string_fields = ["DeviceName","FriendlyName"]
name_override = "tasmota"
I was expecting this :
tasmota,hostname=temp03-1234
but I get this :
InfluxDB shell version: 1.8.3
> use tasmota
Using database tasmota
> show series
key
---
tasmota,host=grafana,url=http://temp03.local/cm?cmnd\=status%200
I know I can get rid of the host and url tags with:
tagexclude = [“url”, “host”]
But why isnt the hostname=temp03-1234 tag there ?
I have tried :
tag_keys = [“Hostname”]
tag_keys = [“hostname”]
tag_keys = [“Status.Hostname”]
tag_keys = [“Status_Hostname”]
but none of those options work. I cant seem to get any tags included.
Secondly, none of the string based fields are in the database. Specifically I added json_string_fields=[“DeviceName”,“FriendlyName”] but I only have numeric data in the database.
Again I’ve tried
json_string_fields = [“DeviceName”]
json_string_fields = [“Status.DeviceName”]
etc.
Any pointers please?
Versions:
$ influx --version
InfluxDB shell version: 1.8.3
$ telegraf --version
Telegraf 1.16.3 (git: HEAD c7f21728)
Thanks!
Regards,
Jon.