<?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 Values from Two Fields into a New Field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127941#M184396</link>
    <description>&lt;P&gt;I don't know if this is possible for the same sourcetype when I want to evaluate both IP addresses and then assign them to one single field.&lt;/P&gt;</description>
    <pubDate>Mon, 04 Nov 2013 22:16:05 GMT</pubDate>
    <dc:creator>jodros</dc:creator>
    <dc:date>2013-11-04T22:16:05Z</dc:date>
    <item>
      <title>Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127932#M184387</link>
      <description>&lt;P&gt;I have two fields, src_ip and dest_ip.  These two fields show up in the same log.  I am trying to merge all values of these two fields into a new generic field, ip.  I have tried using rename, eval with coalesce(), rex, as well as field aliases.  In all cases, only one of the fields (either src_ip or dest_ip) shows as ip.&lt;/P&gt;

&lt;P&gt;Summary: &lt;BR /&gt;
log 12:00:00 src_ip src_port dest_ip dest_port action&lt;/P&gt;

&lt;P&gt;src_ip = 1.1.1.1&lt;BR /&gt;
dest_ip = 2.2.2.2&lt;BR /&gt;
New ip field = 1.1.1.1 and 2.2.2.2&lt;/P&gt;

&lt;P&gt;Any suggestions would be appreciated.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:11:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127932#M184387</guid>
      <dc:creator>jodros</dc:creator>
      <dc:date>2020-09-28T15:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127933#M184388</link>
      <description>&lt;P&gt;&lt;CODE&gt;eval&lt;/CODE&gt; sounds like what you need;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;... | eval new_ip_field = src_ip . " and " . dest_ip&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;the dot (.) is the concatenation operator.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;UPDATE:&lt;/P&gt;

&lt;P&gt;to test the solution suggested by @yong.ly, try this in the search;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| eval ip = src_ip . "," . dest_ip | makemv delim = "," ip | stats c by ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;/K&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2013 15:23:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127933#M184388</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2013-11-04T15:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127934#M184389</link>
      <description>&lt;P&gt;Hi Jodros,&lt;/P&gt;

&lt;P&gt;try this&lt;/P&gt;

&lt;P&gt;|fillnull value="N/A" src_ip,dest_ip | eval NewField = src_ip + "and" + dest_ip&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:11:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127934#M184389</guid>
      <dc:creator>rakesh_498115</dc:creator>
      <dc:date>2020-09-28T15:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127935#M184390</link>
      <description>&lt;P&gt;Ok.  So maybe that isn't what a want to do.  I thought if I were able to merge all values from two fields into one field, than I could show the total count for an unique IP on a map, whether it was the source or destination in a log.&lt;/P&gt;

&lt;P&gt;Is there a better way to accomplish this?  &lt;/P&gt;

&lt;P&gt;Ultimate goal:&lt;BR /&gt;
log 12:00:00 src_ip=10.10.10.10 src_port=12345 dest_ip=1.1.1.1 dest_port=80 action=allow&lt;BR /&gt;
log 12:00:01 src_ip=1.1.1.1 src_port=12345 dest_ip=10.10.10.10 dest_port=80 action=block&lt;/P&gt;

&lt;P&gt;The stats count for a new field ip should show 1.1.1.1 as having a count of 2.&lt;/P&gt;

&lt;P&gt;Let me know if this makes more sense.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:11:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127935#M184390</guid>
      <dc:creator>jodros</dc:creator>
      <dc:date>2020-09-28T15:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127936#M184391</link>
      <description>&lt;P&gt;I just tried running stats on the src_ip and dest_ip in separate searches and appending it together.  That didn't work either.&lt;/P&gt;

&lt;P&gt;Neither did a join.  Was looking at foreach command.  Wonder if it would do it?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:11:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127936#M184391</guid>
      <dc:creator>jodros</dc:creator>
      <dc:date>2020-09-28T15:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127937#M184392</link>
      <description>&lt;P&gt;Or if there is a way to sum the output of a two separate stats commands:&lt;/P&gt;

