<?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 correlate events from two sourcetypes where the correlation field from SourcetypeA is multivalued and SourcetypeB is a single value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181064#M52194</link>
    <description>&lt;P&gt;Ok, that helps me visualize it much better.  I realized what happened - someone created a single alias for this field on both sensors, and that seems to be what was causing the unusual results.  Now if I do the query &lt;CODE&gt;index=A OR index=B OR index=C sourcetype=A or sourcetype=B | eval hashes=coalesce(fieldA,fieldB) | transaction hashes maxspan=* | ...&lt;/CODE&gt; I get the correct result.&lt;/P&gt;

&lt;P&gt;Thanks for the help!&lt;/P&gt;</description>
    <pubDate>Fri, 20 Mar 2015 18:20:26 GMT</pubDate>
    <dc:creator>IngloriousSplun</dc:creator>
    <dc:date>2015-03-20T18:20:26Z</dc:date>
    <item>
      <title>How to correlate events from two sourcetypes where the correlation field from SourcetypeA is multivalued and SourcetypeB is a single value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181055#M52185</link>
      <description>&lt;P&gt;I have two different network sensors - Sensor A and Sensor B.  Each has their own event format that I aggregate in Splunk.  I'm trying to correlate events between the two sensor platforms and only produce a result if both sensors saw the same event.  &lt;/P&gt;

&lt;P&gt;The complication I'm having is that Sensor A will sometimes send a multi-value field containing multiple values for the specific field I'm interested in correlating on, whereas Sensor B will always only send a single value.  For example, if I'm correlating on file hash Sensor A may send two different file hashes separated by what seems to be just a space in a single md5sum hash field.  Sensor B, however, will always send just one file hash per event in that field.&lt;/P&gt;

&lt;P&gt;What is the best way to correlate these events?  I've thought about deduping the field for Sensor A first, then running it through transaction, but I'm concerned I'm not doing this properly and preserving the other event data that I want to display with it.  Another option I found was to not use transaction and use &lt;CODE&gt;stats&lt;/CODE&gt;instead.  I've tried both methods below and fail to receive a result, even though I've found events that should correlate manually.  Any thoughts on the most accurate way to accomplish this?  I want to be able to list the hash, event id for both sensors, timestamps for both sensors, etc for each correlated event.&lt;/P&gt;

&lt;P&gt;Using &lt;CODE&gt;transaction&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A OR index=B OR index=C sourcetype=SensorA OR sourcetype=SensorB | mvexpand sensorAFieldA | dedup sensorAFieldA | singleField=coalesce(sensorAFieldA, sensorBFieldB) | transaction singleField maxspan=1h | eval match=if(match(sensorAFieldA,sensorBFieldB),"1","0") | where match &amp;gt; 0 | table sensorAFieldA, sensorBFieldB, sensorAID, sensorBID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Using &lt;CODE&gt;stats&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A OR index=B OR index=C sourcetype=sensorA OR sourcetype=sensorB | stats values(sensorAFieldA) AS fieldA , values(sensorBFieldB) AS fieldB | mvexpand fieldA | eval matching=if(match(fieldA,fieldB),"1","0") | where matching &amp;gt; 0 | table fieldA, fieldB
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2015 22:00:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181055#M52185</guid>
      <dc:creator>IngloriousSplun</dc:creator>
      <dc:date>2015-03-19T22:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to correlate events from two sourcetypes where the correlation field from SourcetypeA is multivalued and SourcetypeB is a single value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181056#M52186</link>
      <description>&lt;P&gt;The crucial question is "what's the meaning of that MV field in A?".&lt;/P&gt;

&lt;P&gt;Does exactly one of its values correlate with the single value in B? If so, which value?&lt;BR /&gt;
Could any value correlate with B?&lt;BR /&gt;
Should all values correlate with B? If so, how to merge the values in A?&lt;/P&gt;

