Splunk Search

How to find records based on input from user date?

agupta13
Engager

I have set of records where the data has time column in it.

Eg:

agupta13_0-1682724463553.png


Here I will have an input from user where user will enter the date in input box in any format (yyyy/mm/dd)
I want to find all records that are greater than the time entered by user.

 

Labels (1)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

The problem is the "any" in any format.  Does this mean the user choses any format they wish, or does this mean that you dictate any format for your user?  If it is a free text input, while it is possible to parse multiple common date format, it is impossible to be exhaustive.

If you can dictate, say "yyyy/mm/dd" as you exemplified, it will be simple.  Say, your input token is $date_tok$.

| where _time > strptime($date_tok$, "%Y/%m/%d")
Tags (1)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

+1 on the date format - the simplest argument against "any" format is eu vs. us date - does 1/3/23 mean Jan 3rd or March 1st?

Also if you can (and in your case the timestamp seems to be contained in the _time field) you should filter by time as early as possible (time is the most efficient filter) so why not just use time picker to limit your search range?

0 Karma
Get Updates on the Splunk Community!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

(view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...