Hi. I’m really close to solving my issue and just need a little help getting over the last piece of data. I have a nested array “events” in this dataset:
{
"count": 9,
"limit": 200,
"offset": 0,
"items": [
{
"uid": "52e2e31a-19a9-4bf1-9259-cab75d722ea1",
"status": "ACTIVE",
"lastEventDate": "2025-07-10T03:26:25Z",
"entityUid": "1e9b9771-0bcf-4e55-9e70-7fad82241b27",
"entityName": "MGR",
"events": []
},
{
"uid": "a03431ca-893f-491c-924b-7053720b93a8",
"status": "COMPLETED",
"lastEventDate": "2025-07-10T02:56:27Z",
"entityUid": "1e9b9771-0bcf-4e55-9e70-7fad82241b27",
"entityName": "MGR",
"events": [
{
"description": "Read MGR device records successfully",
"username": "System User",
"date": "2025-07-10T02:56:27Z",
"action": "UPDATE"
}
]
}
]
}
I can get all of the data in the output, but the events array enumerates as a map[string]. I’m unsure how to unspool this inner array.
scc_changelog,host=cc05ab3969dd uid="a03431ca-893f-491c-924b-7053720b93a8",status="COMPLETED",entityName="MGR",entityUid="1e9b9771-0bcf-4e55-9e70-7fad82241b27",lastEventDate="2025-07-10T02:56:27Z",events="[map[action:UPDATE date:2025-07-10T02:56:27Z description:Read MGR device records successfully username:System User]]" 1752116187000000000
This is the part that I need help on:
events="[map[action:UPDATE date:2025-07-10T02:56:27Z description:Read MGR device records successfully username:System User]]"
I’m guessing it’s because I have the array as a field. I’m ok with just flattening the events array as a string minus the “map” syntax. But looking for someone with more mojo with this than I for advice.
Here is my config:
[[inputs.file]]
name_override = "scc_changelog"
files = ["/etc/telegraf/telegraf.d/test.json"]
data_format = "xpath_json"
xpath_allow_empty_selection = true
xpath_native_types = true
[[inputs.file.xpath]]
metric_name = "'scc_changelog'"
metric_selection = "//items/*"
timestamp = "lastEventDate"
timestamp_format = "2006-01-02T15:04:05.9999999Z"
[inputs.file.xpath.fields]
uid = "uid"
status = "status"
entityName = "entityName"
entityUid = "entityUid"
lastEventDate = "lastEventDate"
events = "events"
[[outputs.file]]
files = [ "stdout" ]
Thanks in advance!