&lt;P&gt;These should be answered before trying to express the answers in SPL.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2015 22:31:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181056#M52186</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-03-19T22:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to correlate events from two sourcetypes where the correlation field from SourcetypeA is multivalued and SourcetypeB is a single value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181057#M52187</link>
      <description>&lt;P&gt;Any value in A could correlate to B&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2015 01:58:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181057#M52187</guid>
      <dc:creator>IngloriousSplun</dc:creator>
      <dc:date>2015-03-20T01:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to correlate events from two sourcetypes where the correlation field from SourcetypeA is multivalued and SourcetypeB is a single value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181058#M52188</link>
      <description>&lt;P&gt;Maybe it's not this simple, but how about just coalescing to a common field name, then asking stats to count distinct sourcetypes for each value and restricting to the rows that have 2 sourcetypes?  Stats can work across a mix of single-value and multivalue rows so I don't think you need the mvexpand necessarily.  It would look like this:  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A OR index=B OR index=C sourcetype=sensorA OR sourcetype=sensorB | eval normalized=coalesce(sensorAFieldA,sensorBFieldB) | stats count dc(sourcetype) as sourcetypes by normalized | search sourcetypes&amp;gt;1 | rename normalized as file_hash
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the maxspan=1h is interesting,  so to incorporate that sort of logic you could do this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A OR index=B OR index=C sourcetype=sensorA OR sourcetype=sensorB | eval normalized=coalesce(sensorAFieldA,sensorBFieldB) | stats values(_time) as timestamps max(_time) as latest min(_time) as earliest count dc(sourcetype) as sourcetypes by normalized | eval delta=latest-earliest | search sourcetypes&amp;gt;1 delta&amp;lt;3600 | rename normalized as file_hash
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Although technically if the sensorA values kept flagging a particular file for longer than an hour, and then sensor B only flagged it once, this search would filter that out incorrectly. In which case maybe transaction is the better way to go. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A OR index=B OR index=C sourcetype=sensorA OR sourcetype=sensorB | eval file_hash=coalesce(sensorAFieldA,sensorBFieldB) | transaction file_hash maxspan=1h | search sourcetype=sensorA sourcetype=sensorB
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Mar 2015 04:35:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181058#M52188</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2015-03-20T04:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to correlate events from two sourcetypes where the correlation field from SourcetypeA is multivalued and SourcetypeB is a single value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181059#M52189</link>
      <description>&lt;P&gt;If any element of your MV field can match then you can just let &lt;CODE&gt;transaction&lt;/CODE&gt; do its thing:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | eval field = "v1,v2 v2,v3 v3" | makemv field | mvexpand field | makemv delim="," field
| streamstats count | eval _time = now() 
| transaction field
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The first two lines set up three events. The first has &lt;CODE&gt;field=[v1, v2]&lt;/CODE&gt;, the second &lt;CODE&gt;[v2,v3]&lt;/CODE&gt;, the third &lt;CODE&gt;v3&lt;/CODE&gt; only. &lt;CODE&gt;transaction&lt;/CODE&gt; merges them all together.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2015 14:00:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181059#M52189</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-03-20T14:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to correlate events from two sourcetypes where the correlation field from SourcetypeA is multivalued and SourcetypeB is a single value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181060#M52190</link>
      <description>&lt;P&gt;Can you expand on your answer, specifically &lt;CODE&gt;eval field="v1,v2 v2,v3 v3"&lt;/CODE&gt;?  I'm not sure what I should be putting between the quotes, is that the fields?  &lt;/P&gt;

&lt;P&gt;From SensorA I have a field, file_hash, and from SensorB I have a field, File_Hash.  SensorA field file_hash is a MV field, and can contain more than one hash at times.  SensorB's File_Hash field only ever contains one hash.  Are you saying I should make my query: &lt;CODE&gt;| stats count | eval field="file_hash,File_Hash" | makemv field ...&lt;/CODE&gt;?&lt;/P&gt;

