Hello,
I’ve written a bash script that launch a “df -k” command and send its result to influx database after some treatment in the shell script. The result is like this (several more blocks of data) :
[
{
“fs”: “/dev/mapper/vgapp01-lvsavcatnbu”,
“mount”: “/catalog_save_nbu”,
“sia”: “TEC”,
“total”: 33538048,
“utilise”: 33538028
},
{
“fs”: “tmpfs”,
“mount”: “/run/user/0”,
“sia”: “TEC”,
“total”: 13158864,
“utilise”: 0
}
]
Note : the display of this example is wrong here : the path in the “fs” field has a \ before all /
But the data isn’t sent to influx db and I can se following error message in telegraf.log : E! Error in plugin [inputs.exec]: unable to parse out as JSON, json: cannot unmarshal array into Go value of type map[string]interface {}
I’ve tested the json format and it seems very fine (tested in jason validator tools).
I don’t understand, if you have any idea, i thank you in advance.
When I run ‘systemctl status telegraf’ in the terminal of my AWS instance, I see an error: “json: cannot unmarshal string into Go struct field event.data of type particle.data” (I’m trying to publish data from Particle through a webhook)
For me, I can see the telegraf.go code on github for the Particle. The event struct and data struct look like this:
type event struct {
Name string json:"event"
Data data json:"data"
TTL int json:"ttl"
PublishedAt string json:"published_at"
Database string json:"measurement"
}
type data struct {
Tags map[string]string json:"tags"
Fields map[string]interface{} json:"values"
}
I think telegraf can’t parse the JSON I’m sending it into a map in the data struct.
I’m trying to figure out why my JSON parsing is not working, but perhaps searching github for the telegraf Go code might help?
In the case that you have figured this out, could you provide some tips to get it working?
@Ghorin if you are still seeing that cannot unmarshal array into Go value error, can you change the output of your script to something like the following?