Splunk Search

Count of repeated expression in a field

gjjagadeesh
New Member

Below is sample field value
Response : UX 189000055 - RESPONSE1, BB 10437470 - RESPONSE1, AB 11123345 RESPONSE2

If I search for string "RESPONSE1", then it query should display result as 2

Tags (2)
0 Karma

woodcock
Esteemed Legend

Like this:

...  | eval count=mvcount(split(_raw, "RESPONSE1")) - 1
| stats sum(count) AS count
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi gjjagadeesh,
let me understand: do you want to know how many times there is RESPONSE1, how many times RESPONSE2 and so on?
If yes, try something like this example:

| makeresults 
| eval message="UX 189000055 - RESPONSE1, BB 10437470 - RESPONSE1, AB 11123345 - RESPONSE2"
| rex field=message max_match=0 "\w\w\s+\d+\s+-\s+(?<response>\w+)"
| mvexpand response
| stats count BY response

Bye.
Giuseppe

0 Karma

richgalloway
SplunkTrust
SplunkTrust

What is your question?

---
If this reply helps you, Karma would be appreciated.
0 Karma

gjjagadeesh
New Member

Need a query to achieve desired results

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!

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...

SPL2 Deep Dives, AppDynamics Integrations, SAML Made Simple and Much More on Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...