Splunk Search

How to edit my search to add subtotals for successful events by _time for every error?

shivarpith
Path Finder

What I have:

Time                   User        count     Error
2016-02-04 04:18:00 cinci     1  
2016-02-04 04:18:01 cfl
                       tampabay    2     
2016-02-04 04:18:03 nc        4  
2016-02-04 04:18:04             1         1 

What I need:

Time                   User        count      Error
2016-02-04 04:18:00 cinci     1  
2016-02-04 04:18:01 cfl
                       tampabay    2     
2016-02-04 04:18:03 nc        4  
Total users                        7
2016-02-04 04:18:04             1          1
Time                   User        count      Error
2016-02-04 04:18:08 cinci     2
2016-02-04 04:18:10 cfl
                       tampabay    2     
2016-02-04 04:18:13 nc        4  
Total users                        8
....
...
...

..... so before every error, it has to give the total successful event counts based on user and timestamp.

My search:

index=prod user=* 
| fields user,_time
| stats count by user,_time 
| stats values(user) as Domain,sum(count) as Total by _time
| append [ search index=prod error="xyz"
| stats count by error,_time
| stats count(error) as Error,sum(count) as Total by _time]
| sort _time
0 Karma

somesoni2
Revered Legend

Try something like this

index=prod user=* 
 | fields user,_time
 | stats count by user,_time 
 | stats values(user) as Domain,sum(count) as Total by _time
 | append [ search index=prod error="xyz"
 | stats count by error,_time
 | stats count(error) as Error,sum(count) as Total by _time]
 | sort _time
 | eval temp=Error | fillnull temp value=0
 | accum temp | appendpipe [| stats max(_time) as _time sum(Total) as Total by  temp | eval Domain="***************Total Users"]
 | sort _time temp | fields - temp
0 Karma
Get Updates on the Splunk Community!

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...