<?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: Find event in one search, get related events by time in another search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Find-an-error-in-1st-system-and-then-find-errors-close-in-time/m-p/691673#M235500</link>
    <description>&lt;P&gt;Perhaps a better title would be: "Find an error in one system and then find errors close in time in a 2nd system".&amp;nbsp; In my case, both search strings include the word 'Error' and the values are text to indicate what the errors are about.&lt;/P&gt;&lt;P&gt;Two Searches:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=first_index sourcetype=first_source error 500
     | rex field=_raw "string(?&amp;lt;REF_VAL&amp;gt;\d+)"
     | table _time REF_VAL&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output:&lt;BR /&gt;_time&amp;nbsp; &amp;nbsp; REF_VAL&lt;BR /&gt;&lt;SPAN&gt;2024-06-2024 10:48:04.003&amp;nbsp; &amp;nbsp;Avalue&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=second_index soucetype=second_souce error somestring
| rex field=_raw "ERROR - (?&amp;lt;ERR_MTHD&amp;gt;\S+)"
| table _time ERR_MTHD&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output:&lt;BR /&gt;_time&amp;nbsp; &amp;nbsp; ERR_MTHD&lt;BR /&gt;2024-06-24 10:48:51.174&amp;nbsp; Method1text&lt;BR /&gt;2024-06-24 10:48:51:158&amp;nbsp; Method2text&lt;/P&gt;&lt;P&gt;Output that I would like:&amp;nbsp;&lt;BR /&gt;EVENT_TIME&amp;nbsp; &amp;nbsp; &amp;nbsp; REFERENCE_VAL&amp;nbsp; &amp;nbsp; &amp;nbsp; RELATED_TIME&amp;nbsp; &amp;nbsp; &amp;nbsp; RELATED_VAL&lt;BR /&gt;2024-06-2024 10:48:04.003&amp;nbsp; &amp;nbsp;Avalue&amp;nbsp;2024-06-24 10:48:51.174&amp;nbsp; Method1text&lt;BR /&gt;2024-06-2024 10:48:04.003&amp;nbsp; &amp;nbsp;Avalue&amp;nbsp;2024-06-24 10:48:51:158&amp;nbsp; Method2text&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jun 2024 13:19:08 GMT</pubDate>
    <dc:creator>GEB</dc:creator>
    <dc:date>2024-06-27T13:19:08Z</dc:date>
    <item>
      <title>Find an error in 1st system and then find errors close in time in a 2nd system</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-an-error-in-1st-system-and-then-find-errors-close-in-time/m-p/691478#M235450</link>
      <description>&lt;P&gt;"Find event in one search, get related events by time in another search"&lt;BR /&gt;Found some related questions but could not formulate a working solution from them....&amp;nbsp; Of course this doesn't work, but maybe it will make clear what is wanted, values in 2nd search events within milliseconds (2000 shown) of first search's event....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=someIndex searchString
| rex field=_raw "stuff(?&amp;lt;REFERENCE_VAL&amp;gt;)$"
| stats _time as EVENT_TIME
| append (search index=anIndex someSearchString
                    | rex field=_raw "stuff(?&amp;lt;RELATED_VAL&amp;gt;)$"
                    | eval timeBand=_time-EVENT_TIME | where abs(timeBand)&amp;lt;2000
                    | stats _time as RELATED_TIME)
| table EVENT_TIME REFERENCE_VAL RELATED_TIME RELATED_VAL&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 12:51:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-an-error-in-1st-system-and-then-find-errors-close-in-time/m-p/691478#M235450</guid>
      <dc:creator>GEB</dc:creator>
      <dc:date>2024-06-27T12:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: Find event in one search, get related events by time in another search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-an-error-in-1st-system-and-then-find-errors-close-in-time/m-p/691484#M235451</link>
      <description>&lt;P&gt;First question - is the output a single row or are there multiple rows expected, in which case, what is the entity that separates the rows - is it REFERENCE_VAL and if so, how does one correlate&amp;nbsp;REFERENCE_VAL to RELATED_VAL?&lt;/P&gt;&lt;P&gt;This is the ONE row solution&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=someIndex searchString OR someSearchString
| rex field=_raw "stuff(?&amp;lt;REFERENCE_VAL&amp;gt;)$" 
| rex field=_raw "stuff(?&amp;lt;RELATED_VAL&amp;gt;)$" 
| stats min(eval(if(isnotnull(REFERENCE_VAL), _time, null()))) as EVENT_TIME min(eval(if(isnotnull(RELATED_VAL), _time, null()))) as RELATED_TIME
| eval timeBand=RELATED_TIME-EVENT_TIME 
| where abs(timeBand)&amp;lt;2000 &lt;/LI-CODE&gt;&lt;P&gt;which will only give a result if the time range is less than 2 seconds, but I suspect you are expecting more than one row...&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 23:26:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-an-error-in-1st-system-and-then-find-errors-close-in-time/m-p/691484#M235451</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-06-24T23:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: Find event in one search, get related events by time in another search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-an-error-in-1st-system-and-then-find-errors-close-in-time/m-p/691512#M235458</link>
      <description>&lt;P&gt;I think you are looking for &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Map" target="_blank" rel="noopener"&gt;map&lt;/A&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=someIndex searchString
| rex field=_raw "stuff(?&amp;lt;REFERENCE_VAL&amp;gt;somestuff)$"
| rename _time as EVENT_TIME
| eval start = EVENT_TIME - 1, end = EVENT_TIME + 1
| map maxsearches=1000 search="index=anIndex someSearchString earliest=$start$ latest=$end$
    | rex field=_raw "stuff(?&amp;lt;RELATED_VAL&amp;gt;otherstuff)$"
    | rename _time as RELATED_TIME
    | fields RELATED_*"
