Splunk Search

How to group status code in coloumn

chiddarthan17
Explorer

I need to display list of all failed status code in column by consumers

Final Result:

Consumers Errors Total_Requests Error_Percentage list_of_Status
Test 10 100 10  500 400 404

         

Is there a way we can display the failed status codes as well in of list of status coloumn

index=test | stats count(eval(status>399)) as Errors,count as Total_Requests by consumers | eval Error_Percentage=((Errors/Total_Requests)*100)
Labels (2)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

You need the eval like this

values(eval(if(status>399, status, null()))) as list_of_Status 

otherwise the eval just returns a boolean type result, so you need to use if and assign the result.

You can also do it like this after the stats using mvmap

| eval list_of_Status=mvfilter(list_of_Status>=399)

View solution in original post

chiddarthan17
Explorer

Thanks a lot. This works fine. Is there a way we can display only status which are greater than 399. Like (status>399)

i tried values(eval(status>399)) but it didn't work. 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try this query

index=test | stats count(eval(status>399)) as Errors,count as Total_Requests, values(Status) as list_of_Status by consumers 
| eval Error_Percentage=((Errors/Total_Requests)*100)
---
If this reply helps you, Karma would be appreciated.

chiddarthan17
Explorer

Thanks a lot. This works fine. Is there a way we can display only status which are greater than 399. Like (status>399)

i tried values(eval(status>399)) but it didn't work. 

Tags (1)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

You need the eval like this

values(eval(if(status>399, status, null()))) as list_of_Status 

otherwise the eval just returns a boolean type result, so you need to use if and assign the result.

You can also do it like this after the stats using mvmap

| eval list_of_Status=mvfilter(list_of_Status>=399)

chiddarthan17
Explorer

Thank you.This works perfectly. 

0 Karma
Get Updates on the Splunk Community!

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...