Splunk Search

How to stats ratio based on two fields

cheriemilk
Path Finder

Hi team,

I have a below sample raw events in splunk.

2020-11-30 19:15:26,726 ratingEnabled="[performance]"

2020-11-30 15:59:13,827 ratingEnabled="[objective,competency]" ratingEnabledGuideline="[objectiveGuideline]"

2020-11-30 05:34:40,986 ratingEnabled="[performance]" ratingEnabledGuideline="[performanceGuideline]"

stats requirement:

I want to get a ratio that enabled guideline per each rating. For example: analyze above sample events,

1. there are 3 ratings enabled(refer to ratingEnabled field): performance, objective and competency

2. there're 2 ratings enabled guideline(refer to ratingEnabledGuideline field): objective and performance

So the expected result I want splunk to return is:

 

ratingEnabledcountcount - enabled Guidelineratio - enabled guideline
performance2150%
objective11100%
competency100%

 

How to stats the ratio in this scenario?

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| rex max_match=0 field=ratingEnabled "(?<ratingEnabled>[^\[,\]]+)"
| mvexpand ratingEnabled
| rex field=ratingEnabledGuideline "(?<guideline>[^\[]+)Guideline"
| eval guided=if(ratingEnabled=guideline,1,0)
| stats count sum(guided) as guided by ratingEnabled
| eval ratio=guided*100/count

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
| rex max_match=0 field=ratingEnabled "(?<ratingEnabled>[^\[,\]]+)"
| mvexpand ratingEnabled
| rex field=ratingEnabledGuideline "(?<guideline>[^\[]+)Guideline"
| eval guided=if(ratingEnabled=guideline,1,0)
| stats count sum(guided) as guided by ratingEnabled
| eval ratio=guided*100/count
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...