<?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: How to get the result of next event by searching for a key word in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-result-of-next-event-by-searching-for-a-key-word/m-p/672440#M230329</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/41046"&gt;@t_splunk_d&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;let me understand: you have each row in a different event and you're sure that the event are in this sequence.&lt;/P&gt;&lt;P&gt;I suppose that you already extracted Process and Person_Name fields, in this case you could run something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your_search&amp;gt;
| transaction startswith="Start  Processing" maxevents=2
| table Process Person_Name &lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Dec 2023 17:45:22 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2023-12-20T17:45:22Z</dc:date>
    <item>
      <title>How to get the result of next event by searching for a key word</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-result-of-next-event-by-searching-for-a-key-word/m-p/672427#M230322</link>
      <description>&lt;P&gt;I want to get the result of the next line of the log message when I encounter&amp;nbsp; a key word.&lt;/P&gt;&lt;P&gt;Example log:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;----error in checking status--------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;----Person Name: abcd, Status=active---------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-----Check for Status------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;------success : true--------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-----Start&amp;nbsp; Processing XXX----------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;----Person Name: abcd, Status=active---------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-----Check for Status------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;------success : true--------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-----Start&amp;nbsp; Processing XXX----------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;----Person Name: abcd, address:yzgj---------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;-----Check for Person------&lt;/P&gt;&lt;P&gt;------success : true--------&lt;/P&gt;&lt;P&gt;-----Start&amp;nbsp; Processing XXX----------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the above log I want to&amp;nbsp; capture the person name&amp;nbsp; after the&amp;nbsp; "Check for Person". The log is indexed by _time.&amp;nbsp; I want to display the following result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;_time&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Process&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Person Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;XXX&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;abcd&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I don't want to use map or transactions as those are expensive as there are lot of events.&lt;/P&gt;&lt;P&gt;Thank you for the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2023 21:11:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-result-of-next-event-by-searching-for-a-key-word/m-p/672427#M230322</guid>
      <dc:creator>t_splunk_d</dc:creator>
      <dc:date>2023-12-22T21:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the result of next event by searching for a key word</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-result-of-next-event-by-searching-for-a-key-word/m-p/672440#M230329</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/41046"&gt;@t_splunk_d&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;let me understand: you have each row in a different event and you're sure that the event are in this sequence.&lt;/P&gt;&lt;P&gt;I suppose that you already extracted Process and Person_Name fields, in this case you could run something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your_search&amp;gt;
| transaction startswith="Start  Processing" maxevents=2
| table Process Person_Name &lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Dec 2023 17:45:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-result-of-next-event-by-searching-for-a-key-word/m-p/672440#M230329</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-12-20T17:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the result of next event by searching for a key word</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-result-of-next-event-by-searching-for-a-key-word/m-p/672444#M230331</link>
      <description>&lt;P&gt;You may be able to use streamstats assuming that there is some degree off distribution of _time between each event.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base_search&amp;gt;
    | rex field=_raw "Processing\s+(?&amp;lt;process&amp;gt;[^\-]+)\-"
    | rex field=_raw "Person\s+Name\:\s+(?&amp;lt;person_name&amp;gt;[^\,]+)\,"
    | sort 0 +_time
    | streamstats reset_before="("isnotnull(process)")"
        values(process) as current_process
    | streamstats window=2
        first(_raw) as previous_log
    | eval
        checked_person_name=if(
            match(previous_log, "\-Check\s+for\s+Person\-"),
                'person_name',
                null()
            )  
    | stats
        min(_time) as _time
            by current_process, checked_person_name
    | fields + _time, current_process, checked_person_name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;The final output should look something like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1703095211553.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28609i379895932E76DDD8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1703095211553.png" alt="dtburrows3_0-1703095211553.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;The table before the final stats aggregation looked like this and show more context around what the streamstats are doing here.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_1-1703095279517.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28610i435391B957602F6F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_1-1703095279517.png" alt="dtburrows3_1-1703095279517.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Note: For this method to work properly _timestamps of each process event shouldn't be exactly the same, there would need to be some sort of step up in time to the next event (event if it is milliseconds). This is because we need the events in the correct sequence for the streamstats to work as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Dec 2023 18:04:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-result-of-next-event-by-searching-for-a-key-word/m-p/672444#M230331</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2023-12-20T18:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the result of next event by searching for a key word</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-result-of-next-event-by-searching-for-a-key-word/m-p/672635#M230356</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/263242"&gt;@dtburrows3&lt;/a&gt;&amp;nbsp; We are so close. Actually I did not mention about the error. The logs looks like this:&lt;BR /&gt;&lt;SPAN&gt;----error in checking status--------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;----Person Name: abcd, Status=active---------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-----Check for Status------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;------success : true--------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-----Start&amp;nbsp; Processing XXX----------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;So I want to get the Person name for only&amp;nbsp; "&lt;SPAN&gt;error in checking status"&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2023 21:13:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-result-of-next-event-by-searching-for-a-key-word/m-p/672635#M230356</guid>
      <dc:creator>t_splunk_d</dc:creator>
      <dc:date>2023-12-22T21:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the result of next event by searching for a key word</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-result-of-next-event-by-searching-for-a-key-word/m-p/672636#M230357</link>
      <description>&lt;P&gt;I think the addition of a few evals can account for the error line as well.&lt;BR /&gt;&lt;BR /&gt;Maybe something like this?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base_search&amp;gt;
    | rex field=_raw "Processing\s+(?&amp;lt;process&amp;gt;[^\-]+)\-"
    | rex field=_raw "Person\s+Name\:\s+(?&amp;lt;person_name&amp;gt;[^\,]+)\,"
    | sort 0 +_time
    | streamstats reset_before="("isnotnull(process)")"
        values(process) as current_process
    | streamstats window=2
        first(_raw) as previous_log
    | rex field=previous_log "Person\s+Name\:\s+(?&amp;lt;previous_log_person_name&amp;gt;[^\,]+)\,"
    | eval
        checked_person_name=if(
            match(previous_log, "\-Check\s+for\s+Person\-"),
                'person_name',
                null()
            ),
        status_error_person=if(
            match(previous_log, "Person\s+Name:\s+") AND match(_raw, "\-error\s+in\s+checking\s+status"),
                'previous_log_person_name',
                null()
            )
            
 
    | stats
        min(_time) as _time
            by current_process, status_error_person
    | fields + _time, current_process, status_error_person&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 22 Dec 2023 22:11:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-result-of-next-event-by-searching-for-a-key-word/m-p/672636#M230357</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2023-12-22T22:11:02Z</dc:date>
    </item>
  </channel>
</rss>

