<?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: Alternatives to &amp;quot;join&amp;quot; with two matching event fields. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-quot-join-quot-with-two-matching-event-fields/m-p/173750#M49863</link>
    <description>&lt;P&gt;Can you please share final version of your query? Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jan 2017 05:19:00 GMT</pubDate>
    <dc:creator>roopendra</dc:creator>
    <dc:date>2017-01-10T05:19:00Z</dc:date>
    <item>
      <title>Alternatives to "join" with two matching event fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-quot-join-quot-with-two-matching-event-fields/m-p/173744#M49857</link>
      <description>&lt;P&gt;I'm trying to search through one sourcetype called "Windows_System".&lt;/P&gt;

&lt;P&gt;There's also a specific field I'm interested in first called "EventCode"&lt;/P&gt;

&lt;P&gt;If I do a search only for for sourcetype="Windows_System" EventCode=1, I get the results I want. &lt;/P&gt;

&lt;P&gt;There's an executable that I want to be present in the fields when I search for EventCode 2 called "executable.exe"&lt;/P&gt;

&lt;P&gt;If I do a search only for sourcetype="Windows_System" EventCode=2 process="executable.exe", I get the results I want. &lt;/P&gt;

&lt;P&gt;However, there are fields that show up when EventCode=1 is specified for that aren't present when EventCode=2 is. I want to chart out all the fields I want if both EventCode values are specified. &lt;/P&gt;

&lt;P&gt;The good thing is that there's a common field with a unique value between both searches called "GUID" so I can focus on that. &lt;/P&gt;

&lt;P&gt;Here's the query so far&lt;/P&gt;

&lt;P&gt;sourcetype="Windows_System" EventCode=2  Image="executable.exe"&lt;BR /&gt;
| join GUID type=outer [search sourcetype="Windows_System" EventCode=1]&lt;BR /&gt;
| rename SourceHostname as hostname_ip, SourceIp as source_ip, SourcePort as source_port, DestinationHostname as destination_hostname, DestinationIp as destination_ip, DestinationPort as destination_port&lt;BR /&gt;
| table User, hostname_ip, source_ip, source_port, destination_hostname, destination_ip, destination_port, Protocol, GUID, process, CommandLine, ParentImage, ParentCommandLine&lt;/P&gt;

&lt;P&gt;CommandLine, ParentImage, ParentCommandLine are fields that are present ONLY when you specify EventCode1 that aren't when you specify EventCode2. The data in those fields are not showing up when run my main. &lt;/P&gt;

&lt;P&gt;I have two questions. &lt;/P&gt;

&lt;P&gt;Is the "join" command really necessary or can I accomplish this with a less intensive search like with stats or chart?&lt;/P&gt;

&lt;P&gt;Is this search the correct syntax to get the results I want?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:08:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-quot-join-quot-with-two-matching-event-fields/m-p/173744#M49857</guid>
      <dc:creator>sknot1454</dc:creator>
      <dc:date>2020-09-28T19:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: Alternatives to "join" with two matching event fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-quot-join-quot-with-two-matching-event-fields/m-p/173745#M49858</link>
      <description>&lt;P&gt;Joins are expensive and your requirement can easily be done using a stats. Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="Windows_System" (EventCode=2 Image="executable.exe") OR (EventCode=1)
