Splunk Search

Count comma delimited field

neileosis
Engager

I am trying to get counts based on comma delimited values for specified groupings of events.

For instance I have the following logs.

 

Event=A Ids="55,32,5"
Event=A Ids="55"
Event=B Ids="56,63"
Event=C Ids="23,53,12"
Event=C Ids="39,6"

 

I want the data to show up in a table like the following

Event A&BEvent C
65

 

How would I craft the query to get it to aggregate it like this? 

Note: This would be happening for a large number of events.

Labels (4)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

This example gives you what you want - however, I have used simple logic to know that A and B need to be combined - you will have to address that grouping as you need.

This example can be pasted to the splunk search. All up to the table Ids is setting up your example data

| makeresults
| eval events="Event=A Ids=\"55,32,5\"##Event=A Ids=\"55\"##Event=B Ids=\"56,63\"##Event=C Ids=\"23,53,12\"##Event=C Ids=\"39,6\""
| makemv delim="##" events
| mvexpand events
| rename events as _raw
| extract
| table Event Ids
| eval Ids=split(Ids,",")
| eval EventGroup=if(Event="C", Event, "A&B")
| stats count(Ids) as idc by EventGroup
| transpose header_field=EventGroup
| fields - column

Hope this helps

View solution in original post

bowesmana
SplunkTrust
SplunkTrust

This example gives you what you want - however, I have used simple logic to know that A and B need to be combined - you will have to address that grouping as you need.

This example can be pasted to the splunk search. All up to the table Ids is setting up your example data

| makeresults
| eval events="Event=A Ids=\"55,32,5\"##Event=A Ids=\"55\"##Event=B Ids=\"56,63\"##Event=C Ids=\"23,53,12\"##Event=C Ids=\"39,6\""
| makemv delim="##" events
| mvexpand events
| rename events as _raw
| extract
| table Event Ids
| eval Ids=split(Ids,",")
| eval EventGroup=if(Event="C", Event, "A&B")
| stats count(Ids) as idc by EventGroup
| transpose header_field=EventGroup
| fields - column

Hope this helps

neileosis
Engager

Thanks so much! This works as needed.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Automated Threat Analysis: Available in ES Premier

Automated Threat Analysis: Centralize and Accelerate Phishing Investigations in Splunk Enterprise ...

What’s New in Splunk AI: Volume 02

Welcome to the second edition of “What’s New in Splunk AI” where we look at the latest and greatest updates, ...

Best Practices: Splunk auto adjust pipeline queue

When you enable autoAdjustQueue in Splunk, maxSize should be understood as the queue size Splunk starts with ...