<?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 two fields into one field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65338#M16218</link>
    <description>&lt;P&gt;Put it into a "Calculated field".&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;props.conf
[mysourcetype]
eval-report = Duration. "-" .action
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 13 Jul 2019 22:21:27 GMT</pubDate>
    <dc:creator>landen99</dc:creator>
    <dc:date>2019-07-13T22:21:27Z</dc:date>
    <item>
      <title>How to merge two fields into one field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65316#M16196</link>
      <description>&lt;P&gt;I have the following result set coming from a search:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;field_1 field_2
 1       2
 3       4
 5       6
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I need to merge these two fields into a new field "output":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;output
 1
 2
 3
 4
 5
 6
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;Lp&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2023 21:08:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65316#M16196</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2023-01-12T21:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65317#M16197</link>
      <description>&lt;P&gt;Here is one way- but there is probably something better&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere |
rename field1 as output |
append [search yoursearchhere earliest=-24h |
rename field2 as output ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This runs the search twice...&lt;BR /&gt;&lt;BR /&gt;
Notice that I included earliest=-24h for the inner search. Otherwise, this will search over all time - it is not affected by the time selector. [No longer true - the inner search runs over the range specified by the timerange selector.]&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2012 20:45:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65317#M16197</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-05-31T20:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65318#M16198</link>
      <description>&lt;P&gt;This approach is expensive and might not work when dealing with millions of events.&lt;BR /&gt;
Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2012 12:18:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65318#M16198</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2012-06-01T12:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65319#M16199</link>
      <description>&lt;P&gt;Well give more details. You didn't state that this was going to be used across millions events. Also you need to give more details on the search you're using to generate these fields. Do field1 and field2 belong to the same search result? Do both fields always occur in all events you want to apply this to?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2012 12:22:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65319#M16199</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-06-01T12:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65320#M16200</link>
      <description>&lt;P&gt;Better answer:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere |
eval output = toString(field1) + ";" + toString(field2) |
makemv delim=";" output |
mvexpand output
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This assumes that field1 and field2 are numeric. If they are not, you can use the following instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere |
eval output = field1 + ";" + field2 |
makemv delim=";" output |
mvexpand output
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note that a semicolon (;) is used as a delimiter, so a semicolon cannot appear in either field1 or field2.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2012 13:41:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65320#M16200</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-06-01T13:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65321#M16201</link>
      <description>&lt;P&gt;Nice learning experience. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jun 2012 14:33:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65321#M16201</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2012-06-01T14:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65322#M16202</link>
      <description>&lt;P&gt;Simply rename the fields to the same name like this and it works! &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere | rename field_1 as output | rename field_2 as output
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(I found this after not wanting to deal with delimiters)&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2012 20:38:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65322#M16202</guid>
      <dc:creator>e_sherlock</dc:creator>
      <dc:date>2012-10-08T20:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65323#M16203</link>
      <description>&lt;P&gt;Yes, you can do this, but given the example in the original question:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;field_1 field_2&lt;BR /&gt;
 1       2&lt;BR /&gt;
 3       4&lt;BR /&gt;
 5       6&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Your solution would end up with 3 events, not 6. And your 3 events would have a multi-valued field named &lt;CODE&gt;output&lt;/CODE&gt;. Nothing wrong with that, but it might be hard to work with, depending on what you wanted to do next.&lt;/P&gt;

&lt;P&gt;BTW, if you wanted, you could also create field aliases that would make your renames "permanent" so that you don't have to do the renames every time.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2012 04:22:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65323#M16203</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-10-09T04:22:05Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65324#M16204</link>
      <description>&lt;P&gt;True. My specific use case worked as I was dealing with 6 different log events so the source looks like this:&lt;/P&gt;

&lt;P&gt;field_1 field_2&lt;BR /&gt;
1&lt;BR /&gt;
        2&lt;BR /&gt;
3&lt;BR /&gt;
5&lt;BR /&gt;
        4&lt;BR /&gt;
        6&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:36:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65324#M16204</guid>
      <dc:creator>e_sherlock</dc:creator>
      <dc:date>2020-09-28T12:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65325#M16205</link>
      <description>&lt;P&gt;The subsearch naturally carries the time of the outer search unless otherwise specified, as I understand it.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2015 16:19:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65325#M16205</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2015-08-04T16:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65326#M16206</link>
      <description>&lt;P&gt;Sorry for the late show, but this returns null in the second field&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2016 03:34:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65326#M16206</guid>
      <dc:creator>ibekacyril</dc:creator>
      <dc:date>2016-04-18T03:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65327#M16207</link>
      <description>&lt;P&gt;I am getting the null response as well.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 02:11:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65327#M16207</guid>
      <dc:creator>seanclark</dc:creator>
      <dc:date>2016-06-16T02:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65328#M16208</link>
      <description>&lt;P&gt;Is one of your fields that you're merging contains null values?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 04:36:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65328#M16208</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-06-16T04:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65329#M16209</link>
      <description>&lt;P&gt;Apparently they did, but I could not find where they were. I also had to manipulate this solution some to get what I wanted. I had to fields that had IPs in them so I did this.&lt;/P&gt;

&lt;P&gt;myprecious | fillnull value="" source_address ip_address| eval output =ip_address.source_address&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:58:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65329#M16209</guid>
      <dc:creator>seanclark</dc:creator>
      <dc:date>2020-09-29T09:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65330#M16210</link>
      <description>&lt;P&gt;Agreed @landen99, but that was not true in 2012 &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2016 02:46:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65330#M16210</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2016-07-21T02:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65331#M16211</link>
      <description>&lt;P&gt;This solution assumes that you are starting with field1 and field2 not multivalue.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 21:30:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65331#M16211</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2017-02-16T21:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65332#M16212</link>
      <description>&lt;P&gt;If field1 is multivalued, you can do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; eval output = mvappend(field1,field2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To remove nulls:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval output = mvfilter(output!=null())
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jul 2017 18:29:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65332#M16212</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2017-07-12T18:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65333#M16213</link>
      <description>&lt;P&gt;I downvoted this post because the solution does not work.  it just leaves you with output containing the values of field_2&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 18:35:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65333#M16213</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2017-07-12T18:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65334#M16214</link>
      <description>&lt;P&gt;second rename result is always shown when we do this&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 04:37:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65334#M16214</guid>
      <dc:creator>vinodti</dc:creator>
      <dc:date>2018-02-01T04:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Merge two fields into one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65335#M16215</link>
      <description>&lt;P&gt;@lguinn2 Make this a comment so that it can be accepted as an answer. I found this to be correct. &lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2019 17:42:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-two-fields-into-one-field/m-p/65335#M16215</guid>
      <dc:creator>ryhluc01</dc:creator>
      <dc:date>2019-05-10T17:42:22Z</dc:date>
    </item>
  </channel>
</rss>

