Splunk Enterprise

Query to fetch current month Date ,previous 3 months date and future one month date from indexed data

Ashwini008
Builder

Hi,

I have around 1000 events in my indexed data. I have to create a DATE dropdown which pulls and shows all the dates of CURRENT MONTH,PREVIOUS 3 MONTHS AND 1 FUTURE MONTH DATE.

How do i write a query for this?

P.S: My Date is not index_time/_time.It is sharepoint data which i am indexing it in splunk

Thanks in Advance! Happy New year!

 

Query used to fetch DATE field and ProdDate is in yyyy-mm-dd format(2021-01-09)

index = splunk  sourcetype = splunk-sp | spath | fields m:properties_date | rename "m:properties_date" as "ProdDate" | dedup ProdDate | eval temp=split(ProdDate,"T") | eval ProdDate=mvindex(temp, 0) |table ProdDate

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

I don't understand our requirement either. Having said that, I think you should dedup last. Also, if you are interested in months rather than dates you could try

index = splunk  sourcetype = splunk-sp
| spath
| rex field=m:properties_date "(?<ProdDate>\d{4}-\d{2})-\d{2}T"
| dedup ProdDate
| table ProdDate

 Do you then need to select current month, 3 months previous and next month from these results? Why can't you just generate these based on now()?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I don't understand the problem.  You have a query already.  What are you trying to do that the query doesn't do?

Are you saying your index has data 1 month into the future?  Why?

---
If this reply helps you, Karma would be appreciated.
0 Karma

Ashwini008
Builder
0 Karma

General_Talos
Path Finder

If you are building dashboard, I am not sure if you checked details captured by @niketn in below mentioned post.

 

https://community.splunk.com/t5/Dashboards-Visualizations/Jquery-datepicker-in-splunk/m-p/361049

 

0 Karma

Ashwini008
Builder

@General_Talos  I am not using Datepicker. My requirement is to capture the the dates from my field PRODdate(this is not index time/_time). 

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