&lt;P&gt;I should have two results from the data set I'm using, I've confirmed it manually.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:16:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181060#M52190</guid>
      <dc:creator>IngloriousSplun</dc:creator>
      <dc:date>2020-09-28T19:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to correlate events from two sourcetypes where the correlation field from SourcetypeA is multivalued and SourcetypeB is a single value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181061#M52191</link>
      <description>&lt;P&gt;I tried this search: &lt;CODE&gt;index=A OR index=B OR index=C sourcetype=sensorA OR sourcetype=sensorB | eval file_hash=coalesce(sensorAFieldA,sensorBFieldB) | transaction file_hash maxspan=1h | search sourcetype=sensorA sourcetype=sensorB&lt;/CODE&gt;, which is similar to one I was trying previously, but I still get no results.  I know I should have at least 2 results in the data set I'm using as I confirmed manually.  &lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2015 17:47:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181061#M52191</guid>
      <dc:creator>IngloriousSplun</dc:creator>
      <dc:date>2015-03-20T17:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to correlate events from two sourcetypes where the correlation field from SourcetypeA is multivalued and SourcetypeB is a single value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181062#M52192</link>
      <description>&lt;P&gt;Everything until before the &lt;CODE&gt;| transaction&lt;/CODE&gt; just sets up some dummy data looking like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;count  field  _time
1      v1     2015-03-20 18:48:29   
       v2
2      v2     2015-03-20 18:48:29   
       v3
3      v3     2015-03-20 18:48:29
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Using this dummy data for &lt;CODE&gt;| transaction field&lt;/CODE&gt; shows that Splunk will merge them all into one event, honouring the multivalue &lt;CODE&gt;field&lt;/CODE&gt;. This &lt;EM&gt;should&lt;/EM&gt; translate to your problem.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2015 17:49:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181062#M52192</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2015-03-20T17:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to correlate events from two sourcetypes where the correlation field from SourcetypeA is multivalued and SourcetypeB is a single value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181063#M52193</link>
      <description>&lt;P&gt;And for the file hash that you manually confirmed, the value present in sourcetype A and the value presentin sourcetype B are within 1 hour of eachother? &lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2015 18:16:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181063#M52193</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2015-03-20T18:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to correlate events from two sourcetypes where the correlation field from SourcetypeA is multivalued and SourcetypeB is a single value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181064#M52194</link>
      <description>&lt;P&gt;Ok, that helps me visualize it much better.  I realized what happened - someone created a single alias for this field on both sensors, and that seems to be what was causing the unusual results.  Now if I do the query &lt;CODE&gt;index=A OR index=B OR index=C sourcetype=A or sourcetype=B | eval hashes=coalesce(fieldA,fieldB) | transaction hashes maxspan=* | ...&lt;/CODE&gt; I get the correct result.&lt;/P&gt;

&lt;P&gt;Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2015 18:20:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181064#M52194</guid>
      <dc:creator>IngloriousSplun</dc:creator>
      <dc:date>2015-03-20T18:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to correlate events from two sourcetypes where the correlation field from SourcetypeA is multivalued and SourcetypeB is a single value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181065#M52195</link>
      <description>&lt;P&gt;I realized what happened - someone created a single alias for this field on both sensors, and that seems to be what was causing the unusual results.  Now if I do the query &lt;CODE&gt;index=A OR index=B OR index=C sourcetype=A or sourcetype=B | eval hashes=coalesce(fieldA,fieldB) | transaction hashes maxspan=* | ...&lt;/CODE&gt; I get the correct result.&lt;/P&gt;

&lt;P&gt;Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2015 18:20:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-correlate-events-from-two-sourcetypes-where-the/m-p/181065#M52195</guid>
      <dc:creator>IngloriousSplun</dc:creator>
      <dc:date>2015-03-20T18:20:50Z</dc:date>
    </item>
  </channel>
</rss>