&lt;P&gt;stats count by src_ip&lt;BR /&gt;
1.1.1.1 count 2&lt;/P&gt;

&lt;P&gt;stats count by dest_ip&lt;BR /&gt;
1.1.1.1 count 3&lt;/P&gt;

&lt;P&gt;sum of both stats&lt;BR /&gt;
1.1.1.1 count 5&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2013 19:15:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127937#M184392</guid>
      <dc:creator>jodros</dc:creator>
      <dc:date>2013-11-04T19:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127938#M184393</link>
      <description>&lt;P&gt;I combine a bunch of fields into a single field with a field extraction. I created it in Splunk web under "Admin / Fields / Field Extractions".&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\s(ip|domain|url|filename|md5|cve|email_addr|cve)=(?&amp;lt;phrase&amp;gt;\S+)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Nov 2013 19:50:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127938#M184393</guid>
      <dc:creator>jpass</dc:creator>
      <dc:date>2013-11-04T19:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127939#M184394</link>
      <description>&lt;P&gt;I don't think that this will work.  For one the logs don't actually contain the field names, so it doesn't looks like src_ip=1.1.1.1 dest_ip=2.2.2.2 in the log.  However if we took this approach anyway, I think this regex would always match the first and would not show results from both for the new field "phrase".&lt;/P&gt;

&lt;P&gt;Thanks for the suggestion.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:12:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127939#M184394</guid>
      <dc:creator>jodros</dc:creator>
      <dc:date>2020-09-28T15:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127940#M184395</link>
      <description>&lt;P&gt;Tried separate EXTRACT commands for the sourcetype.  Didn't work.&lt;/P&gt;

&lt;P&gt;I think I am running into an issue where a field cannot exist more than once per sourcetype possibly.  I know that I can create field aliases for fields from differing sourcetypes.  For instance, I can define a field alias src = src_ip for sourcetype a, and another field alias sip = src_ip for sourcetype b.  The when I run the search src_ip=1.1.1.1, if the value exists across both sourcetypes, it will return data from both.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:12:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127940#M184395</guid>
      <dc:creator>jodros</dc:creator>
      <dc:date>2020-09-28T15:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127941#M184396</link>
      <description>&lt;P&gt;I don't know if this is possible for the same sourcetype when I want to evaluate both IP addresses and then assign them to one single field.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2013 22:16:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127941#M184396</guid>
      <dc:creator>jodros</dc:creator>
      <dc:date>2013-11-04T22:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127942#M184397</link>
      <description>&lt;P&gt;it sounds like what you want is a multi-value field rather than combining the two (unless you want to have unique combinations of (dest/src). You can do this via an inline extraction or configuring it via props.conf.&lt;/P&gt;

&lt;P&gt;Try this search. It will look for all IP addresses and match up to two values in one event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[search term] | rex field=_raw "(?P&amp;lt;ip_addr&amp;gt;\d+.\d+.\d+.\d+)" max_match=2 | stats count by ip_addr
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Similiarly you can set up the regular expression in props.conf/transforms.conf&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yoursourcetype]
REPORT-ip_addr = extract_ipaddr
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[extract_ipaddr]
REGEX = (?P&amp;lt;ip_addr&amp;gt;\d+.\d+.\d+.\d+)
MV_ADD = true
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Nov 2013 23:53:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127942#M184397</guid>
      <dc:creator>yong_ly</dc:creator>
      <dc:date>2013-11-04T23:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127943#M184398</link>
      <description>&lt;P&gt;THANK YOU!  This is what I needed.  I appreciate it.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2013 14:05:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127943#M184398</guid>
      <dc:creator>jodros</dc:creator>
      <dc:date>2013-11-05T14:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127944#M184399</link>
      <description>&lt;P&gt;Ok, so now how can I further filter out my transformed search results.  I am able to use a "| search NOT ip=10.0.0.0/8" when I run a stats, but not a timechart.  I would like to filter out results from internal IP's and only display foreign IP's.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2013 14:34:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127944#M184399</guid>
      <dc:creator>jodros</dc:creator>
      <dc:date>2013-11-05T14:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127945#M184400</link>
      <description>&lt;P&gt;And apparently I cannot run a "| iplocation" on a multi-value field.  Hmmmm.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2013 14:41:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127945#M184400</guid>
      <dc:creator>jodros</dc:creator>
      <dc:date>2013-11-05T14:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127946#M184401</link>
      <description>&lt;P&gt;Hi Jodros,&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;regarding the first point, you would probably want to run the "|search NOT ip=***" BEFORE the stats or timechart command.. for example:&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;... | search NOT ip=**** | timechart ...&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;I haven't used iplocation, but if it doesn't work on MV fields, then you can use mvexpand to separate it out to different events.. e.g:&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;[search term] | rex field=_raw "(?P&lt;IP_ADDR&gt;\d+.\d+.\d+.\d+)" max_match=2 | mvexpand ip_addr | iplocation ip_addr &lt;/IP_ADDR&gt;&lt;/P&gt;

