Splunk Search

Splunk table and regex filter

mnjmht18
New Member

I have following data in "log" field,
date1 name : message one
date2 name : message two
date3 name : message one
date4 name : message one
date5 name : message three
date6 name : message three

i want to filter this and create a table as below,
columns
log - count
message one - 3
message two - 1
message three - 2

how can i achieve this?

0 Karma

vnravikumar
Champion

Hi @mnjmht18

Try any one of the following

| makeresults 
| eval log="date1 name : message one,date2 name : message two,date3 name : message one,date4 name : message one,date5 name : message three,date6 name : message three" 
| makemv delim="," log 
| mvexpand log 
| rex field=log "name :\s+(?P<log>[^:]+)$" 
| stats count by log

or

| makeresults 
| eval log="date1 name : message one,date2 name : message two,date3 name : message one,date4 name : message one,date5 name : message three,date6 name : message three" 
| makemv delim="," log 
| mvexpand log 
| eval log= mvindex(split(log,"name :"),-1) 
| stats count by log
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try this query.

... | rex field=log "name : (?<log>.*)"
| stats count by log
---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

The OpenTelemetry Certified Associate (OTCA) Exam

What’s this OTCA exam? The Linux Foundation offers the OpenTelemetry Certified Associate (OTCA) credential to ...

From Manual to Agentic: Level Up Your SOC at Cisco Live

Welcome to the Era of the Agentic SOC   Are you tired of being a manual alert responder? The security ...

Splunk Classroom Chronicles: Training Tales and Testimonials (Episode 4)

Welcome back to Splunk Classroom Chronicles, our ongoing series where we shine a light on what really happens ...