<?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 How to write a search to correlate an eventcode from index1 with errors that show up in index2? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-write-a-search-to-correlate-an-eventcode-from-index1-with/m-p/130091#M26762</link>
    <description>&lt;P&gt;So I have a problem and I can't seem to crack it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index1 host=server* EventCode=1234 |localize maxpause=1m| map search="search index=index2 host=server* errortext starttimeu=$starttime$ endtimeu=$endtime$" | stats count(host) by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm trying to correlate the eventcode 1234 in index1 with errors that show up in index2 &lt;/P&gt;

&lt;P&gt;I need help capturing the "host names" which are the same in both indexes so I can correlate exactly. The problem is that index2 throws this particular error text, but it's generally not a problem unless it occurs around eventcode 1234&lt;/P&gt;

&lt;P&gt;I tried a join:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index 1 host=server* EventCode=1234| stats values(host) by _time | join host [search index=index2 host=server* errortext
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this doesn't work out because it doesn't have any sort of time context of the eventcode vs the error&lt;/P&gt;

&lt;P&gt;I tried this as well, but was unable to get it to work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index2 host=server* errortext [search index=ssapevent host=server* EventCode=1234| rename _time AS earliest | eval earliest=latest + 60| fields earliest, latest]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 08 Apr 2015 00:11:51 GMT</pubDate>
    <dc:creator>icur2ys4ye</dc:creator>
    <dc:date>2015-04-08T00:11:51Z</dc:date>
    <item>
      <title>How to write a search to correlate an eventcode from index1 with errors that show up in index2?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-write-a-search-to-correlate-an-eventcode-from-index1-with/m-p/130091#M26762</link>
      <description>&lt;P&gt;So I have a problem and I can't seem to crack it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index1 host=server* EventCode=1234 |localize maxpause=1m| map search="search index=index2 host=server* errortext starttimeu=$starttime$ endtimeu=$endtime$" | stats count(host) by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm trying to correlate the eventcode 1234 in index1 with errors that show up in index2 &lt;/P&gt;

&lt;P&gt;I need help capturing the "host names" which are the same in both indexes so I can correlate exactly. The problem is that index2 throws this particular error text, but it's generally not a problem unless it occurs around eventcode 1234&lt;/P&gt;

&lt;P&gt;I tried a join:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index 1 host=server* EventCode=1234| stats values(host) by _time | join host [search index=index2 host=server* errortext
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this doesn't work out because it doesn't have any sort of time context of the eventcode vs the error&lt;/P&gt;

&lt;P&gt;I tried this as well, but was unable to get it to work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index2 host=server* errortext [search index=ssapevent host=server* EventCode=1234| rename _time AS earliest | eval earliest=latest + 60| fields earliest, latest]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Apr 2015 00:11:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-write-a-search-to-correlate-an-eventcode-from-index1-with/m-p/130091#M26762</guid>
      <dc:creator>icur2ys4ye</dc:creator>
      <dc:date>2015-04-08T00:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to correlate an eventcode from index1 with errors that show up in index2?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-write-a-search-to-correlate-an-eventcode-from-index1-with/m-p/130092#M26763</link>
      <description>&lt;P&gt;Hello!&lt;BR /&gt;
&lt;STRONG&gt;First&lt;/STRONG&gt; a question. How do you use your &lt;CODE&gt;starttimeu=$starttime$ endtimeu=$endtime$&lt;/CODE&gt;?&lt;BR /&gt;
I think, for it to work, you must have something like this bellow, with &lt;STRONG&gt;starttime&lt;/STRONG&gt; and &lt;STRONG&gt;endtime&lt;/STRONG&gt; as fields in your &lt;STRONG&gt;index1&lt;/STRONG&gt; events:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index1 host=server* EventCode=1234 starttime=...  endtime=....| map search="search index=index2 host=server* errortext starttimeu=$starttime$ endtimeu=$endtime$" | stats count(host) by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And, &lt;STRONG&gt;starttimeu&lt;/STRONG&gt; and  &lt;STRONG&gt;endtimeu&lt;/STRONG&gt; must be fields int your &lt;STRONG&gt;index2&lt;/STRONG&gt; events, and must respectively have same values with &lt;STRONG&gt;starttime&lt;/STRONG&gt; and &lt;STRONG&gt;endtime&lt;/STRONG&gt;. If that is not the case, remove that &lt;CODE&gt;starttimeu=$starttime$ endtimeu=$endtime$&lt;/CODE&gt; in your code.&lt;/P&gt;

&lt;P&gt;Ok.  To capture the &lt;STRONG&gt;host names&lt;/STRONG&gt;, that is what you can do.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index1 host=server* EventCode=1234 | map search="search index=index2 host=$host$ errortext" | stats count(host) by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;here is one example with the &lt;STRONG&gt;_internal&lt;/STRONG&gt; and &lt;STRONG&gt;_audit&lt;/STRONG&gt; indexes.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype=* user=*|map search="search index=_audit user=$user$" error|stats count(user) by user
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Apr 2015 04:55:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-write-a-search-to-correlate-an-eventcode-from-index1-with/m-p/130092#M26763</guid>
      <dc:creator>stephanefotso</dc:creator>
      <dc:date>2015-04-08T04:55:42Z</dc:date>
    </item>
  </channel>
</rss>

