Splunk Search

How to combine multiple rows into one row

am2498
Engager

Hi, I am new to splunk. I have a query to return the count of successes and failures

I have a field http_status that can either be 200 (success) or anything other than 200 (failure)

 

 | stats count by http_status currently returns:

200     111

400     214

401     1

 

I want that anything other than 200 be grouped together as failure:


success    111

failure    215

 

Is there any way to do this?

Labels (2)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @am2498,

before the stats command, you have to define a new variable using eval and use this new variable in the stats command:

your_search
| eval status=if(http_status="200","success","failure")
| stats count BY status

Ciao.

Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @am2498,

before the stats command, you have to define a new variable using eval and use this new variable in the stats command:

your_search
| eval status=if(http_status="200","success","failure")
| stats count BY status

Ciao.

Giuseppe

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!

Unlocking Unified Insights: New Gigamon Federated Search App for Splunk

In today’s data-heavy environment, organizations are caught in a data distribution dilemma. As data volumes ...

GA: New Data Management App in Splunk Platform

Streamlining Data Management: Introducing a unified experience in Splunk Managing data at scale shouldn’t feel ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...