<?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 do I get unique values of different types of events without duplicates? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-unique-values-of-different-types-of-events-without/m-p/424585#M121752</link>
    <description>&lt;P&gt;@renjith, No, value of 210491 does not have in tag in the type=First but  for id_second=210491 has the value in tag for type=Second. In this case tag should be considered as great since it's not present in the type=First.&lt;/P&gt;

&lt;P&gt;When the ran the query you provided, I'm not getting the values of tags but it's just displaying values as okay to all the events of tag.&lt;/P&gt;

&lt;P&gt;index=sai_core sourcetype=firstsecond_log &lt;BR /&gt;
| eval ID=coalesce(id_first,id_second) &lt;BR /&gt;
| stats values(eval(if(type="First",tag,null()))) as _tag1,values(eval(if(type="Second",tag,null()))) as _tag2 by ID&lt;BR /&gt;
| eval tag=if(_tag1!="", _tag1, _tag2)&lt;/P&gt;

&lt;P&gt;I do not understand where is the value "okay" is coming. There is no word "okay" exists in the event.&lt;BR /&gt;
How can I view the values of _tag1 and _tag2?&lt;/P&gt;

&lt;P&gt;ID  tag&lt;BR /&gt;
210468  okay&lt;BR /&gt;
210469  okay&lt;BR /&gt;
210470  okay&lt;BR /&gt;
210483  okay&lt;BR /&gt;
210487  okay&lt;BR /&gt;
210491  okay&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 22:18:36 GMT</pubDate>
    <dc:creator>bollam</dc:creator>
    <dc:date>2020-09-29T22:18:36Z</dc:date>
    <item>
      <title>How do I get unique values of different types of events without duplicates?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-unique-values-of-different-types-of-events-without/m-p/424583#M121750</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have got events with two different types: Type=First and type=Second&lt;/P&gt;

&lt;P&gt;I would like to get the consolidated(with unique tags) from both the types based on the following conditions.&lt;/P&gt;

&lt;P&gt;If both types have a values of tag, then on priority, it should consider value of tag from the type=First and ignore the tag value from type=Second, even if it has value or not.&lt;/P&gt;

&lt;P&gt;ii) If tag has no value — i.e., "" in type=First and tag of type=Second has the value — then it considers the value from type=Second for the same id of type=First.&lt;/P&gt;

&lt;P&gt;iii) if both the types have no value in tag, then we can ignore this.&lt;/P&gt;

&lt;P&gt;Note: the values of id_first and id_second has same values but the naming convention is different.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    time=1544071583425 type="First" version="2.0.5" status="OK"  id_first="210468"  user="abc" tag="some"
    time=1544071583425 type="First" version="2.0.5" status="OK"  id_first="210469"  user="xyz" tag=""
    time=1544071583424 type="First" version="2.0.5" status="OK"  id_first="210470"  user="wow" tag=""
    time=1544071583424 type="First" version="2.0.5" status="OK"  id_first="210483"  user="rez" 
    time=1544071583424 type="First" version="2.0.5" status="OK"  id_first="210487"  user="yov" tag="wrong"
    time=1544071583424 type="First" version="2.0.5" status="OK"  id_first="210491"  user="boh" tag=""


time=1544071583425 type="Second" version="2.0.5" status="OK"  id_second="210468"  user="abc" tag="some"
time=1544071583425 type="Second" version="2.0.5" status="OK"  id_second="210469"  user="xyz" tag="where"
time=1544071583424 type="Second" version="2.0.5" status="OK"  id_second="210470"  user="wow" tag="fishy
time=1544071583424 type="Second" version="2.0.5" status="OK"  id_second="210483"  user="rez" 
time=1544071583424 type="Second" version="2.0.5" status="OK"  id_second="210487"  user="yov" tag="wrong"
time=1544071583424 type="Second" version="2.0.5" status="OK"  id_second="210491"  user="boh" tag="great"

output:

tag              id
some         210469
where       210469
fishy       210470
wrong       210483
great       210487
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:18:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-unique-values-of-different-types-of-events-without/m-p/424583#M121750</guid>
      <dc:creator>bollam</dc:creator>
      <dc:date>2020-09-29T22:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get unique values of different types of events without duplicates?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-unique-values-of-different-types-of-events-without/m-p/424584#M121751</link>
      <description>&lt;P&gt;@bollam,&lt;/P&gt;

&lt;P&gt;According to your description, there is a mismatch in your output. For e.g. 210468 should have tag as some and 210491 should have great.&lt;BR /&gt;
Based on this assumption , try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"your search"
|eval ID=coalesce(id_first,id_second)
|stats values(eval(if(type="First",tag,null()))) as _tag1,values(eval(if(type="Second",tag,null()))) as _tag2 by ID
|eval tag=if(_tag1!="",_tag1,_tag2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Dec 2018 11:05:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-unique-values-of-different-types-of-events-without/m-p/424584#M121751</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-12-06T11:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get unique values of different types of events without duplicates?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-unique-values-of-different-types-of-events-without/m-p/424585#M121752</link>
      <description>&lt;P&gt;@renjith, No, value of 210491 does not have in tag in the type=First but  for id_second=210491 has the value in tag for type=Second. In this case tag should be considered as great since it's not present in the type=First.&lt;/P&gt;

&lt;P&gt;When the ran the query you provided, I'm not getting the values of tags but it's just displaying values as okay to all the events of tag.&lt;/P&gt;

&lt;P&gt;index=sai_core sourcetype=firstsecond_log &lt;BR /&gt;
| eval ID=coalesce(id_first,id_second) &lt;BR /&gt;
| stats values(eval(if(type="First",tag,null()))) as _tag1,values(eval(if(type="Second",tag,null()))) as _tag2 by ID&lt;BR /&gt;
| eval tag=if(_tag1!="", _tag1, _tag2)&lt;/P&gt;

&lt;P&gt;I do not understand where is the value "okay" is coming. There is no word "okay" exists in the event.&lt;BR /&gt;
How can I view the values of _tag1 and _tag2?&lt;/P&gt;

&lt;P&gt;ID  tag&lt;BR /&gt;
210468  okay&lt;BR /&gt;
210469  okay&lt;BR /&gt;
210470  okay&lt;BR /&gt;
210483  okay&lt;BR /&gt;
210487  okay&lt;BR /&gt;
210491  okay&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:18:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-unique-values-of-different-types-of-events-without/m-p/424585#M121752</guid>
      <dc:creator>bollam</dc:creator>
      <dc:date>2020-09-29T22:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get unique values of different types of events without duplicates?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-unique-values-of-different-types-of-events-without/m-p/424586#M121753</link>
      <description>&lt;P&gt;@bollam,&lt;BR /&gt;
Thats strange, can you try this and verify the values of of tag1 and tag2? If this is fine, then remove tag1 &amp;amp; tag2 by using &lt;CODE&gt;|fields - tag1,tag2&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=sai_core sourcetype=firstsecond_log 
| eval ID=coalesce(id_first,id_second) 
| stats values(eval(if(type="First",tag,null()))) as tag1,values(eval(if(type="Second",tag,null()))) as tag2 by ID
| eval tag=if(tag1!="", tag1, tag2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Dec 2018 18:20:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-get-unique-values-of-different-types-of-events-without/m-p/424586#M121753</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-12-06T18:20:16Z</dc:date>
    </item>
  </channel>
</rss>

