Dashboards & Visualizations

How to get data by comparing with a date field and current date?

dtccsundar
Path Finder

We have different licenses expires by different dates .The current sourcetype data comprises of both future expiry and past expiry too.

we don’t want license that are expired meaning anything that is before the current day.

"Expire valid To" field will have this date .

Please let me know how to achieve this in SPL .

 

 

 

Labels (1)
Tags (1)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

Here's a simple example that generates 20 dates within one year before or after today and makes that date YYYY-MM-DD.

The where clause simply checks that date is >= today

| makeresults count=20
``` Make up a random sample of expiry dates within 1 uyear before and after today ```
| eval r=365
| eval range=random() % (r * 2 * 86400) 
| eval "Expire valid To"=strftime(now() + (r * 86400) - range, "%F")
``` Now simply test whether the expiry date is today or later ```
| where strptime('Expire valid To', "%F") >= relative_time(now(), "@d")

The last line is what you will need. Depending on your date format, change the strptime format variable (currently %F is YYYY-MM-DD).

 

View solution in original post

0 Karma

dtccsundar
Path Finder

It works bowesmana .Thank you .

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Here's a simple example that generates 20 dates within one year before or after today and makes that date YYYY-MM-DD.

The where clause simply checks that date is >= today

| makeresults count=20
``` Make up a random sample of expiry dates within 1 uyear before and after today ```
| eval r=365
| eval range=random() % (r * 2 * 86400) 
| eval "Expire valid To"=strftime(now() + (r * 86400) - range, "%F")
``` Now simply test whether the expiry date is today or later ```
| where strptime('Expire valid To', "%F") >= relative_time(now(), "@d")

The last line is what you will need. Depending on your date format, change the strptime format variable (currently %F is YYYY-MM-DD).

 

0 Karma
Get Updates on the Splunk Community!

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

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...