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!

Stay Connected: Your Guide to November Tech Talks, Office Hours, and Webinars!

🍂 Fall into November with a fresh lineup of Community Office Hours, Tech Talks, and Webinars we’ve ...

Transform your security operations with Splunk Enterprise Security

Hi Splunk Community, Splunk Platform has set a great foundation for your security operations. With the ...

Splunk Admins and App Developers | Earn a $35 gift card!

Splunk, in collaboration with ESG (Enterprise Strategy Group) by TechTarget, is excited to announce a ...