Splunk Search

Separate values from multi valued field

Dhruvi
Explorer

I have to write query for extracting out the values from multi valued field

example field: 

Region=America, Africa

Region=Asia

Region=America, Asia

i want table like this:

Region            Count

America             2

Asia                     2

Africa                 1

I have used split cmmnd:

eval temp=split(Region,“,”) 

Now what is happening is it is only giving me count of Asia =1
 

Need little help:)

Labels (1)
0 Karma

to4kawa
Ultra Champion
| makeresults
| eval _raw="Region=America, Africa
Region=Asia
Region=America, Asia"
| multikv noheader=t
| rex max_match=0 "(?<Region>A\w+)"
| table Region
| rename COMMENT as "this is your sample"
| stats count by Region

try stats by

Dhruvi
Explorer

okay it is working well 

 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Dhruvi ,

you have ro separate values in distinct events and then use stats, something like this:

| makeresults | eval Region="America, Africa"
| append [ | makeresults | eval Region="America, Africa" ]
| append [ | makeresults | eval Region="America" ]
| append [ | makeresults | eval Region="Asia" ]
| makemv delim="," Region
| mvexpand Region
| stats count BY Region

Use the last three rows.

Ciao.

Giuseppe

 

Dhruvi
Explorer

Thanks 🙂 it works as expected 

0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security(ES) 7.3 is approaching the end of support. Get ready for ...

Hi friends!    At Splunk, your product success is our top priority. With Enterprise Security (ES), we're here ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk, and empower your SOC to reach new heights! Duration: 1 hour  Prepare to ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...