Hi,
I'm trying to merge two data sets into one document that will get stored in ES.
My first data set looks like this:
"_source": {
"protocol-name": "BGP",
"name-tag": "default",
"@version": "1",
"host": "lab-aar-deployment-55b8f56f6f-lh2fh-telegraf-agent",
"device": "aara101.mgt.net",
"name": "bgp",
"@timestamp": "2022-02-24T20:25:32.506Z",
"identifier": "BGP",
"session-state": "ESTABLISHED",
"neighbor-address": "2001:578:30:1100:10:10:10:2"
}
My second data set looks like this:
"_source": {
"protocol-name": "BGP",
"name-tag": "default",
"@version": "1",
"host": "lab-aar-deployment-55b8f56f6f-lh2fh-telegraf-agent",
"prefixes-installed": 0,
"device": "aara101.mgt.net",
"name": "bgp",
"@timestamp": "2022-02-24T20:25:32.505Z",
"identifier": "BGP",
"neighbor-address": "2001:578:30:1100:10:10:10:2",
"afi-safi-name": "IPV4_UNICAST"
}
As you can see "session-state" is only in the first data set and I would like to merge it with the second data set and create one document that has everything in it.
I believe I need to use the aggregate plugin but just not sure how.
My first failed attempt:
if [session-state] {
aggregate {
task_id => "%{device}-%{neighbor-address}"
code => "
event.to_hash.each { |k,v|
unless map[k]
map[k] = v
end
}
"
}
} else {
aggregate {
task_id => "%{device}-%{neighbor-address}-%{afi-safi-name}"
end_of_task => true
timeout => 60
code => "
event.to_hash.each { |k,v|
unless map[k]
map[k] = v
end
}
# event.cancel
"
}