Splunk Search

How to create a table showing the count of values across Lists/Arrays in multiple queries?

beaverjustin1
Engager

If I have queries with Lists/Arrays containing events :

line.Data = [eventOne, eventThree];  line.Data = [eventOne, eventTwo]; 

How can I create a table that shows the count of the different events:

eventOne: 2

eventTwo: 1

eventThree: 1

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Here is a runanywhere example of how you might approach this

| makeresults
| fields - _time
| eval line.Data = split("[eventOne, eventThree];[eventOne, eventTwo]",";")
| mvexpand line.Data
``` the lines above create sample events, one event per line.Data ```
| eval event=split(trim('line.Data',"[]"),", ")
| stats count by event
0 Karma

TrangCIC81
Communicator

Try this.

 

<your base search>
| mvexpand line.Data
| stats count by line.Data

 

  1. Replace <your base search> with the search that produces the line.Data field containing the lists/arrays.
  2. Use the mvexpand command to expand the line.Data field into separate rows, one for each event in the list.
  3. Use the stats command with the count function to count the number of occurrences of each event.
Get Updates on the Splunk Community!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...