Splunk Search

Create splunk chart from seach with totals over time

eholz1
Contributor

Hello Members,

I have seen and used the accum command, but it does not quite give me what I want.

I have this search below which gives me a line chart with event count over the time range:

index=main sourcetype=cisco:asa host=* message_id=113004
| eval Date=strftime(_time, "%Y-%m-%d %H:%M:%S")
| timechart count BY message_id

The graph type can be any type. I would like to get an accumulated total for a time period, like 24 hours, OK to count every hour, but show the accumulated count each hour, with the ending total for the time range, i.e. 24hr.

Thanks for greate source of help here,

eholz1

Labels (2)
0 Karma
1 Solution

yuanliu
SplunkTrust
SplunkTrust

The command you are looking for is streamstats.  If you have a single series, you can do

| timechart count
| steamstats sum(count) as cumulative

But your OP suggests that you have multiple series.  For that, you can do something like

index=main sourcetype=cisco:asa host=* message_id=113004
| timechart count BY message_id
| streamstats sum(*) as *-cumulative by message_id

This produces two extraneous series "*" and "*-cumulative".  I don't know how to remove them.  If you have a limited number of message values, you can do

index=main sourcetype=cisco:asa host=* message_id=113004
| timechart count BY message_id
| streamstats sum(msg_id1) as msg_id1-cumulative sum(msg_id2) as msg_id2 ... by message_id

View solution in original post

Tags (1)

yuanliu
SplunkTrust
SplunkTrust

Not sure what the real requirement is.  Do you mean a 24-hour chart like this?

totalby.png

I.e., a group of varying line charts and a group of horizontal lines representing their period total?  For this, you can do something like

index=main sourcetype=cisco:asa host=* message_id=113004
| timechart count BY message_id
| eventstats sum(*) as *-Total

0 Karma

eholz1
Contributor

Thank you very much for the reply. I will try the search you suggest. Here is a screen shot of one result, which shows the number of events over time. But, starting from left of chart, instead of seeing values like: 7, 12,13,12,9 - I would like to see 7,19,32,41, etc.

eholz1_0-1690299447166.png

Thanks Again, will check your suggestion, and get back

0 Karma

yuanliu
SplunkTrust
SplunkTrust

The command you are looking for is streamstats.  If you have a single series, you can do

| timechart count
| steamstats sum(count) as cumulative

But your OP suggests that you have multiple series.  For that, you can do something like

index=main sourcetype=cisco:asa host=* message_id=113004
| timechart count BY message_id
| streamstats sum(*) as *-cumulative by message_id

This produces two extraneous series "*" and "*-cumulative".  I don't know how to remove them.  If you have a limited number of message values, you can do

index=main sourcetype=cisco:asa host=* message_id=113004
| timechart count BY message_id
| streamstats sum(msg_id1) as msg_id1-cumulative sum(msg_id2) as msg_id2 ... by message_id
Tags (1)

eholz1
Contributor

Hello, and Thank you

 

This is what I need. Again I thank you for the information.

 

Eholz1

0 Karma
Get Updates on the Splunk Community!

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...