&lt;P&gt;What this will do is create two events from the one event that look identical, except that the ip_addr field will have different values.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 15:12:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127946#M184401</guid>
      <dc:creator>yong_ly</dc:creator>
      <dc:date>2020-09-28T15:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127947#M184402</link>
      <description>&lt;P&gt;So at this point, I need to know why I can run a stats count with a multi value field, but not a timechart count.  Also, the iplocation is a custom python script and I guess I need to know how to make it work with a multi value field.&lt;/P&gt;

&lt;P&gt;I also need to decide if this is worth it, to extract both IP's (src and dest) from logs and display them by unique IP count on a map.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2013 22:44:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127947#M184402</guid>
      <dc:creator>jodros</dc:creator>
      <dc:date>2013-11-05T22:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127948#M184403</link>
      <description>&lt;P&gt;did using the mvexpand command not work for either of those things? &lt;/P&gt;

&lt;P&gt;I think you're mistaken about timechart and MV fields. I just tested it and it works fine. Can you show me your full query? I don't think searches appended AFTER a timechart are valid.. so you need to filter BEFORE the timechart as I mentioned above.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2013 23:14:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127948#M184403</guid>
      <dc:creator>yong_ly</dc:creator>
      <dc:date>2013-11-05T23:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127949#M184404</link>
      <description>&lt;P&gt;Hey yong.ly, sorry about the last comment 18 hours ago.  Apparently my session wasn't fresh and I did not see your comments.  Yes, using the mvexpand is exactly what I need.  I really appreciate the assistance.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2013 17:47:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127949#M184404</guid>
      <dc:creator>jodros</dc:creator>
      <dc:date>2013-11-06T17:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127950#M184405</link>
      <description>&lt;P&gt;Why not create a field alias for &lt;CODE&gt;src_ip&lt;/CODE&gt; to ip and &lt;CODE&gt;dest_ip&lt;/CODE&gt; to ip. It's what I've done.&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[sourcetype1]  
FIELDALIAS_st1_src_to_ip = src_ip AS ip  
FIELDALIAS_st1_dest_to_ip = dest_tip AS ip  
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Nov 2013 12:25:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127950#M184405</guid>
      <dc:creator>Runals</dc:creator>
      <dc:date>2013-11-13T12:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Values from Two Fields into a New Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127951#M184406</link>
      <description>&lt;P&gt;Because it will only take the last FIELDALIAS statement it reads.  So actually in your example, the ip field will only contain the values from the dest_ip field.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2013 13:35:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Merge-Values-from-Two-Fields-into-a-New-Field/m-p/127951#M184406</guid>
      <dc:creator>jodros</dc:creator>
      <dc:date>2013-11-13T13:35:02Z</dc:date>
    </item>
  </channel>
</rss>

