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!

Quantify Your Splunk Investment Impact: Introducing Savings Metrics to Value Insights

Building on the foundation established in our initial Value Insights releases, we are introducing the Savings ...

Event Series: Telemetry Pipeline Management

Balancing Scale and Spend: Gaining Control Over High-Volume Metrics in Splunk Observability Cloud As ...

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...