Splunk Search

How to Fill Null for fail or exception

indeed_2000
Motivator

Hi

here is my spl, that show different status:

index="myindex" | rex "status\[(?<status>\w+)"| stats count(status) by status

here is the current result:

status                       count(status)
successful             3581

 

here is the exception result:

status                       count(status)
successful             3581

fail                                0

exception                0

 

FYI: some time fail or exception might bot be in log file some time might be exist, neet to show in stats result even if these stats not exist.

Any idea?

Thanks

Labels (3)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| append [
  | makeresults
  | fields - _time
  | eval status=split("exception|fail","|")
  | mvexpand status
  | eval "count(status)" = 0]
| stats sum(*) as * by status

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| append [
  | makeresults
  | fields - _time
  | eval status=split("exception|fail","|")
  | mvexpand status
  | eval "count(status)" = 0]
| stats sum(*) as * by status

indeed_2000
Motivator

Thanks it work, How can I add total column, like below?

 

status                       count(status)
successful             3581

fail                                0

exception                0

total                              3581

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
0 Karma

indeed_2000
Motivator

before ask here use addtotals but status field is empty and try label but create another column.

 

current output:

status                count(status)
Exception        0
Fail                       0
successful     3581
                              3581

expected output:

status                count(status)
Exception        0
Fail                       0
successful     3581
total                    3581

 

0 Karma
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!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...