Splunk Search

How to exclude maintenance time from my query?

tchintam
Path Finder

Say suppose, I have a inputlookup which has start_date, end_date, start_time and end_time. This is my scheduled maintenance time. I want to include this in my main query to remove this time from this main query. How do I do that?

Tags (2)
0 Karma
1 Solution

tiagofbmm
Influencer

Use the following:

| inputlookup yourlookup
| eval earliest=strptime(End_Date + " " + End_Time,"%Y-%m-%d %H:%M:%S"), latest=strptime(Start_Date + " " + Start_Time,"%Y-%m-%d %H:%M:%S")
| return earliest, latest

That will give you the earliest and latest fields, and so you can pass them to your main query, like this:

Main query example

index=_internal [ 
 | inputlookup yourlookup
    | eval earliest=strptime(End_Date + " " + End_Time,"%Y-%m-%d %H:%M:%S"), latest=strptime(Start_Date + " " + Start_Time,"%Y-%m-%d %H:%M:%S")
    | return earliest, latest
]

View solution in original post

tiagofbmm
Influencer

Use the following:

| inputlookup yourlookup
| eval earliest=strptime(End_Date + " " + End_Time,"%Y-%m-%d %H:%M:%S"), latest=strptime(Start_Date + " " + Start_Time,"%Y-%m-%d %H:%M:%S")
| return earliest, latest

That will give you the earliest and latest fields, and so you can pass them to your main query, like this:

Main query example

index=_internal [ 
 | inputlookup yourlookup
    | eval earliest=strptime(End_Date + " " + End_Time,"%Y-%m-%d %H:%M:%S"), latest=strptime(Start_Date + " " + Start_Time,"%Y-%m-%d %H:%M:%S")
    | return earliest, latest
]

tiagofbmm
Influencer

Please let me know if the answer was useful for you. If it was, accept it and upvote. If not, give us more input so we can help you with that

0 Karma

tchintam
Path Finder

Thanks for this.

0 Karma

p_gurav
Champion

Is it possible to provide sample data for csv?

0 Karma

tchintam
Path Finder

I already have data in that lookup.

Say example:

Name End Date End Time Start Date Start Time

Dennis 2017-08-04 17:00:00 2017-07-04 06:00:00

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...