<?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: Is there an easy way to pair two events with the same sourcetype that have the same values in different fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-easy-way-to-pair-two-events-with-the-same-sourcetype/m-p/454293#M128544</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;

&lt;P&gt;I guess my question was to identify if there was in fact a better way than running the same search twice and joining them together. I was taught that 'join' should be avoided if at all possible. However, if it is the best solution I will keep it.&lt;/P&gt;

&lt;P&gt;Thanks for the help!&lt;/P&gt;</description>
    <pubDate>Tue, 11 Sep 2018 19:48:58 GMT</pubDate>
    <dc:creator>ssiat479</dc:creator>
    <dc:date>2018-09-11T19:48:58Z</dc:date>
    <item>
      <title>Is there an easy way to pair two events with the same sourcetype that have the same values in different fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-easy-way-to-pair-two-events-with-the-same-sourcetype/m-p/454289#M128540</link>
      <description>&lt;P&gt;I am looking for an elegant solution to the following problem:&lt;BR /&gt;
I want to summarize data from two different events which have the same sourcetype/index/etc, but which have identical values in two different fields.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Event A:
sourcetype= foo
ComputerName=homepc
FileName=example.exe
PID=3333
PPID=2222

Event B:
sourcetype=foo
ComputerName=homepc
FileName=parent.exe
PID=2222
PPID=1111
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to group data from both events into one summarized line like follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ComputerName......FileName...........PID.........ParentFileName.......PPID
homepc...................example.exe......3333.......parent.exe................2222
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have attempted to accomplish this via JOIN and it does seem to work, but I am aware this is not an ideal solution:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype=foo
| table ComputerName FileName PID PPID 
| rename FileName as Child_FileName, PID as Child_PID, PPID as Parent_PID
| join Parent_PID ComputerName
[ search index=_internal sourcetype=foo
| table ComputerName FileName  PID
| rename FileName as Parent_FileName, PID as Parent_PID ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If the sourcetypes in the two searches were different, I know I could easily accomplish this via a string of 'eval's and stats. Thanks for any suggestions!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 16:06:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-easy-way-to-pair-two-events-with-the-same-sourcetype/m-p/454289#M128540</guid>
      <dc:creator>ssiat479</dc:creator>
      <dc:date>2018-09-11T16:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an easy way to pair two events with the same sourcetype that have the same values in different fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-easy-way-to-pair-two-events-with-the-same-sourcetype/m-p/454290#M128541</link>
      <description>&lt;P&gt;@ssiat479&lt;/P&gt;

&lt;P&gt;Can you please try this? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal sourcetype=foo 
| fields ComputerName FileName PID 
| append  [ search index=_internal sourcetype=foo 
    | fields ComputerName FileName PID | eval PID=PPID | eval ParentFileName=FileName | fields - FileName ] | stats values(*) as * by ComputerName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Sep 2018 16:24:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-easy-way-to-pair-two-events-with-the-same-sourcetype/m-p/454290#M128541</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-09-11T16:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an easy way to pair two events with the same sourcetype that have the same values in different fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-easy-way-to-pair-two-events-with-the-same-sourcetype/m-p/454291#M128542</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;

&lt;P&gt;It does not seem to work as well as the above query which used JOIN.&lt;/P&gt;

&lt;P&gt;The results only include three columns: ComputerName, FileName, and PID. PPID is not included and since results are grouped by ComputerName only, there is no way to correlate a PID to PPID/ParentFileName.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 18:06:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-easy-way-to-pair-two-events-with-the-same-sourcetype/m-p/454291#M128542</guid>
      <dc:creator>ssiat479</dc:creator>
      <dc:date>2018-09-11T18:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an easy way to pair two events with the same sourcetype that have the same values in different fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-easy-way-to-pair-two-events-with-the-same-sourcetype/m-p/454292#M128543</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;What would you like to see improved in the SPL you posted? &lt;/P&gt;

&lt;P&gt;I wrote a solution that appears to work then realized that it's the same logic as your example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval sourcetype="foo",ComputerName = "homepc", FileName="example.exe",PID="3333",PPID="2222" 
| append 
    [| makeresults 
    | eval sourcetype="foo",ComputerName = "homepc", FileName="parent.exe",PID="2222",PPID="1111"] 
| join PPID 
    [| makeresults 
    | eval sourcetype="foo",ComputerName = "homepc", FileName="parent.exe",PID="2222",PPID="1111" 
    | rename PPID AS parent_PPID, FileName AS parent_FileName 
    | rename PID AS PPID 
    | fields parent_FileName,PPID,parent_PPID]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Sep 2018 18:39:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-easy-way-to-pair-two-events-with-the-same-sourcetype/m-p/454292#M128543</guid>
      <dc:creator>zonistj</dc:creator>
      <dc:date>2018-09-11T18:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an easy way to pair two events with the same sourcetype that have the same values in different fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-easy-way-to-pair-two-events-with-the-same-sourcetype/m-p/454293#M128544</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;

&lt;P&gt;I guess my question was to identify if there was in fact a better way than running the same search twice and joining them together. I was taught that 'join' should be avoided if at all possible. However, if it is the best solution I will keep it.&lt;/P&gt;

&lt;P&gt;Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 19:48:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-easy-way-to-pair-two-events-with-the-same-sourcetype/m-p/454293#M128544</guid>
      <dc:creator>ssiat479</dc:creator>
      <dc:date>2018-09-11T19:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an easy way to pair two events with the same sourcetype that have the same values in different fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-there-an-easy-way-to-pair-two-events-with-the-same-sourcetype/m-p/454294#M128545</link>
      <description>&lt;P&gt;Thanks for the clarification!&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;join&lt;/STRONG&gt; is the most efficient method that I know of  for joining the two data sets in a "real-time" manner.&lt;/P&gt;

&lt;P&gt;If you had a specific time period of data, you could use a lookup table and that would be more resource efficient. For example, if you were conducting a forensic investigation into a system and had a timeline of processes that ran with PID and PPID then you could run one query to create the lookup table and one query to get  your results.&lt;/P&gt;

&lt;P&gt;It would look like this:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;CREATE LOOKUP TABLE&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
 | eval sourcetype="foo",ComputerName = "homepc", FileName="example.exe",PID="3333",PPID="2222" 
 | append 
     [| makeresults 
     | eval sourcetype="foo",ComputerName = "homepc", FileName="parent.exe",PID="2222",PPID="1111"]
| append [| makeresults 
     | eval sourcetype="foo",ComputerName = "homepc", FileName="grandparent.exe",PID="1111",PPID="0"]
| stats values(FileName) AS FileName by PID
| outputlookup foo_bar_data.csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;SEARCH FOR DATA&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
 | eval sourcetype="foo",ComputerName = "homepc", FileName="example.exe",PID="3333",PPID="2222" 
 | append 
     [| makeresults 
     | eval sourcetype="foo",ComputerName = "homepc", FileName="parent.exe",PID="2222",PPID="1111"]
| append [| makeresults 
     | eval sourcetype="foo",ComputerName = "homepc", FileName="grandparent.exe",PID="1111",PPID="0"]
| lookup foo_bar_data.csv PID AS PPID OUTPUTNEW FileName AS Parent_FileName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This might be a better approach depending on your exact use case.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 20:06:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-there-an-easy-way-to-pair-two-events-with-the-same-sourcetype/m-p/454294#M128545</guid>
      <dc:creator>zonistj</dc:creator>
      <dc:date>2018-09-11T20:06:19Z</dc:date>
    </item>
  </channel>
</rss>

