<?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 would a lookup to combine two values to one OUTPUT field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323510#M96569</link>
    <description>&lt;P&gt;Splunk search time order of operations strikes again - sorry for that &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;But you could try using a eval based macro &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Definesearchmacros#Eval_expressions_in_macro_definitions"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Definesearchmacros#Eval_expressions_in_macro_definitions&lt;/A&gt; for this&lt;/P&gt;</description>
    <pubDate>Mon, 05 Jun 2017 17:52:51 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2017-06-05T17:52:51Z</dc:date>
    <item>
      <title>How would a lookup to combine two values to one OUTPUT field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323498#M96557</link>
      <description>&lt;P&gt;I'm looking at firewall logs which typically have (among other details) a source address and a destination address. I'm attempting to use a lookup table to determine the organizational group that each IP belongs to. The lookup table is a fairly basic format:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Subnet,OrgGroup
192.168.0.0/24,Group1
192.168.1.0/24,Group2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This was how I was originally going to do it: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=cisco:asa | lookup ip_to_group Subnet AS src_ip OUTPUT OrgGroup as src_group  | lookup ip_to_group Subnet AS dest_ip OUTPUT OrgGroup as dest_group
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives me: &lt;EM&gt;src_group=Group1, dest_group=Group2&lt;/EM&gt;&lt;BR /&gt;
For business reasons, we don't want to have two output fields (src_group, dest_group) but one ("org_group"):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=cisco:asa | lookup ip_to_group Subnet AS src_ip OUTPUT OrgGroup as org_group  | lookup ip_to_group Subnet AS dest_ip OUTPUT OrgGroup as org_group
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How would I blend those lookups into both using "org_group" without overwriting? e.g. &lt;EM&gt;org_group=Group1,Group2&lt;/EM&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:17:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323498#M96557</guid>
      <dc:creator>robdanl</dc:creator>
      <dc:date>2020-09-29T14:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: How would a lookup to combine two values to one OUTPUT field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323499#M96558</link>
      <description>&lt;P&gt;You could concatenate the results using an eval statement&lt;/P&gt;

&lt;P&gt;| eval org_group= src_group+",".dest_group,You could concatenate the two fields using an eval statement&lt;/P&gt;

&lt;P&gt;| eval org_group= src_group+",".dest_group&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:16:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323499#M96558</guid>
      <dc:creator>anthonymelita</dc:creator>
      <dc:date>2020-09-29T14:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: How would a lookup to combine two values to one OUTPUT field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323500#M96559</link>
      <description>&lt;P&gt;Hi robdanl,&lt;/P&gt;

&lt;P&gt;make the lookup an automatic lookup &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Makeyourlookupautomatic"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Makeyourlookupautomatic&lt;/A&gt; so it will perform the lookup automatically for you and add a calculated field &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/definecalcfields"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/definecalcfields&lt;/A&gt; to your soucetype that concatenates the fields &lt;CODE&gt;src_group&lt;/CODE&gt; and &lt;CODE&gt;dest_group&lt;/CODE&gt; like this in &lt;CODE&gt;props.conf&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;EVAL-org_group = src_group .":". dest_group
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or as multi value field (which is a bit tricky and &lt;EM&gt;nasty&lt;/EM&gt; for post processing AND if your really want it this way) in search time:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search here | eval org_group = "" | foreach *_group [eval org_group='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;' + "," + org_group]| makemv delim="," org_group
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Maybe you need to adapt this, because I haven't tested it &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps to get you started ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 20:15:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323500#M96559</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2017-05-30T20:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: How would a lookup to combine two values to one OUTPUT field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323501#M96560</link>
      <description>&lt;P&gt;Both of your suggestions work. It's a shame there doesn't seem to be a way to create a multi-value field as part of a lookup the way I described. That would be ideal as - you're right - doing a loop through fields and concatenating them doesn't feel ideal when we need to have it included in every single search performed.&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 20:37:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323501#M96560</guid>
      <dc:creator>robdanl</dc:creator>
      <dc:date>2017-05-30T20:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: How would a lookup to combine two values to one OUTPUT field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323502#M96561</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=cisco:asa