| table EVENT_TIME REFERENCE_VAL RELATED_TIME RELATED_VAL&lt;/LI-CODE&gt;&lt;P&gt;Caveats:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;When there are many events in main search, it can be very, very expensive.&lt;/LI&gt;&lt;LI&gt;You need to give a number to maxsearches; it cannot be 0. (See documentation for more limitations.)&lt;/LI&gt;&lt;LI&gt;If you are using [-1000ms, + 1000ms], chances are strong that all these start-end pairs will overlap badly, rendering your question itself rather meaningless. &amp;nbsp;You can develop algorithms to merge these overlaps to make map command more efficient (by reducing intervals). &amp;nbsp;But you need to ask yourself (or your boss) seriously: Is this a well-posed question?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 06:17:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-an-error-in-1st-system-and-then-find-errors-close-in-time/m-p/691512#M235458</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-06-25T06:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: Find event in one search, get related events by time in another search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-an-error-in-1st-system-and-then-find-errors-close-in-time/m-p/691558#M235466</link>
      <description>&lt;P&gt;Based on the data, I expect 2-4 rows per single REFERENCE_VAL.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 12:30:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-an-error-in-1st-system-and-then-find-errors-close-in-time/m-p/691558#M235466</guid>
      <dc:creator>GEB</dc:creator>
      <dc:date>2024-06-25T12:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Find event in one search, get related events by time in another search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-an-error-in-1st-system-and-then-find-errors-close-in-time/m-p/691575#M235470</link>
      <description>&lt;P&gt;Thanks for the response -&amp;nbsp; I expect about 5 results for each reference result -&amp;gt; so I set maxsearches=5.&amp;nbsp; However, nothing I have tried produces any results.&amp;nbsp; Boss?&amp;nbsp; You mean team SME?&amp;nbsp; Don't actually have one of those, we are in a help yourself environment.&lt;BR /&gt;Everything I've done with the above query results an a msg that says "unable to run query",&amp;nbsp; specifying the query after the map.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 13:23:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-an-error-in-1st-system-and-then-find-errors-close-in-time/m-p/691575#M235470</guid>
      <dc:creator>GEB</dc:creator>
      <dc:date>2024-06-27T13:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: Find event in one search, get related events by time in another search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-an-error-in-1st-system-and-then-find-errors-close-in-time/m-p/691621#M235485</link>
      <description>&lt;P&gt;So how are you expecting to correlate the 2 data sets? How do you find events with RELATED_VAL that are related to the row containing REFERENCE_VAL&lt;/P&gt;&lt;P&gt;i.e. if the data is&lt;/P&gt;&lt;P&gt;reference_val_1&lt;BR /&gt;related_val_1&lt;BR /&gt;reference_val_2&lt;BR /&gt;related_val_2&lt;BR /&gt;related_val_3&lt;BR /&gt;reference_val_3&lt;BR /&gt;related_val_4&lt;/P&gt;&lt;P&gt;how do you expect to correlate related_val_3 with any of the 3 reference vals is it simply time proximity and if so, can you have interleaved reference_vals that may be in the same time window?&lt;/P&gt;&lt;P&gt;Can you give an example of data - otherwise the requirements are too vague&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 01:20:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-an-error-in-1st-system-and-then-find-errors-close-in-time/m-p/691621#M235485</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-06-26T01:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Find event in one search, get related events by time in another search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Find-an-error-in-1st-system-and-then-find-errors-close-in-time/m-p/691673#M235500</link>
      <description>&lt;P&gt;Perhaps a better title would be: "Find an error in one system and then find errors close in time in a 2nd system".&amp;nbsp; In my case, both search strings include the word 'Error' and the values are text to indicate what the errors are about.&lt;/P&gt;&lt;P&gt;Two Searches:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=first_index sourcetype=first_source error 500
     | rex field=_raw "string(?&amp;lt;REF_VAL&amp;gt;\d+)"
     | table _time REF_VAL&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output:&lt;BR /&gt;_time&amp;nbsp; &amp;nbsp; REF_VAL&lt;BR /&gt;&lt;SPAN&gt;2024-06-2024 10:48:04.003&amp;nbsp; &amp;nbsp;Avalue&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=second_index soucetype=second_souce error somestring
| rex field=_raw "ERROR - (?&amp;lt;ERR_MTHD&amp;gt;\S+)"
| table _time ERR_MTHD&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output:&lt;BR /&gt;_time&amp;nbsp; &amp;nbsp; ERR_MTHD&lt;BR /&gt;2024-06-24 10:48:51.174&amp;nbsp; Method1text&lt;BR /&gt;2024-06-24 10:48:51:158&amp;nbsp; Method2text&lt;/P&gt;&lt;P&gt;Output that I would like:&amp;nbsp;&lt;BR /&gt;EVENT_TIME&amp;nbsp; &amp;nbsp; &amp;nbsp; REFERENCE_VAL&amp;nbsp; &amp;nbsp; &amp;nbsp; RELATED_TIME&amp;nbsp; &amp;nbsp; &amp;nbsp; RELATED_VAL&lt;BR /&gt;2024-06-2024 10:48:04.003&amp;nbsp; &amp;nbsp;Avalue&amp;nbsp;2024-06-24 10:48:51.174&amp;nbsp; Method1text&lt;BR /&gt;2024-06-2024 10:48:04.003&amp;nbsp; &amp;nbsp;Avalue&amp;nbsp;2024-06-24 10:48:51:158&amp;nbsp; Method2text&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 13:19:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Find-an-error-in-1st-system-and-then-find-errors-close-in-time/m-p/691673#M235500</guid>
      <dc:creator>GEB</dc:creator>
      <dc:date>2024-06-27T13:19:08Z</dc:date>
    </item>
  </channel>
</rss>

