<?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: Help with JOIN in multi search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404623#M117029</link>
    <description>&lt;P&gt;I got the following error, any suggestions? &lt;/P&gt;

&lt;P&gt;Error in 'eval' command: The arguments to the 'if' function are invalid.&lt;/P&gt;

&lt;P&gt;I tried to change some of the field names for how I understand your suggestion but still can't get it to work.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jul 2019 18:54:42 GMT</pubDate>
    <dc:creator>jmpaul012</dc:creator>
    <dc:date>2019-07-23T18:54:42Z</dc:date>
    <item>
      <title>Help with JOIN in multi search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404621#M117027</link>
      <description>&lt;P&gt;I'm trying to do a JOIN with 2 search but I'm having issues. I tried to do a multi search  &lt;CODE&gt;join&lt;/CODE&gt; but I'm getting a streaming error. &lt;BR /&gt;
I think one of the problems is the seaches both have an   &lt;CODE&gt;"id"&lt;/CODE&gt; column, but they reference two totally different things and I need to use it in the join. Here is the info below:&lt;/P&gt;

&lt;P&gt;(I want to join these two searches)&lt;/P&gt;

&lt;P&gt;SEARCH1 -  &lt;CODE&gt;"id"&lt;/CODE&gt; column is the ec2 instance name (I use this column for the join)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=*_aws sourcetype=aws:description source="*ec2_instances"  |rename id AS ec2id | table account_id, ec2id, state, ip, publicIP, instance_type, platform vpc_id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;SEARCH2-  &lt;CODE&gt;"id"&lt;/CODE&gt; column is the sg name" (I use instances{}.id to join "id" in SEARCH1)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=*_aws sourcetype=aws:description source=*:ec2_security_groups
| rename id AS sgid, instances{}.id AS ec2id
| table account_id, sgid, ec2id, name, instances{}.id, rules{}.from_port, rules{}.grants{}.cidr_ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to join on column ec2id.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 13:35:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404621#M117027</guid>
      <dc:creator>jmpaul012</dc:creator>
      <dc:date>2019-07-23T13:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: Help with JOIN in multi search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404622#M117028</link>
      <description>&lt;P&gt;Perhaps &lt;CODE&gt;join&lt;/CODE&gt; is not needed.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=*_aws sourcetype=aws:description (source="*ec2_instances" OR source=*:ec2_security_groups)
| eval id = if(like(source, "%:ec2_security_groups"), sgid)
| eval ec2id = if(like(source, "%:ec2_security_groups"), instances{}.id, id)
| stats values(account_id) as account_id, values(state) as state, values(publicIP) as publicIP, values(instance_type) as instance_type, values(platform) as platform, values(vpc_id) as vpc_id, values(name) as name, values(rules{}.from_port) as from_port, values(rules{}.grants{}.cidr_ip) as cidr_ip by ec2id
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jul 2019 18:43:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404622#M117028</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-07-23T18:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help with JOIN in multi search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404623#M117029</link>
      <description>&lt;P&gt;I got the following error, any suggestions? &lt;/P&gt;

&lt;P&gt;Error in 'eval' command: The arguments to the 'if' function are invalid.&lt;/P&gt;

&lt;P&gt;I tried to change some of the field names for how I understand your suggestion but still can't get it to work.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 18:54:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404623#M117029</guid>
      <dc:creator>jmpaul012</dc:creator>
      <dc:date>2019-07-23T18:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: Help with JOIN in multi search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404624#M117030</link>
      <description>&lt;P&gt;There is an error in the 2 line (if command missing a else case):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
| eval id = if(like(source, "%:ec2_security_groups"), sgid)
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
| eval id = if(like(source, "%:ec2_security_groups"), sgid, id)
...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Jul 2019 23:09:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404624#M117030</guid>
      <dc:creator>jaime_ramirez</dc:creator>
      <dc:date>2019-07-23T23:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Help with JOIN in multi search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404625#M117031</link>
      <description>&lt;P&gt;Thanks, the search runs but doesn't return results. If I run the query without "by ec2id" at the end it returns 700+ rows. Any idea why it isn't returning results with "by ec2id"?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 12:30:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404625#M117031</guid>
      <dc:creator>jmpaul012</dc:creator>
      <dc:date>2019-07-24T12:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Help with JOIN in multi search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404626#M117032</link>
      <description>&lt;P&gt;We may need to swap the order of &lt;CODE&gt;eval&lt;/CODE&gt;s.  What are you seeing for the values of ec2id?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=*_aws sourcetype=aws:description (source="*ec2_instances" OR source=*:ec2_security_groups)
| eval ec2id = if(like(source, "%:ec2_security_groups"), instances{}.id, id) 
| eval id = if(like(source, "%:ec2_security_groups"), sgid, id)
| stats values(account_id) as account_id, values(state) as state, values(publicIP) as publicIP, values(instance_type) as instance_type, values(platform) as platform, values(vpc_id) as vpc_id, values(name) as name, values(rules{}.from_port) as from_port, values(rules{}.grants{}.cidr_ip) as cidr_ip by ec2id
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jul 2019 14:13:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404626#M117032</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-07-24T14:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help with JOIN in multi search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404627#M117033</link>
      <description>&lt;P&gt;No values are being returned for ec2id&lt;/P&gt;

&lt;P&gt;This part of the query doesn't work becuase "ec2id" is what I want to rename "instances{}.id to.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval ec2id = if(like(source, "%:ec2_security_groups"), instances{}.id, id) 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2019 12:39:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404627#M117033</guid>
      <dc:creator>jmpaul012</dc:creator>
      <dc:date>2019-07-25T12:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help with JOIN in multi search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404628#M117034</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=*_aws AND sourcetype="aws:description") AND (source="*ec2_instances" OR source=*:ec2_security_groups)
| eval ec2id = if(match(source, "ec2_instances$"), id, 'instances{}.id')
| eval sgid = if(match(source, "ec2_instances$"), null, id)
| table account_id, sgid, ec2id, name, state, ip, publicIP, instance_type, platform vpc_id instances{}.id, rules{}.from_port, rules{}.grants{}.cidr_ip
| stats values(*) AS * BY ec2id
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2019 23:57:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404628#M117034</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-25T23:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: Help with JOIN in multi search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404629#M117035</link>
      <description>&lt;P&gt;Your query seems to be working a lot better! I do have a question. This part didn't work:&lt;/P&gt;

&lt;P&gt;(index=*_AND aws sourcetype=aws:description)&lt;/P&gt;

&lt;P&gt;I had to remove the _AND:&lt;BR /&gt;
 (index=* aws sourcetype=aws:description)&lt;/P&gt;

&lt;P&gt;What is the logic behind, index=*_AND ?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 11:50:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404629#M117035</guid>
      <dc:creator>jmpaul012</dc:creator>
      <dc:date>2019-07-29T11:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Help with JOIN in multi search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404630#M117036</link>
      <description>&lt;P&gt;How does it not work?  The &lt;CODE&gt;eval&lt;/CODE&gt; is functionally equivalent to &lt;CODE&gt;rename&lt;/CODE&gt; in that you get a field called 'ec2id' with the value from field 'instances{}.id'.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 12:16:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404630#M117036</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-07-30T12:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: Help with JOIN in multi search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404631#M117037</link>
      <description>&lt;P&gt;That was a typo; I fixed it.  I like to have explicit &lt;CODE&gt;AND&lt;/CODE&gt; instead if implied.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 14:50:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-JOIN-in-multi-search/m-p/404631#M117037</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-30T14:50:10Z</dc:date>
    </item>
  </channel>
</rss>

