<?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 Re: parameterize search from various source types simultaneously in a fixed time frame. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386946#M173071</link>
    <description>&lt;P&gt;That's what the community is here for! Have a good day as well.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Feb 2019 12:04:16 GMT</pubDate>
    <dc:creator>DMohn</dc:creator>
    <dc:date>2019-02-13T12:04:16Z</dc:date>
    <item>
      <title>parameterize search from various source types simultaneously in a fixed time frame.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386931#M173056</link>
      <description>&lt;P&gt;I have multiple sourcetypes in my index. Lets call them st1, st2, st3, st4 &amp;amp; st5.&lt;BR /&gt;
I have a query that end with  | table user _time  &amp;lt;&amp;lt; This is from st1&lt;/P&gt;

&lt;P&gt;What I am trying to do is, &lt;BR /&gt;
Fetch the "_time" field and "user" filed (from the above query) and using them as a search parameter to look for associated events in all remaining sourcetypes (i.e. st2,st3,st4,st5). &lt;BR /&gt;
which means all the events in other sourcetypes should contain that &lt;STRONG&gt;user&lt;/STRONG&gt; name OR &lt;STRONG&gt;should have the same time stamp&lt;/STRONG&gt; OR in a five min time duration before and after that event .&lt;/P&gt;

&lt;P&gt;The goal here is to figure out what was happening in the system (Across all the source types) during a certain time frame. and able to visualize it at one place like a dashboard.&lt;/P&gt;

&lt;P&gt;I think of may be using subseach or localize.....But I am confused....how to begin.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 08:03:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386931#M173056</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2019-02-13T08:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: parameterize search from various source types simultaneously in a fixed time frame.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386932#M173057</link>
      <description>&lt;P&gt;Subsearch is a good starting point here. You can start with your first query as the subsearch, returning &lt;CODE&gt;user&lt;/CODE&gt; and the time range in which you want to search. According to your requirements, the 10-minute-timeframe before and after the event should cover the exact time stamp as well, so I assume a &lt;CODE&gt;earliest&lt;/CODE&gt; and &lt;CODE&gt;latest&lt;/CODE&gt; search might be sufficient.&lt;/P&gt;

&lt;P&gt;Please start with this and see if it helps:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your_search_for_st2,st3,st4,st5&amp;gt; [|search &amp;lt;your_search_returning_user_and_time&amp;gt; | eval earliest=relative_time(_time,"-5m") | eval latest=relative_time(_time,"+5m") | return earliest latest user]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;EDIT:&lt;BR /&gt;
Refined the search as per comment below&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 08:35:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386932#M173057</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-02-13T08:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: parameterize search from various source types simultaneously in a fixed time frame.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386933#M173058</link>
      <description>&lt;P&gt;Thank you.&lt;BR /&gt;
