Splunk Search

How to count a sum of events since a specified time?

ssackrider
Explorer

How to count how many events are over 1 yr old? And better yet, how to show a pie chart comparing against the entire list?

0 Karma
1 Solution

javiergn
SplunkTrust
SplunkTrust

I'm sure there will be other ways to achieve the same. Anyway, try this:

| metasearch index=foo sourcetype=bar
| eval year = relative_time(now(), "-1y")
| eval age = if(_time < year, "old", "new")
| stats count by age

Then go to the visualization tab and select Pie.

View solution in original post

0 Karma

javiergn
SplunkTrust
SplunkTrust

I'm sure there will be other ways to achieve the same. Anyway, try this:

| metasearch index=foo sourcetype=bar
| eval year = relative_time(now(), "-1y")
| eval age = if(_time < year, "old", "new")
| stats count by age

Then go to the visualization tab and select Pie.

0 Karma

ssackrider
Explorer

Wow-- Never thought of metasearch OR starting with a pipe.. but it works.. Thanks!

0 Karma
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 ...

Splunk is officially part of Cisco

Revolutionizing how our customers build resilience across their entire digital footprint.   Splunk ...

Splunk APM & RUM | Planned Maintenance March 26 - March 28, 2024

There will be planned maintenance for Splunk APM and RUM between March 26, 2024 and March 28, 2024 as ...