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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...