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!

Build the Future of Agentic AI: Join the Splunk Agentic Ops Hackathon

AI is changing how teams investigate incidents, detect threats, automate workflows, and build intelligent ...

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...