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!

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...