Splunk Search

How to search count trends by displaying a 3 column table with source name, count (last 10 min) and count (now)?

vikas_gopal
Builder

Hi Experts,

I need your expert advice. I want to create a table which will have 3 columns e.g source name, count (last 10 min), count (now). What I need is to check the trend count over past 10 min. Please suggest.

Thanks

Tags (3)
1 Solution

MuS
SplunkTrust
SplunkTrust

Hi vikas_gopal,

take a look at this run everywhere command, this will compare event count from 3 minutes ago with event count 2 minutes ago:

index=_internal earliest=-3min@min 
| bucket _time span=1min 
| stats last(_time) AS last_time count AS per_min_count by _time, host
| eval 2min_ago = if(last_time > exact(relative_time(now(),"-3min@min")) AND last_time <= exact(relative_time(now(),"-2min@min")) , per_min_count ,"0")
| eval current_count = if(last_time > exact(relative_time(now(),"-2min@min")) AND last_time <= exact(relative_time(now(),"-1min@min")) , per_min_count ,"0") 
| stats max(last_time) AS _time, values(host) AS host, max(current_count) AS current_count, max(2min_ago) AS 2min_ago 
| eval diff = '2min_ago' - 'current_count'

Hope this helps to get you started ...

cheers, MuS

View solution in original post

MuS
SplunkTrust
SplunkTrust

Hi vikas_gopal,

take a look at this run everywhere command, this will compare event count from 3 minutes ago with event count 2 minutes ago:

index=_internal earliest=-3min@min 
| bucket _time span=1min 
| stats last(_time) AS last_time count AS per_min_count by _time, host
| eval 2min_ago = if(last_time > exact(relative_time(now(),"-3min@min")) AND last_time <= exact(relative_time(now(),"-2min@min")) , per_min_count ,"0")
| eval current_count = if(last_time > exact(relative_time(now(),"-2min@min")) AND last_time <= exact(relative_time(now(),"-1min@min")) , per_min_count ,"0") 
| stats max(last_time) AS _time, values(host) AS host, max(current_count) AS current_count, max(2min_ago) AS 2min_ago 
| eval diff = '2min_ago' - 'current_count'

Hope this helps to get you started ...

cheers, MuS

vikas_gopal
Builder

Works like magic , but things are not clear to me , like purpose of using last(_time), line 4 and 5 . Need a small celerity on these.

0 Karma

MuS
SplunkTrust
SplunkTrust

Those two lines (4 & 5) will count events based on the last_time value which was set in the stats on line 3

vikas_gopal
Builder

I get it , thanks MuS for your quick response you are awesome..;)

MuS
SplunkTrust
SplunkTrust

Thanks, you're welcome 🙂

0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...