<?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 can I display the 10 event entries prior to and post a specified keyword search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-display-the-10-event-entries-prior-to-and-post-a/m-p/643232#M222819</link>
    <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| streamstats count(eval(error=="java")) as java
| streamstats reset_on_change=t count as post_java by java
| eval post_java=if(post_java==0,null(),post_java)
| reverse
| streamstats count(eval(error=="java")) as java
| streamstats reset_on_change=t count as pre_java by java
| eval pre_java=if(pre_java==0,null(),pre_java)
| where pre_java &amp;lt;= 10 OR post_java &amp;lt;= 10
| reverse&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 12 May 2023 15:09:56 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2023-05-12T15:09:56Z</dc:date>
    <item>
      <title>How can I display the 10 event entries prior to and post a specified keyword search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-display-the-10-event-entries-prior-to-and-post-a/m-p/643227#M222817</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;In the logs file, we are capturing java error is multiple entries, so in order for me to see the entire error set, I need to see the events/records (10 used here as an example) that are immediately prior-to and post the keyword that is being search.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently, when I use the below SPL, I get only the events that contain the word "java" which is good, but I want to see the 10 records (i.e. log entry lines) prior to this "java" record and 10 entries post this "java" record".&amp;nbsp; The records prior-to and post may not have any keyword "java" in them, but I still want to see those records as part of the result set being displayed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;| from datamodel:"xyz"&lt;BR /&gt;| fields host source _time&lt;BR /&gt;| where like(_raw,"%java%")&lt;BR /&gt;| table host source _raw&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to display the 10 records/events prior-to and post the keyword being searched from the _raw field?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 12:55:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-display-the-10-event-entries-prior-to-and-post-a/m-p/643227#M222817</guid>
      <dc:creator>Steve_A200</dc:creator>
      <dc:date>2023-05-15T12:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: How can I display the 10 event entries prior to and post a specified keyword search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-display-the-10-event-entries-prior-to-and-post-a/m-p/643232#M222819</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| streamstats count(eval(error=="java")) as java
| streamstats reset_on_change=t count as post_java by java
| eval post_java=if(post_java==0,null(),post_java)
| reverse
| streamstats count(eval(error=="java")) as java
| streamstats reset_on_change=t count as pre_java by java
| eval pre_java=if(pre_java==0,null(),pre_java)
| where pre_java &amp;lt;= 10 OR post_java &amp;lt;= 10
| reverse&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 12 May 2023 15:09:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-display-the-10-event-entries-prior-to-and-post-a/m-p/643232#M222819</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-05-12T15:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: How can I display the 10 event entries prior to and post a specified keyword search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-display-the-10-event-entries-prior-to-and-post-a/m-p/643234#M222820</link>
      <description>&lt;P&gt;Hi ITWhisperer,&lt;/P&gt;&lt;P&gt;Unfortunately, that didn't do the trick.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2 issues:&lt;/P&gt;&lt;P&gt;- it did not list events that contained the keyword being search i.e. like "java"&lt;/P&gt;&lt;P&gt;- it listed a total of 20 events, I was hoping to list every event that contains the word "java" +/- 10 record, rather than just a single event +/- 10 events.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 15:35:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-display-the-10-event-entries-prior-to-and-post-a/m-p/643234#M222820</guid>
      <dc:creator>Steve_A200</dc:creator>
      <dc:date>2023-05-12T15:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: How can I display the 10 event entries prior to and post a specified keyword search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-display-the-10-event-entries-prior-to-and-post-a/m-p/643238#M222821</link>
      <description>&lt;P&gt;Obviously, the key is getting the eval correct - you could try searchmatch&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| streamstats count(eval(searchmatch("java"))) as java
| eval java=if(java==0,null(),java)
| streamstats reset_on_change=t count as post_java by java
| reverse
| streamstats count(eval(searchmatch("java"))) as java
| eval java=if(java==0,null(),java)
| streamstats reset_on_change=t count as pre_java by java
| where pre_java &amp;lt;= 10 OR post_java &amp;lt;= 10
| reverse&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 12 May 2023 16:29:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-display-the-10-event-entries-prior-to-and-post-a/m-p/643238#M222821</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-05-12T16:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I display the 10 event entries prior to and post a specified keyword search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-display-the-10-event-entries-prior-to-and-post-a/m-p/643239#M222822</link>
      <description>&lt;P&gt;Thank you ITWhisperer, that indeed did the trick.&amp;nbsp; I sandwiched your search between the fields and table&amp;nbsp; commands.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 16:38:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-display-the-10-event-entries-prior-to-and-post-a/m-p/643239#M222822</guid>
      <dc:creator>Steve_A200</dc:creator>
      <dc:date>2023-05-12T16:38:17Z</dc:date>
    </item>
  </channel>
</rss>

