All Apps and Add-ons

Regex Stats count Help

valpravin
Engager

Hi All

I have String result as a

"Event":"BirthDay"
"Event":"MarriageAnniversary"
"Event":"NewYear"
"Event":"BirthDay"

when I do stats count by activity I want to get results as:

BirthDay : 2
MarriageAnniversary : 1
NewYear : 1

Tried Like this but no help

| rex field=_raw "\?Event=(?"":"\w+")" | stats count by Event
Tags (2)
0 Karma
1 Solution

tiagofbmm
Influencer

Hello

Please try this one

| rex field=_raw "\"Event\"\:\"(?<Activity>[^\"]*)"

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

When writing regular expressions or other code in questions, answers, or comments it's best to enclose them in backtic characters (`) so they don't get dropped. You can also highlight your code and click the "101010" button.

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

richgalloway
SplunkTrust
SplunkTrust

Your regex string is a little off. Try this one. You may need to insert additional backslashes to make rex happy. It can be tricky to create a regex with quotes in it.

| rex "Event\":\"(?<Event>\w+)\"" | ...
---
If this reply helps you, Karma would be appreciated.
0 Karma

tiagofbmm
Influencer

Hello

Please try this one

| rex field=_raw "\"Event\"\:\"(?<Activity>[^\"]*)"
Get Updates on the Splunk Community!

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Index This | What goes away as soon as you talk about it?

May 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...

What's New in Splunk Observability Cloud and Splunk AppDynamics - May 2025

This month, we’re delivering several new innovations in Splunk Observability Cloud and Splunk AppDynamics ...