Splunk Search

how to get statistical values for different fields

varsh_6_8_6
Explorer

I have to create a base search for a dashboard and I am kinda stuck. Any help would be appreciated.

index=service msg.message="*uri=/v1/payment-options*" eHttpMethodType="GET"
| fields index, msg.springProfile,msg.transactionId,eHttpStatusCode,eHttpMethodType,eClientId,eURI
| dedup msg.transactionId
| rename msg.springProfile as springProfile
| eval profile = case(like(springProfile, "%dev%"), "DEV",
           like(springProfile, "%qa%"), "QA",
           like(springProfile, "%uat%"), "UAT")
           
| eval request= case(like(eURI, "%/v1/payment-options%"), "PaymentOptions",
                       like(eURI, "%/v1/account%"), "AccountTransalation")
                               
| stats 
count as "TotalRequests",
count(eval(eHttpStatusCode=201 or eHttpStatusCode=204 or eHttpStatusCode=200)) as "TotalSuccessfulRequests",
count(eval(eHttpStatusCode=400)) as "Total400Faliures", 
count(eval(eHttpStatusCode=422)) as "Total422Faliures", 
count(eval(eHttpStatusCode=404)) as "Total404Faliures",
count(eval(eHttpStatusCode=500)) as "Total500Faliures", by profile, eClientId

Now that I want to include the stats in the basesearch else my values/events  would be truncated. My problem is I need to also count 

| stats
count as "TotalRequests",
count(eval(eHttpStatusCode=201 or eHttpStatusCode=204 or eHttpStatusCode=200)) as "TotalSuccessfulRequests"

by request  for each of the profile such as Dev, QA,UAT to display in 3 different panels.

How to incorparate this in the above basesearch

Labels (1)
Tags (1)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

You need to go back to the four golden rules of asking an answerable analytical question that I call 4 Commandments:

  • Illustrate data input (in raw text, anonymize as needed), whether they are raw events or output from a search that volunteers here do not have to look at.
  • Illustrate the desired output from illustrated data.
  • Explain the logic between illustrated data and desired output without SPL.
  • If you also illustrate attempted SPL, illustrate actual output and compare with desired output, explain why they look different to you if that is not painfully obvious.
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Do you mean to use your "base search" and then filter based on profile for each panel? For example

| where profile="Dev"

 

0 Karma
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 ...