Splunk Search

How to build a lookup table with a condition?

joydeep741
Path Finder

I have a lookup of epoch times:

epoch_time_lookup.csv

Start Time  End Time
1529737700  1529737800
1529737600  1529737750
1529737800  1529737900
1529737720  1529737722

I have a search which gives me results with 2 columns. EPOCH TIME and AVAILABILITY

EPOCH               AVAIL
1529737700  100
1529737600  100
1529737800  0
1529737720 100

Now I want to build a search, whenever AVAIL == 0 , check if the EPOCH is between any START and END times in epoch_time_lookup.csv lookup.

If yes, make availability 100.

Eg:

index= abc sourcetype=xyz | eval EPOCH = _time | eval AVAILABILITY = availability_field | **eval availability = (if EPOCH  in START and END of lookup) ,100, 0)**

Need help in building the logic.

Tags (2)
1 Solution

woodcock
Esteemed Legend

This solution is based on this other Q&A:

https://answers.splunk.com/answers/648345/timechart-volume-per-hour-same-day-over-several-we.html
Try this:

index= abc sourcetype=xyz
| eval AVAILABILITY = availability_field
| eval availability = if([|inputlookup epoch_time_lookup.csv 
                          | rename "Start Time" AS time>, "End Time" AS time< 
                          | format 
                          | rex field=search mode=sed "s/time/_time/g s/\"//g"] ,100, 0)

View solution in original post

0 Karma

woodcock
Esteemed Legend

This solution is based on this other Q&A:

https://answers.splunk.com/answers/648345/timechart-volume-per-hour-same-day-over-several-we.html
Try this:

index= abc sourcetype=xyz
| eval AVAILABILITY = availability_field
| eval availability = if([|inputlookup epoch_time_lookup.csv 
                          | rename "Start Time" AS time>, "End Time" AS time< 
                          | format 
                          | rex field=search mode=sed "s/time/_time/g s/\"//g"] ,100, 0)
0 Karma

joydeep741
Path Finder

@woodcock
I corrected it. Thanks a lot.
What a genius way of doing this.

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