<?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 Context Search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22476#M177415</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Is there any way to do a contextual search in Splunk?  For example, if I issue the command "grep -C 5 failed &lt;FILE&gt;" it will return lines in &lt;FILE&gt; which contain the keywork "failed" AND the last 5 lines before and 5 lines after.  I am not sure how to do this in Splunk.&lt;/FILE&gt;&lt;/FILE&gt;&lt;/P&gt;

&lt;P&gt;I am interested in searching for a message X which has message Y before it.  I know I could achieve a successful search by using the OR operator but one of the messages is very common and clutters the results.  So I would like to search for the much less common message X in a contextual fashion and manually inspect for message Y before it.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Fri, 03 Jun 2011 17:14:34 GMT</pubDate>
    <dc:creator>axsolis</dc:creator>
    <dc:date>2011-06-03T17:14:34Z</dc:date>
    <item>
      <title>Context Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22476#M177415</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Is there any way to do a contextual search in Splunk?  For example, if I issue the command "grep -C 5 failed &lt;FILE&gt;" it will return lines in &lt;FILE&gt; which contain the keywork "failed" AND the last 5 lines before and 5 lines after.  I am not sure how to do this in Splunk.&lt;/FILE&gt;&lt;/FILE&gt;&lt;/P&gt;

&lt;P&gt;I am interested in searching for a message X which has message Y before it.  I know I could achieve a successful search by using the OR operator but one of the messages is very common and clutters the results.  So I would like to search for the much less common message X in a contextual fashion and manually inspect for message Y before it.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2011 17:14:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22476#M177415</guid>
      <dc:creator>axsolis</dc:creator>
      <dc:date>2011-06-03T17:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: Context Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22477#M177416</link>
      <description>&lt;P&gt;One way that comes to mind would be to use the "transaction" parameter...this allows you to group events into a single transaction at search time...there are probably a few ways to use transaction in this manner:&lt;/P&gt;

&lt;P&gt;source=foo &lt;X_IDENTIFIER&gt; | transaction &lt;FIELD&gt; maxspan=&lt;TIME&gt;&lt;/TIME&gt;&lt;/FIELD&gt;&lt;/X_IDENTIFIER&gt;&lt;/P&gt;

&lt;P&gt;for X_identifier...I'd just be looking for something you'd only see in event X.&lt;/P&gt;

&lt;P&gt;for "field", you have to choose a field in splunk that will be common to both of these transactions...common ones might be host, clientip..etc.  maxspan isn't required, but I've found it useful.&lt;/P&gt;

&lt;P&gt;What this will do is filter for X event, then build a transaction around X that presumably includes Y as well.  Now, there may be better ways to do this, but this is one that I've used before for this purpose. &lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2011 23:05:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22477#M177416</guid>
      <dc:creator>cgilbert_splunk</dc:creator>
      <dc:date>2011-06-03T23:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: Context Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22478#M177417</link>
      <description>&lt;P&gt;Is Y expected to come directly before X, or could there be an hour or so in between?&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jun 2011 16:12:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22478#M177417</guid>
      <dc:creator>mw</dc:creator>
      <dc:date>2011-06-05T16:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: Context Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22479#M177418</link>
      <description>&lt;P&gt;Y is expected to come within 5 seconds of X.  Could be before or after....  Also, there are no fields that are common to the two messages.  That is why I am wanting to find messages withing a time window around X.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2011 15:33:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22479#M177418</guid>
      <dc:creator>axsolis</dc:creator>
      <dc:date>2011-06-06T15:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Context Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22480#M177419</link>
      <description>&lt;P&gt;Thanks for the reply and that is good info.  Unfortunately messages X and Y have no common fields.  I am looking for cases when Y is produced within 5 seconds or so of when X is produced.  This does not happen consistently but I have an interest to find out when it does.&lt;/P&gt;

&lt;P&gt;Gave point due to good informative answer.  Unfortunately does not solve my issue.  Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2011 15:37:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22480#M177419</guid>
      <dc:creator>axsolis</dc:creator>
      <dc:date>2011-06-06T15:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Context Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22481#M177420</link>
      <description>&lt;P&gt;You might try checking out this thread...I haven't had the chance to validate the searches, but there are a few things in here that seem to map to your use case:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://splunk-base.splunk.com/answers/2602/can-splunk-filtermatch-events-and-bring-back-neighbouring-events-like-gnu-grep"&gt;http://splunk-base.splunk.com/answers/2602/can-splunk-filtermatch-events-and-bring-back-neighbouring-events-like-gnu-grep&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2011 16:10:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22481#M177420</guid>
      <dc:creator>cgilbert_splunk</dc:creator>
      <dc:date>2011-06-06T16:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Context Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22482#M177421</link>
      <description>&lt;P&gt;I think this does it.  I was able to find the events I wanted anyway.  More playing around will need to be done but it got me what I wanted.  Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2011 19:14:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22482#M177421</guid>
      <dc:creator>axsolis</dc:creator>
      <dc:date>2011-06-06T19:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Context Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22483#M177422</link>
      <description>&lt;P&gt;How can I search for "Send failed" and result should display the 5 lines before the message found as well.&lt;/P&gt;

&lt;P&gt;I need to see what happens before the "Send failed" occurred.&lt;/P&gt;

&lt;P&gt;Any help on the search query would be helpful.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2012 01:19:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22483#M177422</guid>
      <dc:creator>TXBU</dc:creator>
      <dc:date>2012-02-18T01:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: Context Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22484#M177423</link>
      <description>&lt;P&gt;cgilbert_splunk's link should probably work for you too.  Something like this:&lt;/P&gt;

&lt;P&gt;sourcetype=whatever | transaction endswith="Send failed" maxevents=5&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2012 15:29:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Context-Search/m-p/22484#M177423</guid>
      <dc:creator>mw</dc:creator>
      <dc:date>2012-02-20T15:29:01Z</dc:date>
    </item>
  </channel>
</rss>

