Hi,
I'm trying to use push_previous_map_as_event to aggregate and save everything as key/value fields in a document.
My data looks like this:
device: router1
property: mem_prop1 ( there are twelve properties per component-name for a device)
component-name: FPC1:CPU1
value: 1
sequence: 1000 (this appears to be unique per device and component-name)
device: router2
property: mem_prop2
component-name: FPC2:CPU2
value: 2
sequence: 2000
This is my aggregate filter which is storing the property-name and value inside an array:
if [component-name] and [property-name] and [property-value] {
aggregate {
task_id => "%{device}-%{sequence}-%{component-name}"
timeout_task_id_field => "task_id"
timeout_timestamp_field => "@timestamp"
code => "
map['sequence'] ||= event.get('sequence')
map['device'] ||= event.get('device')
map['component-name'] ||= event.get('component-name')
map['properties'] ||= []
map['properties'] << {event.get('property-name') => event.get('property-value')}
"
push_map_as_event_on_timeout => true
push_previous_map_as_event => true
timeout => 60
}
}
else {
drop {}
}
My output looks like this:
"properties": [
{
"mem-util-packet-dma-utilization": 9
},
{
"mem-util-kernel-flow-table-allocations-failed": 0
},
{
"mem-util-kernel-toe-pkt-transfer-allocations-failed": 0
},
{
"mem-util-kernel-cos-allocations-failed": 0
},
{
"mem-util-kernel-filter-allocations-failed": 0
},
{
"mem-util-kernel-rtt-allocations-failed": 0
},
{
"mem-util-kernel-rt-allocations-failed": 0
},
{
"mem-util-kernel-iff-allocations-failed": 0
},
{
"mem-util-kernel-ifl-allocations-failed": 0
},
{
"mem-util-kernel-size": 3221225472
},
{
"mem-util-kernel-utilization": 26
},
{
"mem-util-kernel-bytes-allocated": 860475368
}
]
I'd like to flatten properties out so that all of the property-names and values get saved as key/value fields in the aggregated document. How do I do that?
Thank you.