When I test this. I  should see events in a 5 min time range. But I see way past events.&lt;BR /&gt;
The search result should contain all the events before and after 5 min of the time fetched from this ([|search  )   query....&lt;/P&gt;

&lt;P&gt;The search event outputs from all the sourcetypes should also match the fetched username.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 09:32:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386933#M173058</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2019-02-13T09:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: parameterize search from various source types simultaneously in a fixed time frame.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386934#M173059</link>
      <description>&lt;P&gt;So the constraint is time AND username? Can you please confirm this? Because in that case the search string might be much easier...&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 09:39:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386934#M173059</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-02-13T09:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: parameterize search from various source types simultaneously in a fixed time frame.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386935#M173060</link>
      <description>&lt;P&gt;yes, the constrain it time and the username.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 09:42:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386935#M173060</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2019-02-13T09:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: parameterize search from various source types simultaneously in a fixed time frame.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386936#M173061</link>
      <description>&lt;P&gt;Okay, that changes some requirements. I have updated the query above, please see if this works for you!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 09:54:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386936#M173061</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-02-13T09:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: parameterize search from various source types simultaneously in a fixed time frame.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386937#M173062</link>
      <description>&lt;P&gt;Here is the final query I am using&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=baysian host=the_viral_host* [| search sourcetype="baysian:greece" host=the_viral_host* 
    | eval bla bla bla 
    | eval bla bla bla
    | table host user  _time serv_time | sort - serv_time | head 1 | eval earliest=relative_time(_time,"-5m") | eval latest=relative_time(_time,"+5m") | return earliest latest user]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But this gives me no result !!! &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 10:28:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386937#M173062</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2019-02-13T10:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: parameterize search from various source types simultaneously in a fixed time frame.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386938#M173063</link>
      <description>&lt;P&gt;Could you please just run the subsearch part and see what the return value is (so everything after &lt;EM&gt;[|search&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 10:47:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386938#M173063</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-02-13T10:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: parameterize search from various source types simultaneously in a fixed time frame.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386939#M173064</link>
      <description>&lt;P&gt;yes. subsearch part gives me result.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 10:50:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386939#M173064</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2019-02-13T10:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: parameterize search from various source types simultaneously in a fixed time frame.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386940#M173065</link>
      <description>&lt;P&gt;How does the result look like? It should be a table with a &lt;EM&gt;search&lt;/EM&gt; column containing something like &lt;CODE&gt;earliest="1234567890.00000" latest="1234567890.0000" user="someusername"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;What if you add this string manually to your base search, does that show any results?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 10:56:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386940#M173065</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-02-13T10:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: parameterize search from various source types simultaneously in a fixed time frame.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386941#M173066</link>
      <description>&lt;P&gt;Yes. subsearch result looks exactly like you have given.&lt;BR /&gt;
And I was trying to feed this result value directly into the main query it doesn't work. (except when I add user name only)&lt;/P&gt;

&lt;P&gt;I think we might have missed $ , like return $ user]&lt;BR /&gt;
And when add that it works....&lt;BR /&gt;
But making return $earliest $latest $username]   doesn't work.&lt;BR /&gt;
Because in the main query it takes the returned time (1234567890.0000)  as a search criteria...instead of considering that value as a 'time range' ...&lt;/P&gt;

&lt;P&gt;The main query becomes like&lt;BR /&gt;&lt;BR /&gt;
index=baysian host=the_viral_host*  1234567890.00000 1234567890.0000 someusername &lt;/P&gt;

&lt;P&gt;And there is no such keyword in  my logs such as 1234567890.00000 AND 1234567890.0000 . hence the output is null. If we can only make the earliest and latest to be considered by the main query as a time range instead of a search keyword, that might help.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:16:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386941#M173066</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T23:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: parameterize search from various source types simultaneously in a fixed time frame.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386942#M173067</link>
      <description>&lt;P&gt;@DMohn &lt;BR /&gt;
How about if we use the earliest and latest  command in the main query by the returned latest and earliest values from the subquery ? That way the search results will be limited to the time range we want. &lt;BR /&gt;
Is it even possible to return and catch multiple values in subsearches like that?&lt;BR /&gt;
Any suggestion !!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 11:43:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386942#M173067</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2019-02-13T11:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: parameterize search from various source types simultaneously in a fixed time frame.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386943#M173068</link>
      <description>&lt;P&gt;You are on the right way ... If you make it a &lt;CODE&gt;return $fieldname&lt;/CODE&gt; it just returns the value of that field, a &lt;CODE&gt;return fieldname&lt;/CODE&gt; returns fieldname=value. &lt;/P&gt;

&lt;P&gt;Knowing that, I assume the field &lt;CODE&gt;user&lt;/CODE&gt; in your main query does not exist, or is not extracted as such, because if you have a free-text search (what you have when you do a &lt;CODE&gt;return $user&lt;/CODE&gt;) you get results.&lt;/P&gt;

&lt;P&gt;So, either check if your field &lt;CODE&gt;user&lt;/CODE&gt; in the main query is extracted correctly (and named correctly), rename the return field (eg &lt;CODE&gt;return user=username&lt;/CODE&gt;) or make it a full text search ( &lt;CODE&gt;return $user&lt;/CODE&gt; )&lt;/P&gt;

&lt;P&gt;Either way, leave the &lt;EM&gt;earliest&lt;/EM&gt; and &lt;EM&gt;latest&lt;/EM&gt; as stated, so you will have the time range interpreted correctly. So, going for &lt;CODE&gt;return earliest latest $user&lt;/CODE&gt; might be a good start!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 11:48:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386943#M173068</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-02-13T11:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: parameterize search from various source types simultaneously in a fixed time frame.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386944#M173069</link>
      <description>&lt;P&gt;Yes, that might be a good way to go for it! Anyway, check my last comment, and try using the last mentioned return statement. You can basically return as many fields as you want from the subsearch, as long as the fieldnames are correct. You can even return multiple results, which might not be necessary in your case anyway.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 11:53:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386944#M173069</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-02-13T11:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: parameterize search from various source types simultaneously in a fixed time frame.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386945#M173070</link>
      <description>&lt;P&gt;@DMohn  I appreciate you so patiently sticking to the issue and helping me out. The solution now works. Thank you &amp;amp; have a good rest of the day.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 11:59:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386945#M173070</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2019-02-13T11:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: parameterize search from various source types simultaneously in a fixed time frame.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386946#M173071</link>
      <description>&lt;P&gt;That's what the community is here for! Have a good day as well.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 12:04:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parameterize-search-from-various-source-types-simultaneously-in/m-p/386946#M173071</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-02-13T12:04:16Z</dc:date>
    </item>
  </channel>
</rss>

