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!

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...

Integrating Splunk Search API and Quarto to Create Reproducible Investigation ...

 Splunk is More Than Just the Web Console For Digital Forensics and Incident Response (DFIR) practitioners, ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...