<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic If I want to use a field from the main search as a search criteria for a sub-search, what code should I write? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/If-I-want-to-use-a-field-from-the-main-search-as-a-search/m-p/590964#M205742</link>
    <description>&lt;P&gt;If I want to use a field(alarm_time) from the main search as a search criteria for a sub-search, what code should I write?&lt;BR /&gt;In the following code, I want to search for the time they are working&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I want to search Conditions : work_start &amp;lt; alarm_time &amp;lt; work_end&amp;nbsp;&lt;BR /&gt;search results you want to get : (work_name=work_b)&lt;BR /&gt;____________________________________&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| makeresults
|eval _raw="alarm_time,host,message
2022/03/26 18:05,test_node,test_down"
| multikv forceheader=1
| eval alarm_time_strp = strptime(alarm_time,"%Y/%m/%d %H:%M")
| join type=left host
[| makeresults
|eval _raw="host,work_start,work_end,work_name
test_node,2022/03/26 17:00,2022/03/26 18:00,work_a
test_node,22022/03/26 18:00,2022/03/26 19:00,work_b
test_node,2022/03/26 19:00,2022/03/26 20:00,work_c"
| multikv forceheader=1
| eval work_start_strp = strptime(work_start,"%Y/%m/%d %H:%M")
| eval work_end_strp = strptime(work_end,"%Y/%m/%d %H:%M")
]&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 28 Mar 2022 15:44:48 GMT</pubDate>
    <dc:creator>hasegawaarte</dc:creator>
    <dc:date>2022-03-28T15:44:48Z</dc:date>
    <item>
      <title>If I want to use a field from the main search as a search criteria for a sub-search, what code should I write?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-I-want-to-use-a-field-from-the-main-search-as-a-search/m-p/590964#M205742</link>
      <description>&lt;P&gt;If I want to use a field(alarm_time) from the main search as a search criteria for a sub-search, what code should I write?&lt;BR /&gt;In the following code, I want to search for the time they are working&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I want to search Conditions : work_start &amp;lt; alarm_time &amp;lt; work_end&amp;nbsp;&lt;BR /&gt;search results you want to get : (work_name=work_b)&lt;BR /&gt;____________________________________&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| makeresults
|eval _raw="alarm_time,host,message
2022/03/26 18:05,test_node,test_down"
| multikv forceheader=1
| eval alarm_time_strp = strptime(alarm_time,"%Y/%m/%d %H:%M")
| join type=left host
[| makeresults
|eval _raw="host,work_start,work_end,work_name
test_node,2022/03/26 17:00,2022/03/26 18:00,work_a
test_node,22022/03/26 18:00,2022/03/26 19:00,work_b
test_node,2022/03/26 19:00,2022/03/26 20:00,work_c"
| multikv forceheader=1
| eval work_start_strp = strptime(work_start,"%Y/%m/%d %H:%M")
| eval work_end_strp = strptime(work_end,"%Y/%m/%d %H:%M")
]&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 28 Mar 2022 15:44:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-I-want-to-use-a-field-from-the-main-search-as-a-search/m-p/590964#M205742</guid>
      <dc:creator>hasegawaarte</dc:creator>
      <dc:date>2022-03-28T15:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: If I want to use a field from the main search as a search criteria for a sub-search, what code should I write?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/If-I-want-to-use-a-field-from-the-main-search-as-a-search/m-p/590965#M205743</link>
      <description>&lt;P&gt;In general case, you don't "pass parameters" to a subsearch. It's the other way around - the subsearch is evaluated first, its results are rendered to a condition or set of conditions which gets appended to the main search.&lt;/P&gt;&lt;P&gt;You can use the map command to launch a subsearch with parameters coming from the main search but it's for a very very rare cases.&lt;/P&gt;&lt;P&gt;As a rule of thumb you should avoid subsearches whenever you can - they have their limitations and can fail silently and fail you in a very nasty way.&lt;/P&gt;&lt;P&gt;Huge part of searches you'd initially try to write with subsearches (and joins) can be rewritten as stats.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 10:34:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/If-I-want-to-use-a-field-from-the-main-search-as-a-search/m-p/590965#M205743</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-03-26T10:34:58Z</dc:date>
    </item>
  </channel>
</rss>

