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

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...