Splunk Search

Calculating Trends in tables

andreafebbo
Communicator

Hi all.

I'd like to create a table like the following columns:

server - event count - event count last period

what do I mean by that?

I have to do a count by of the events, and this is trivial.

base query | stats count as events by source 

now i have a selector that let me select the period (the classic splunk time selector).

what i need is the following:
if the selector is "last week" i need to count in the first column the events of the last week and in the second column the events of the week before that

if the selector is "last mount" i need to count in the first column the events of the last mount and in the second column the events of the mount before that

etc...

Id like to do that without messing with html, xml or any other language. I'd like, if possible, a plain splunk search.

Thanks a lot.

Andrea

1 Solution

jpolcari
Communicator

This looks like a good use of bucket https://docs.splunk.com/Documentation/Splunk/6.4.2/SearchReference/Bucket

This should work for you:

base query earliest=-30d | bucket _time span=1d |  stats count as events by source 

Basically, the bucket command will break your search results into specified time periods. In the search above we take the last month and break them into buckets per day.

View solution in original post

jpolcari
Communicator

This looks like a good use of bucket https://docs.splunk.com/Documentation/Splunk/6.4.2/SearchReference/Bucket

This should work for you:

base query earliest=-30d | bucket _time span=1d |  stats count as events by source 

Basically, the bucket command will break your search results into specified time periods. In the search above we take the last month and break them into buckets per day.

Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...