Splunk Search

Add count of field instead of just count it

indeed_2000
Motivator

Hi I have log file that each minute store 1 event like this

8:00   1

8:01   1

8:02   1

 

instead of counting i want store last value and add new value to that, like this:

8:48    2

8:49   12 (10+2)

8:50   20  (3+12)

8:51   21 (1+20)

any idea?

 Thanks 

Tags (2)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| streamstats sum(count) as runningtotal

venkatasri
SplunkTrust
SplunkTrust

Hi @indeed_2000  You have to use streamstats command.

 

Tags (1)
0 Karma

venkatasri
SplunkTrust
SplunkTrust

@indeed_2000 

You can try something like this, i assumed your field name for numerical as 'count' you have to change it for your case.

 

 

<your_search_goes_here>
| reverse 
| streamstats sum(count)

 

 

Output would be something like this,

venkatasri_0-1625746936442.png

 

---

An upvote would be appreciated and Accept solution if this reply helps!

indeed_2000
Motivator

Field value is not number

field name= status (success,fail) 

 

Also i try these but not work:

index=main | reverse | streamstats sum(status)

index=main | reverse | streamstats sum(count(status))

any idea?

 Thanks 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Can you provide some sample events?

0 Karma

indeed_2000
Motivator

I do field extraction that the name is “status”, and value is “fail” or “success”.


2021-07-06 23:11:12,197 INFO [app] fail , time[10] User: anonymous
2021-07-06 23:11:12,187 INFO [app] success, User: anonymous
2021-07-06 23:11:12,178 INFO [app] fail , time[10] User: anonymous
2021-07-06 23:11:12,167 INFO [app] success, User: anonymous
2021-07-06 23:11:12,159 INFO [app] fail , time[10] User: anonymous
2021-07-06 23:11:12,149 INFO [app] success, User: anonymous
2021-07-06 23:11:12,141 INFO [app] fail , time[10] User: anonymous
2021-07-06 23:11:12,131 INFO [app] success, User: anonymous
2021-07-06 23:11:12,134 INFO [app] success, User: anonymous
2021-07-06 23:11:12,138 INFO [app] success, User: anonymous

expected result:
fail 1
success 1
fail 2
success 2
fail 3
success 3
fail 4
success 4
success 5
success 6

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try this:

| streamstats count by status
0 Karma
Get Updates on the Splunk Community!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...