| stats values(process) as process, values(SourceHostname) as hostname_ip, values(SourceIp) as source_ip, values(SourcePort) as source_port, values(DestinationHostname) as destination_hostname, values(DestinationIp) as destination_ip, values(DestinationPort) as destination_port values(CommandLine) as CommandLine, values(ParentImage) as ParentImage, values(ParentCommandLine) as ParentCommandLine by User, Protocol, GUID
| table User, hostname_ip, source_ip, source_port, destination_hostname, destination_ip, destination_port, Protocol, GUID, process, CommandLine, ParentImage, ParentCommandLine
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;UPDATED SEARCH&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="Windows_System" (EventCode=2 Image="executable.exe") OR (EventCode=1)
| eval CommandLine=coalesce(CommandLine,null()) | eval ParentImage=coalesce(ParentImage,null()) | eval ParentCommandLine=coalesce(ParentCommandLine
 ,null())   | stats values(process) as process, values(SourceHostname) as hostname_ip, values(SourceIp) as source_ip, values(SourcePort) as source_port, values(DestinationHostname) as destination_hostname, values(DestinationIp) as destination_ip, values(DestinationPort) as destination_port values(CommandLine) as CommandLine, values(ParentImage) as ParentImage, values(ParentCommandLine) as ParentCommandLine by User, Protocol, GUID
    | table User, hostname_ip, source_ip, source_port, destination_hostname, destination_ip, destination_port, Protocol, GUID, process, CommandLine, ParentImage, ParentCommandLine
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Mar 2015 17:34:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-quot-join-quot-with-two-matching-event-fields/m-p/173745#M49858</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-03-10T17:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: Alternatives to "join" with two matching event fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-quot-join-quot-with-two-matching-event-fields/m-p/173746#M49859</link>
      <description>&lt;P&gt;You're definitely right. The stats helped speed up the query. &lt;/P&gt;

&lt;P&gt;Unfortunately the CommandLine, ParentImage, ParentCommandLine field values are still blank in the results table. &lt;/P&gt;

&lt;P&gt;All of the fields tabled out are common between EventCode1 and EventCode2 except for the three I listed above. &lt;/P&gt;

&lt;P&gt;Any idea why they aren't being included?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2015 17:48:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-quot-join-quot-with-two-matching-event-fields/m-p/173746#M49859</guid>
      <dc:creator>sknot1454</dc:creator>
      <dc:date>2015-03-10T17:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Alternatives to "join" with two matching event fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-quot-join-quot-with-two-matching-event-fields/m-p/173747#M49860</link>
      <description>&lt;P&gt;See if updated answer works for you.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2015 18:17:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-quot-join-quot-with-two-matching-event-fields/m-p/173747#M49860</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-03-10T18:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Alternatives to "join" with two matching event fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-quot-join-quot-with-two-matching-event-fields/m-p/173748#M49861</link>
      <description>&lt;P&gt;Still not working. &lt;/P&gt;

&lt;P&gt;I tabled out the _raw field and it seems only raw data the from EventCode 3 is in the field. There's nothing from EventCode 1.&lt;/P&gt;

&lt;P&gt;It seems they aren't joining together which makes sense that I can't see those three fields in my table. &lt;/P&gt;

&lt;P&gt;The data is in XML format. Would this be a problem?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2015 18:35:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-quot-join-quot-with-two-matching-event-fields/m-p/173748#M49861</guid>
      <dc:creator>sknot1454</dc:creator>
      <dc:date>2015-03-10T18:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Alternatives to "join" with two matching event fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-quot-join-quot-with-two-matching-event-fields/m-p/173749#M49862</link>
      <description>&lt;P&gt;I know this was a while ago, but I ended up using "Eval GUID=coalesce(GUID,GUID)" and sorting by "GUID" when I tabled out the fields.&lt;/P&gt;

&lt;P&gt;Since I know when EventCode=1 is specified, there would always be data in the field CommandLine, and I knew there would always be data for the field "DestinationIp" when EventCode=3 was specified, I just used "CommandLine!="" and DestinationIP="" to filter out null fields.&lt;/P&gt;

&lt;P&gt;Works 100000x faster than a join. Queries that would take hours to run with join now take less than 10 minutes&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2016 20:18:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-quot-join-quot-with-two-matching-event-fields/m-p/173749#M49862</guid>
      <dc:creator>sknot1454</dc:creator>
      <dc:date>2016-08-23T20:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: Alternatives to "join" with two matching event fields.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-quot-join-quot-with-two-matching-event-fields/m-p/173750#M49863</link>
      <description>&lt;P&gt;Can you please share final version of your query? Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 05:19:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Alternatives-to-quot-join-quot-with-two-matching-event-fields/m-p/173750#M49863</guid>
      <dc:creator>roopendra</dc:creator>
      <dc:date>2017-01-10T05:19:00Z</dc:date>
    </item>
  </channel>
</rss>

