<?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: merge 2 logs into one with at most one value for each field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/merge-2-logs-into-one-with-at-most-one-value-for-each-field/m-p/391496#M190787</link>
    <description>&lt;P&gt;@shayhibah how have you indexed the two logs? Are they having same/different metadata like index, sourcetype, source? Best approach would be to write you search to pull all required data from index. Then you can apply correlation afterwards (as per your example does not seem like there is any correlation between the two logs).&lt;/P&gt;

&lt;P&gt;Please provide more information for the community to assist you better. What is your current SPL? How are you correlating log 1 data with log 2? Will name field serve as the key to correlate and find unique events in each log? How many fields can these logs have?&lt;/P&gt;

&lt;P&gt;Based on your explanation so far, you can try something like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=blah sourcetype IN ("sourcetypeForLog1","sourceTypeForLog2") source="path\log*"
| fields name a,b,c,d,
| stats min(_time) as _time last(*) as * by name
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 22 Jul 2019 14:00:29 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2019-07-22T14:00:29Z</dc:date>
    <item>
      <title>merge 2 logs into one with at most one value for each field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/merge-2-logs-into-one-with-at-most-one-value-for-each-field/m-p/391493#M190784</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I would like to combine 2 logs (or more) as the following:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;log #1:&lt;/STRONG&gt;&lt;BR /&gt;
time=1563281015|name=sh_lab|a=1|b=2|c=3|&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;log#2:&lt;/STRONG&gt;&lt;BR /&gt;
time=1563281010|a=2|d=4|&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Output should be:&lt;/STRONG&gt;&lt;BR /&gt;
time=1563281015|name=sh_lab|a=1|b=2|c=3|d=4|&lt;/P&gt;

&lt;P&gt;(time is taken from the first log since it is the latest log,d is taken from the second log since it does not part of the latest log, all other fields are taken from the first log since it is the latest log).&lt;/P&gt;

&lt;P&gt;Is it possible to do it in Splunk?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 07:39:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/merge-2-logs-into-one-with-at-most-one-value-for-each-field/m-p/391493#M190784</guid>
      <dc:creator>shayhibah</dc:creator>
      <dc:date>2019-07-18T07:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: merge 2 logs into one with at most one value for each field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/merge-2-logs-into-one-with-at-most-one-value-for-each-field/m-p/391494#M190785</link>
      <description>&lt;P&gt;any idea??&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 12:34:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/merge-2-logs-into-one-with-at-most-one-value-for-each-field/m-p/391494#M190785</guid>
      <dc:creator>shayhibah</dc:creator>
      <dc:date>2019-07-22T12:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: merge 2 logs into one with at most one value for each field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/merge-2-logs-into-one-with-at-most-one-value-for-each-field/m-p/391495#M190786</link>
      <description>&lt;P&gt;@shayhibah :&lt;/P&gt;

&lt;P&gt;Appendcols might give you what you desire. below is something i tried with your data set.&lt;/P&gt;

&lt;P&gt;| makeresults | eval time=1563281015, name="sh_lab", a=1, b=2, c=3&lt;BR /&gt;
| appendcols  [makeresults | eval time=1563281010,a=2,d=4 | table d]&lt;/P&gt;

&lt;P&gt;Kindly know that there is a high possibility you might not get correct results.&lt;BR /&gt;&lt;BR /&gt;
Because it will correlate the first event of log one with the 1st event of log two, and so on.&lt;BR /&gt;&lt;BR /&gt;
It will not care about the time and fields of the events or when events came.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 13:38:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/merge-2-logs-into-one-with-at-most-one-value-for-each-field/m-p/391495#M190786</guid>
      <dc:creator>chinmoya</dc:creator>
      <dc:date>2019-07-22T13:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: merge 2 logs into one with at most one value for each field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/merge-2-logs-into-one-with-at-most-one-value-for-each-field/m-p/391496#M190787</link>
      <description>&lt;P&gt;@shayhibah how have you indexed the two logs? Are they having same/different metadata like index, sourcetype, source? Best approach would be to write you search to pull all required data from index. Then you can apply correlation afterwards (as per your example does not seem like there is any correlation between the two logs).&lt;/P&gt;

&lt;P&gt;Please provide more information for the community to assist you better. What is your current SPL? How are you correlating log 1 data with log 2? Will name field serve as the key to correlate and find unique events in each log? How many fields can these logs have?&lt;/P&gt;

&lt;P&gt;Based on your explanation so far, you can try something like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=blah sourcetype IN ("sourcetypeForLog1","sourceTypeForLog2") source="path\log*"
| fields name a,b,c,d,
| stats min(_time) as _time last(*) as * by name
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Jul 2019 14:00:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/merge-2-logs-into-one-with-at-most-one-value-for-each-field/m-p/391496#M190787</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-07-22T14:00:29Z</dc:date>
    </item>
  </channel>
</rss>

