<?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: What is the best way to correlate events (from same source type) that share a common field value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221918#M65240</link>
    <description>&lt;P&gt;Have you looked into using the transaction command? This should get the job done, though it may be slow (especially in a large environment.) Documentation &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Transaction"&gt;here&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.. | transaction UID
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 08 Jan 2016 20:30:37 GMT</pubDate>
    <dc:creator>jluo_splunk</dc:creator>
    <dc:date>2016-01-08T20:30:37Z</dc:date>
    <item>
      <title>What is the best way to correlate events (from same source type) that share a common field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221917#M65239</link>
      <description>&lt;P&gt;I am new to splunk so I don't know all the syntax or the most efficient way to construct searches.&lt;/P&gt;

&lt;P&gt;My goal is to correlate multiple email events and create a report containing the event fields: Subject, Sender, Recipient, Status (delivered or not delivered).&lt;/P&gt;

&lt;P&gt;The problem is that each email event does not contain all the fields I need. &lt;BR /&gt;
Subject is in a different event.&lt;BR /&gt;
Sender is in a different event.&lt;BR /&gt;
Recipient is in a different event.&lt;BR /&gt;
Status is in a different event.&lt;BR /&gt;
However, all the events associated with a specific email contain a unique ID (UID), so I can correlate based on the UID.&lt;BR /&gt;
For example, if I search for an email with a subject = "blah", I can find the UIDs and then search the UIDs.&lt;/P&gt;

&lt;P&gt;Primary Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=email  sourcetype=xemail  subject="blah" | table Subject UID

blah 1234
blah 2353
blah 3454
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Secondary Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=email  sourcetype=xemail  UID=1234 | table UID Subject Sender Recipient Status

1234   blah
1234          sender@domain.com
1234                             recipient@domain.com
1234                                                     delivered
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(Note: if above displayed in a table format, the Subject, Sender, Recipient, and Status fields would be in different columns, not stacked)&lt;/P&gt;

&lt;P&gt;As you can imagine manual searching is tedious and time-consuming.  So there must be a way to work smarter by using sub search and some function to retrieve all the UIDs from the initial search (where subject = blah) and then correlate all events based on the UIDs.  &lt;/P&gt;

&lt;P&gt;Please advise if it is even possible to correlate all events based on the initial subject search.&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 20:01:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221917#M65239</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2016-01-08T20:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to correlate events (from same source type) that share a common field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221918#M65240</link>
      <description>&lt;P&gt;Have you looked into using the transaction command? This should get the job done, though it may be slow (especially in a large environment.) Documentation &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Transaction"&gt;here&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.. | transaction UID
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jan 2016 20:30:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221918#M65240</guid>
      <dc:creator>jluo_splunk</dc:creator>
      <dc:date>2016-01-08T20:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to correlate events (from same source type) that share a common field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221919#M65241</link>
      <description>&lt;P&gt;See if this gives you what your are looking for&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=email sourcetype=xemail | stats list(subject) as sub list(sender) as sender list(recipient) as recp list(status) as status by UID
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jan 2016 20:31:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221919#M65241</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-01-08T20:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to correlate events (from same source type) that share a common field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221920#M65242</link>
      <description>&lt;P&gt;Thank you for the comment.&lt;/P&gt;

&lt;P&gt;Yes, | transaction UID  is a good option to collect all the unique id field values, however the next step is to automate the correlation of all the other events with the same UID.&lt;/P&gt;

&lt;P&gt;For instance, for each UID found with search &amp;gt; index=email  sourcetype=xemail  subject="blah"  another search has to be done on each UID to get the other fields: Sender, Recipient, and Delivery Status  because as I mentioned before, each field  is in a separate event.   In other words, the email appliance logs create separate events for the subject, sender, recipient, and delivery status separately.  The unique ID what you can use to group them together as a complete picture.&lt;/P&gt;

&lt;P&gt;So the next search step is the big question.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 22:28:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221920#M65242</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2016-01-08T22:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to correlate events (from same source type) that share a common field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221921#M65243</link>
      <description>&lt;P&gt;Thank you for the comment.&lt;/P&gt;

&lt;P&gt;Unfortunately, this will not display the other fields.  Only the subjects with UIDs are listed.    &lt;/P&gt;

&lt;P&gt;Perhaps I did not explain clearly, because this is a somewhat complicated search.&lt;/P&gt;

&lt;P&gt;Imagine you search for an email with subject = Hello in the last 15 minutes.&lt;BR /&gt;
Lets say you get 10 emails with subject = Hello.&lt;BR /&gt;&lt;BR /&gt;
In order to find the sender, recipient, and delivery status another search is required.&lt;BR /&gt;&lt;BR /&gt;
The sender, recipient, and delivery status may all be different.&lt;BR /&gt;
From the first search you can see there are 10 different unique ids displayed per row.&lt;BR /&gt;
Now a second search of each unique id is required to get the other fields, sender, recipient, and delivery status.&lt;/P&gt;

