Hi all,
I'm working on getting some logs onboarded and I'm having an issue with a field that contains Key/Values inside an array. (For reference please see below)
{
"redis_cache_read_bytes": 741,
"format": "json",
"params": [
{
"value": "backend",
"key": "namespace_id"
},
{
"value": "web-app",
"key": "project_id"
},
{
"value": "617",
"key": "id"
}
],
...
}
What I would like to be able to do is something like this:
{
"redis_cache_read_bytes": 741,
"format": "json",
"item": {
"backend": "namespace_id",
"project_id": "web-app",
"id": "617"
}
}
I've considered a few ways of doing this (foreach processor into script processor, for loop via script processor etc. ) but I can't seem to make it do anything other than create a document with the last k/v value in the array (example below)
for (item in ctx.params) { ctx.item = item; }
{
"item": {
"value": "617",
"key": "id"
},
"redis_cache_read_bytes": 741,
"format": "json",
"params": [
{
"value": "backend",
"key": "namespace_id"
},
{
"value": "web-app",
"key": "project_id"
},
{
"value": "617",
"key": "id"
}
],
...
}