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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...