&lt;P&gt;For example one incoming email "session" creates multiple events.   Not all fields are in each event, but the UID relates them as part of the same session.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;unique ID   subject sender  recipient   delivery status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;1   1234    Hello&lt;BR /&gt;&lt;BR /&gt;
2   1234        &lt;A href="mailto:sender@domain.com"&gt;sender@domain.com&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;
3   1234            &lt;A href="mailto:recipient@domain.com"&gt;recipient@domain.com&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;
4   1234                delivered&lt;/P&gt;

&lt;P&gt;So this is where I am stuck.   How do you take the first results "many" and perform a secondary search on each of the "many" to get the other events to display in one report?&lt;/P&gt;

&lt;P&gt;I appreciate everyone's efforts on this.&lt;/P&gt;

&lt;P&gt;Tack&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 22:51:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221921#M65243</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2016-01-08T22:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to correlate events (from same source type) that share a common field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221922#M65244</link>
      <description>&lt;P&gt;It may help to see your actual events you need to correlate, but even without that I haven't seen a reason why transaction won't work.  My suspicion is you have the transaction command inserted AFTER the filtering, so it can't do the correlation.  I'm guessing the below from your existing search snippets, but perhaps try this instead...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=email  sourcetype=xemail  | transaction UID 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If that lumps the events together with matching UIDs, then try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=email  sourcetype=xemail  | transaction UID | table UID Subject Sender Recipient Status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The key is you don't want to limit your initial search - toss it ALL the events that you'll end up wanting all correlated together, then let Splunk do the correlation.  That transaction command will "group" all the events with matching UIDs together.  &lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 23:04:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221922#M65244</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-01-08T23:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to correlate events (from same source type) that share a common field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221923#M65245</link>
      <description>&lt;P&gt;This technique should also work.  If you need to search for the "Hello" ones, don't do that until afterwards.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=email sourcetype=xemail 
| stats list(subject) as sub list(sender) as sender list(recipient) as recp list(status) as status by UID 
| search subject="Hello"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If one of these solves your problem, please remember to "accept" it!  IF both do, well, pick the best.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;  If neither does, please post back with more info and we can help some more! &lt;/P&gt;

&lt;P&gt;(The key in this technique is also as I mention in the "transaction" answer by jluo - give Splunk ALL of the events to work with and group/stats/transaction them, THEN filter.)&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 23:08:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221923#M65245</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-01-08T23:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to correlate events (from same source type) that share a common field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221924#M65246</link>
      <description>&lt;P&gt;As below, filter it &lt;STRONG&gt;after&lt;/STRONG&gt; you get everything lumped together that needs to be lumped together.  Put your &lt;CODE&gt;| search subject="Hello"&lt;/CODE&gt; at the end of all the above (well, before the table).  Like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=email  sourcetype=xemail  
| transaction UID 
| search subject="Hello"
| table UID Subject Sender Recipient Status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let us know!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 23:23:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221924#M65246</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-01-08T23:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to correlate events (from same source type) that share a common field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221925#M65247</link>
      <description>&lt;P&gt;Thank you !!!   It works, I was going about it in the wrong order, and using the wrong method.  Lesson learned.  I owe you one cyber drink.  Thank you again.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 20:19:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221925#M65247</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2016-01-11T20:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to correlate events (from same source type) that share a common field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221926#M65248</link>
      <description>&lt;P&gt;Sounds like what you may need is a &lt;CODE&gt;subsearch&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1.2/SearchTutorial/Useasubsearch"&gt;http://docs.splunk.com/Documentation/Splunk/6.1.2/SearchTutorial/Useasubsearch&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;So in your example, the search would look something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search for other fields&amp;gt;  [ search for ids based on subject | fields UID] | transform ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 20:32:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221926#M65248</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-01-11T20:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to correlate events (from same source type) that share a common field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221927#M65249</link>
      <description>&lt;P&gt;For some reason this one does not work, even with the search as the last step.&lt;/P&gt;

&lt;P&gt;But as a newb,  I missed the ordering of the search (d'oh!*?!)   &lt;/P&gt;

&lt;P&gt;IF and when I discover why this one does not work, I will post the reason.   &lt;/P&gt;

&lt;P&gt;Thank you to all that helped with this.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 20:33:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221927#M65249</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2016-01-11T20:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to correlate events (from same source type) that share a common field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221928#M65250</link>
      <description>&lt;P&gt;I got it to work by changing [ | search subject ="Hello"  ]  to [ |search subj ="Hello"]&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 21:12:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/What-is-the-best-way-to-correlate-events-from-same-source-type/m-p/221928#M65250</guid>
      <dc:creator>packet_hunter</dc:creator>
      <dc:date>2016-01-11T21:12:20Z</dc:date>
    </item>
  </channel>
</rss>

