Splunk Search

Dynamic time period for sub-search based on date on each row from the main search?

tg_to
Loves-to-Learn

Hi, 

I have a main search that generates counts of events table by date, UID and host something like for example:

dateUIDhostcount
20201014abc01host125
20201015abc01host216
20201016xyz01host11

 

Then I generate additional fields from a sub-search by joining on those dates and UIDs.  The problem is, I need to dynamically perform the sub-search for earliest=-30d and latest=-3d based on the values of dates in each row from the main search. That is, the sub-search for the second row where dat=20201015 should only extract results from 30 days prior to 2020-10-15  (i.e. earliest=2020-09-15) upto 3days prior to 20201015 (i.e. latest=2020-10-12). Similarly, the sub-search for the third row should only extract results from 30 days prior to 2020-10-16 (i.e. earliest=2020-09-16) up to 3days prior to 2020-10-16 (i.e. latest=20201013). 

How do I do that? 

So far, I have done: 

 

<main search> | eval date=strftime(_time, "%Y%m%d") ... 
| join type=inner date, uid, host
   [search index=subsearch_idx 
        [| gentimes start=-30 end=-3 increment=1d | addinfo | eval earliest=info_min_time | eval latest=info_max_time | return earliest latest] continue_subsearch...]
| continue_main_search 

 

 

 

It doesn't seem to work however. How can I populate the dates for the sub-search dynamically based on the values of the date in the main search? Thank you for your time and help.

 

Labels (4)
0 Karma

thambisetty
SplunkTrust
SplunkTrust

you can't do much if your date doesn't have time also. 

try looking in below thread.

https://community.splunk.com/t5/Splunk-Search/Splunk-Date-Time-comparison-using-time-generated-throu...

————————————
If this helps, give a like below.
0 Karma

tg_to
Loves-to-Learn

Sorry for the confusion. the _time field exists; the date in the table above is just for illustrative purposes. i extracted date with:

 

| eval date=strftime(_time, "%Y%m%d")

 

0 Karma
Get Updates on the Splunk Community!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...