At the bottom is an example of some metrics in a JSON file I’d like to massage into influxdb. This file is updated every 10 minutes and is converted from XML via xmltodict automatically. This is the first part of a much larger project to gather and display organisation wide infrastructure/system metrics.
Unfortunately, I’m no programmer and despite looking at [Influx Line Protocol documentation](InfluxDB line protocol tutorial | InfluxDB OSS v1 Documentation posts I’m still unclear about how to achieve this. I believe using telegraf’s json parser is the best way to go. However I’m unclear about what values I should use in telegraf.conf. Especially the GJSON paths. Some guidance would be appreciated!
I’m interested in extracting the following values…
“system”: { “name”: “"example1 },
“volume”: “id”: “#”
“volume”: {“name”: “/”}
“volume”: {“state”: “online”}
“volume”: {“spaceUsedGB”: “#####”}
“volume”: {“spaceAvailableGB”: “#####.##”}
“volume”: {“hardQuotaGB”: “###.##”,}
“volume”: {“softQuotaGB”: “###.##”}
“time”: “2018-12-11T09:40:02Z”,
measurement: system-name
tags: volume-id,volume-name,volume-state
fields: volume-SpaceUsedGb,volume-SpaceAvailableGB,volume-HardQuotaGB,volume-SoftQuotaGB
timestamp: time
How would I configure telegraf.conf given the above values???
.
######################### /etc/telegraf/telegraf.conf #######################################
Query is a GJSON path that specifies a specific chunk of JSON to be
parsed, if not specified the whole document will be parsed.
GJSON query paths are described here:
{GitHub - tidwall/gjson: Get JSON values quickly - JSON parser for Go
json_query = “”
Tag keys is an array of keys that should be added as tags.
tag_keys = [
** “my_tag_1”,**
** “my_tag_2”**
** ]**
String fields is an array of keys that should be added as string fields.
json_string_fields = []
Name key is the key to use as the measurement name.
json_name_key = “”
Time key is the key containing the time that should be used to create the
metric.
json_time_key = “”
##################################################################################
What should the resultant influx data point look like?
Thanks in advance
{
“pasxml”: {
“version”: “6.0.0”,
“system”: {
“name”: “example1”,
“IPV4”: “0.0.0.0”,
“alertLevel”: “critical”,
“state”: “online”
},
“time”: “2018-12-11T09:40:02Z”,
“volumes”: {
“volume”: [
{
“id”: “1”,
“name”: “/”,
“bladesetName”: {
“id”: “1”,
“#text”: “Set-1”
},
“state”: “Online”,
“raid”: “Object RAID6+”,
“director”: “Shelf-001,1”,
“volservice”: “0x0400000000000004(FM)”,
“objectId”: “I-xD0200000000000004-xG7ee84b0c-xU00004a75726a656e”,
“recoveryPriority”: “1”,
“efsaMode”: “retry”,
“spaceUsedGB”: “0”,
“spaceAvailableGB”: “695667.94”,
“hardQuotaGB”: “0.52”,
“softQuotaGB”: “0.52”,
“userQuotaPolicy”: {
“inherit”: “0”,
“#text”: “disabled”
},
“stats”: null
},
{
“id”: “8”,
“name”: “/datacentre/archvol/pan101”,
“bladesetName”: {
“id”: “1”,
“#text”: “Set-1”
},
“alertLevel”: “critical”,
“state”: “Online”,
“raid”: “Object RAID6+”,
“director”: “Shelf-008,1”,
“volservice”: “0x04000000000000ec(FM)”,
“objectId”: “I-xD02000000000000ec-xG5c7aef6f-xU00004a75726a656e”,
“recoveryPriority”: “50”,
“efsaMode”: “retry”,
“spaceUsedGB”: “117000.01”,
“spaceAvailableGB”: “695667.94”,
“hardQuotaGB”: “117000.00”,
“softQuotaGB”: “90000.00”,
“userQuotaPolicy”: {
“inherit”: “1”,
“#text”: “disabled”
},
“stats”: null
}