| lookup ip_to_group Subnet AS src_ip OUTPUT OrgGroup as src_group 
| lookup ip_to_group Subnet AS dest_ip OUTPUT OrgGroup as dest_group
| nomv src_grp
| nomv dest_grp
| eval combined = src_grp . " " . dest_grp
| makemv org_group
| eval org_group= mvdedup(org_group)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 May 2017 21:54:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323502#M96561</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-30T21:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: How would a lookup to combine two values to one OUTPUT field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323503#M96562</link>
      <description>&lt;P&gt;On your second option (with the foreach), how would that be included in every search? While I would be able to copy/paste that string or add it into a macro, not every user could or would want to do that.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 18:30:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323503#M96562</guid>
      <dc:creator>robdanl</dc:creator>
      <dc:date>2017-06-01T18:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: How would a lookup to combine two values to one OUTPUT field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323504#M96563</link>
      <description>&lt;P&gt;It also appears I can also do it this way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval org_group=mvappend(src_group,dest_group)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I just need to figure out how to make every search include this behind the scenes.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 18:45:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323504#M96563</guid>
      <dc:creator>robdanl</dc:creator>
      <dc:date>2017-06-01T18:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: How would a lookup to combine two values to one OUTPUT field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323505#M96564</link>
      <description>&lt;P&gt;Create a calculated field from your eval statement.&lt;BR /&gt;
Settings &amp;gt; Fields &amp;gt; Caluclated fields&lt;/P&gt;

&lt;P&gt;it won't auto append on your searches, but it will be a nice shortcut&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 20:28:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323505#M96564</guid>
      <dc:creator>anthonymelita</dc:creator>
      <dc:date>2017-06-01T20:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: How would a lookup to combine two values to one OUTPUT field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323506#M96565</link>
      <description>&lt;P&gt;Yes, that is better, but it might still need &lt;CODE&gt;mvdedup&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 20:31:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323506#M96565</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-06-01T20:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: How would a lookup to combine two values to one OUTPUT field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323507#M96566</link>
      <description>&lt;P&gt;Yes, that's the downside of the second option. Therefore the automatic lookup and the calculated field as in option one is preferred. Or use the &lt;CODE&gt;mvappend()&lt;/CODE&gt; as you figured out, for the calculated field. Still post processing this new field will be tricky....&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 20:38:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323507#M96566</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2017-06-01T20:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: How would a lookup to combine two values to one OUTPUT field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323508#M96567</link>
      <description>&lt;P&gt;Unfortunately, it doesn't look like this will work per the documentation on props.conf:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Splunk processes calculated fields after field extraction and field&lt;BR /&gt;
 aliasing but before lookups. This means that:&lt;BR /&gt;
 - You can use a field alias in the eval statement for a calculated&lt;BR /&gt;
   field.&lt;BR /&gt;
 - You cannot use a field added through a lookup in an eval statement for a&lt;BR /&gt;
   calculated field.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 05 Jun 2017 14:20:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323508#M96567</guid>
      <dc:creator>robdanl</dc:creator>
      <dc:date>2017-06-05T14:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: How would a lookup to combine two values to one OUTPUT field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323509#M96568</link>
      <description>&lt;P&gt;It doesn't appear I can do as you were suggesting as calculated fields are processed before lookups per your initial link as well as some documention on props.conf:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Calculated fields come fifth in the search-time operations sequence, after field aliasing but before lookups&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 05 Jun 2017 14:22:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323509#M96568</guid>
      <dc:creator>robdanl</dc:creator>
      <dc:date>2017-06-05T14:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: How would a lookup to combine two values to one OUTPUT field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323510#M96569</link>
      <description>&lt;P&gt;Splunk search time order of operations strikes again - sorry for that &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;But you could try using a eval based macro &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Definesearchmacros#Eval_expressions_in_macro_definitions"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Definesearchmacros#Eval_expressions_in_macro_definitions&lt;/A&gt; for this&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2017 17:52:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-would-a-lookup-to-combine-two-values-to-one-OUTPUT-field/m-p/323510#M96569</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2017-06-05T17:52:51Z</dc:date>
    </item>
  </channel>
</rss>

