<?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: Separate a field value and use the parts to make a new field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Separate-a-field-value-and-use-the-parts-to-make-a-new-field/m-p/158617#M44715</link>
    <description>&lt;P&gt;This should do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | eval host = "location-group-function-number.domain.com" | rex field=host "^(?&amp;lt;location&amp;gt;[^-]+)-(?&amp;lt;group&amp;gt;[^-]+)-(?&amp;lt;function&amp;gt;[^-]+)-(?&amp;lt;number&amp;gt;[^.]+)" | eval name = location."-".number
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once happy you can move the &lt;CODE&gt;rex&lt;/CODE&gt; to a field extraction by going to Settings -&amp;gt; Fields -&amp;gt; Field Extractions -&amp;gt; New and entering this (note the "in host"!):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^(?&amp;lt;location&amp;gt;[^-]+)-(?&amp;lt;group&amp;gt;[^-]+)-(?&amp;lt;function&amp;gt;[^-]+)-(?&amp;lt;number&amp;gt;[^.]+) in host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You could go even further and define a calculated field for &lt;CODE&gt;name&lt;/CODE&gt; - then there's little need to repeat this in every query.&lt;/P&gt;</description>
    <pubDate>Fri, 25 Jul 2014 21:32:55 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-07-25T21:32:55Z</dc:date>
    <item>
      <title>Separate a field value and use the parts to make a new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Separate-a-field-value-and-use-the-parts-to-make-a-new-field/m-p/158616#M44714</link>
      <description>&lt;P&gt;Separate a field values and use the parts to make a new field.&lt;BR /&gt;
My host names have four components in the name separated by a dash:&lt;/P&gt;

&lt;P&gt;i.e. "location-group-function-number.domain.com"&lt;/P&gt;

&lt;P&gt;I would like to separate the parts of the name and recombine them as:&lt;/P&gt;

&lt;P&gt;"Loc-num"&lt;/P&gt;

&lt;P&gt;I used this regex to go from the FWDN to the netbios name:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;rex field=host "^(?&amp;lt;name&amp;gt;.+)\.domain\.com"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I tried using the &lt;CODE&gt;makemv delim=”-“ name&lt;/CODE&gt; &lt;BR /&gt;
but this just gives me more values for “name”&lt;/P&gt;

&lt;P&gt;I though of using three regex functions one to each part then use strcat to put them back together but this seems a bit to much code for a simple task&lt;/P&gt;

&lt;P&gt;I have this format: host=”Loc-Grp-Func-##.domain.com”&lt;/P&gt;

&lt;P&gt;For readability on the report I would like: name=”Loc-##”&lt;/P&gt;

&lt;P&gt;Any suggestions would be helpful&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jul 2014 21:20:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Separate-a-field-value-and-use-the-parts-to-make-a-new-field/m-p/158616#M44714</guid>
      <dc:creator>hartfoml</dc:creator>
      <dc:date>2014-07-25T21:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Separate a field value and use the parts to make a new field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Separate-a-field-value-and-use-the-parts-to-make-a-new-field/m-p/158617#M44715</link>
      <description>&lt;P&gt;This should do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | eval host = "location-group-function-number.domain.com" | rex field=host "^(?&amp;lt;location&amp;gt;[^-]+)-(?&amp;lt;group&amp;gt;[^-]+)-(?&amp;lt;function&amp;gt;[^-]+)-(?&amp;lt;number&amp;gt;[^.]+)" | eval name = location."-".number
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once happy you can move the &lt;CODE&gt;rex&lt;/CODE&gt; to a field extraction by going to Settings -&amp;gt; Fields -&amp;gt; Field Extractions -&amp;gt; New and entering this (note the "in host"!):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^(?&amp;lt;location&amp;gt;[^-]+)-(?&amp;lt;group&amp;gt;[^-]+)-(?&amp;lt;function&amp;gt;[^-]+)-(?&amp;lt;number&amp;gt;[^.]+) in host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You could go even further and define a calculated field for &lt;CODE&gt;name&lt;/CODE&gt; - then there's little need to repeat this in every query.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jul 2014 21:32:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Separate-a-field-value-and-use-the-parts-to-make-a-new-field/m-p/158617#M44715</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-07-25T21:32:55Z</dc:date>
    </item>
  </channel>
</rss>

