Splunk Search

How can I count by date, field, and range?

tkwaller_2
Communicator

Hello

I have some steps in a table that have a due date and SLA tied to them. Im trying to sum number of SLA days by date range.

Heres an example table:

Name      SLA        Due Date
Sample 1    5  2018-05-03 22:59:17.246000
Sample 2    10   2018-04-27 22:59:17.246000
Sample 3    5  2018-03-20 22:59:17.246000
Sample 4    5  2018-03-13 22:59:17.246000
Sample 5    2  2018-02-27 22:59:17.246000

I'm trying to total SLA by Date Range -
"Sum of SLA days for Next 30 days"

"Sum of SLA days for 31-60 days"

"Sum of SLA days for 61-90 days"

"Sum of SLA days for 90+ days"

0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try

your current search giving table with fields Name SLA "Due Date"
| eval DateRange=round((strptime('Due Date',"%Y-%m-%d %H:%M:%S.%6N")-now())/86400)
| eval DateRange=case(DateRange<=30,"Next 30 days",DateRange<=60,"31-60 days", DateRange<=90,"61-90 days",true(),"90+ days)
| stats sum(SLA) as "total SLA" by DateRange
| eval DateRange="Sum of SLA days for ".DateRange

View solution in original post

somesoni2
Revered Legend

Give this a try

your current search giving table with fields Name SLA "Due Date"
| eval DateRange=round((strptime('Due Date',"%Y-%m-%d %H:%M:%S.%6N")-now())/86400)
| eval DateRange=case(DateRange<=30,"Next 30 days",DateRange<=60,"31-60 days", DateRange<=90,"61-90 days",true(),"90+ days)
| stats sum(SLA) as "total SLA" by DateRange
| eval DateRange="Sum of SLA days for ".DateRange
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...