Hi.
I'm trying to parse the information from a log line with this format.
2021 Mar 30 00:45:01;1617075901;user1,gw11,0;user1,gw22,5;user2,gw33,2;user2;gw43,3
I'm using dissect to format the first part of the log, with this:
dissect {
mapping => {"message" => "%{fecha};%{timestamp};%{data}"}
}
the "data" field could be variable...
2021 Mar 30 00:45:01;1617075901;user1,gw11,0;user1,gw22,5;user2,gw33,2;user2;gw43,3
or
2021 Mar 30 00:46:01;1617075961;user1,gw11,3;user1,gw22,5
or
2021 Mar 30 00:47:01;1617076021;user1,gw11,5;user1,gw22,5;user3,gw33,2;user3;gw43,3;user4,gw44,4;user4,gw55,3
and so on...
What i need is to transform this log into multiple events, in particular an event per "User"
I'm struggling to parse the "data" and add the "integer" value indicated as a summ per user.
For example, a log line like this:
2021 Mar 30 00:46:01;1617075961;user1,gw11,3;user1,gw22,5
Needs to be an event like this:
event 1
{
"_index": "index1",
"@timestamp": "2021 Mar 30 00:47:01"
"_type": "doc",
"user": "user1"
"gateways": [
{
"name": "gw11"
"gwcalls": 3
}
{
"name": "gw22"
"gwcalls": 5
}
]
"totalcalls":8
}
And and log line like this:
2021 Mar 30 00:47:01;1617076021;user1,gw11,5;user1,gw22,5;user3,gw33,2;user3;gw43,3;user4,gw44,4;user4,gw55,3
Need to be transform into 3 events like this
event 1
{
"_index": "index1",
"@timestamp": "2021 Mar 30 00:47:01"
"_type": "doc",
"user": "user1"
"gateways": [
{
"name": "gw11"
"gwcalls": 5
}
{
"name": "gw22"
"gwcalls": 5
}
]
"totalcalls":10
}
event 2
{
"_index": "index1",
"@timestamp": "2021 Mar 30 00:47:01"
"_type": "doc",
"user": "user3"
"gateways": [
{
"name": "gw22"
"gwcalls": 5
}
{
"name": "gw33"
"gwcalls": 2
}
]
"totalcalls":7
}
event 3
{
"_index": "index1",
"@timestamp": "2021 Mar 30 00:47:01"
"_type": "doc",
"user": "user4"
"gateways": [
{
"name": "gw44"
"gwcalls": 4
}
{
"name": "gw55"
"gwcalls": 3
}
]
"totalcalls":7
}
Is possible?. Could someone point me in the right direction?
Thanks!