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
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...