Splunk Search

How to pass _time from subsearch to mainsearch which contains lookup

Anusha_Sankar
New Member

Hi All,

I have a lookup table which contains fields like name , id,etc but not timestamp.
In the log file I will be having the _time value as well as an id.
I would like to identify the count of id in lookup as well as in the logs over time.
Please find below the query I have used to fetch the count.
inputlookup test1 | eventstats count as A
|search not
[subsearch] |event stats count as B

Please suggest how to pass _time to the main search

Tags (2)
0 Karma

Ayn
Legend

The problem here is that _time is considered to be an internal field, and as such won't get picked up by the format command that is implicitly run by the subsearch, so it will not be included in the subsearch output.

However using a little workaround we can get the output we want anyway, by creating a field called query which will contain the _time filtering string. query is a special field whose value is returned from the subsearch as-is rather than Splunk adding "query=" before it.

[search yoursubsearch | eval query="_time="._time | fields query]
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...