Splunk Search

Create splunk chart from seach with totals over time

eholz1
Builder

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
Builder

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
Builder

Hello, and Thank you

 

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

 

Eholz1

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Observability Simplified: Combining User Experience, Application Performance & ...

Tech Talk Observability Simplified: Combining User Experience, Application Performance & Network ...

Event Series May & June: From Network Visibility to Service Intelligence

Unifying the Network: Moving from Alert Noise to Service Intelligence with Splunk ITSI In today’s hybrid ...

Global Splunk User Group Events: May + June 2026

Your Splunk Community Awaits: Discover Upcoming User Group Events Worldwide    Staying ahead in the fast-paced ...