<?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 can I split up values in a field to create new fields? New field names should be extracted from original field. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-up-values-in-a-field-to-create-new-fields-New/m-p/703305#M238381</link>
    <description>&lt;P&gt;Try this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex max_match=0 field=tags "(?&amp;lt;namevalue&amp;gt;[^:,]+:[^, ]+)"
| mvexpand namevalue
| rex field=namevalue "(?&amp;lt;name&amp;gt;[^:]+):(?&amp;lt;value&amp;gt;.*)"
| eval {name}=value&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 01 Nov 2024 09:50:26 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2024-11-01T09:50:26Z</dc:date>
    <item>
      <title>How can I split up values in a field to create new fields? New field names should be extracted from original field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-up-values-in-a-field-to-create-new-fields-New/m-p/702842#M238277</link>
      <description>&lt;P&gt;I've imported a csv file and one of the fields called "Tags" looks like this:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Tags=&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"avd:vm, dept:support services, cm-resource-parent:/subscriptions/e9674c3a-f9f8-85cc-b457-94cf0fbd9715/resourcegroups/avd-standard-pool-rg/providers/microsoft.desktopvirtualization/hostpools/avd_standard_pool_1, manager:JohnDoe@email.com"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'd like to split each of these tags up into their own field/value, &lt;STRONG&gt;AND&lt;/STRONG&gt; extract the first part of the tag as the field name.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Result of new fields/values would look like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;avd="vm"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;dept="support services"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;cm-resource-parent="/subscriptions/e9674c3a-f9f8-85cc-b457-94cf0fbd9715/resourcegroups/avd-standard-pool-rg/providers/microsoft.desktopvirtualization/hostpools/avd_standard_pool_1"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;manager="JohnDoe@email.com"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I've looked at a lot of examples with rex, MV commands, etc, but nothing that pulls the new field name out of the original field.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The format of that Tags field is always the same as listed above, for all events.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2024 21:23:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-up-values-in-a-field-to-create-new-fields-New/m-p/702842#M238277</guid>
      <dc:creator>eraser</dc:creator>
      <dc:date>2024-10-25T21:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split up values in a field to create new fields? New field names should be extracted from original field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-up-values-in-a-field-to-create-new-fields-New/m-p/702846#M238278</link>
      <description>&lt;P&gt;Try this one :&lt;/P&gt;&lt;PRE&gt;&amp;lt;your_search&amp;gt;| rex field=Tags "avd:(?&amp;lt;avd&amp;gt;[^,]+),\s*dept:(?&amp;lt;dept&amp;gt;[^,]+),\s*cm-resource-parent:(?&amp;lt;cm_resource_parent&amp;gt;[^,]+),\s*manager:(?&amp;lt;manager&amp;gt;[^$]+)"&lt;/PRE&gt;&lt;P&gt;------&lt;/P&gt;&lt;H5&gt;If you find this solution helpful, please consider&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;accepting it&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;awarding karma points !!&lt;/STRONG&gt;&lt;/H5&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Oct 2024 07:49:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-up-values-in-a-field-to-create-new-fields-New/m-p/702846#M238278</guid>
      <dc:creator>Jawahir</dc:creator>
      <dc:date>2024-10-26T07:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split up values in a field to create new fields? New field names should be extracted from original field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-up-values-in-a-field-to-create-new-fields-New/m-p/702847#M238279</link>
      <description>&lt;P&gt;It depends whether we're talking about configuring extractions in transforms or trying to do it with search commands.&lt;/P&gt;&lt;P&gt;With configured extractions you just need to capture two groups - one for the field name, another for value and either use $1::$2 for format if using unnamed groups or name them _KEY_1 and _VAL_1 respectively if using named groups.&lt;/P&gt;&lt;P&gt;If you want to do that in SPL you need to use the {} notation. Like&lt;/P&gt;&lt;PRE&gt;| eval {fieldname}=fieldvalue&lt;/PRE&gt;&lt;P&gt;Where fieldname is a field containing your target field name.&lt;/P&gt;&lt;P&gt;Most probably you'll want to split your input into key:value chunks as multivalued field, then use foreach to iterate over those chunks and split them into final key-value pairs and use the {key} notation to define the output field.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Oct 2024 07:54:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-up-values-in-a-field-to-create-new-fields-New/m-p/702847#M238279</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-10-26T07:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split up values in a field to create new fields? New field names should be extracted from original field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-up-values-in-a-field-to-create-new-fields-New/m-p/702855#M238283</link>
      <description>&lt;LI-CODE lang="markup"&gt;| rex max_match=0 field=tags "(?&amp;lt;namevalue&amp;gt;[^:, ]+:[^, ]+)"
| mvexpand namevalue
| rex field=namevalue "(?&amp;lt;name&amp;gt;[^:]+):(?&amp;lt;value&amp;gt;.*)"
| eval {name}=value&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 26 Oct 2024 11:58:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-up-values-in-a-field-to-create-new-fields-New/m-p/702855#M238283</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-10-26T11:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split up values in a field to create new fields? New field names should be extracted from original field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-up-values-in-a-field-to-create-new-fields-New/m-p/703297#M238378</link>
      <description>&lt;P&gt;Thanks - this is very close to what I'm looking for (I do want to perform this extraction at search time), but may need a couple tweaks.&lt;/P&gt;&lt;P&gt;1) All of the dept's have a space in them (some more than one)and the rex is only picking up the first word of that dept. Examples: "&lt;SPAN class=""&gt;support&lt;/SPAN&gt; &lt;SPAN class=""&gt;services", "xyz operations r&amp;amp;d"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;2) Also - when I look into each event to see that the Tags fields are extracted,&amp;nbsp; only one actually gets extracted. But it's not the same one each time?? The "name" and "namevalue" fields match the one field that does get extracted.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Hope that makes sense?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2024 00:01:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-up-values-in-a-field-to-create-new-fields-New/m-p/703297#M238378</guid>
      <dc:creator>eraser</dc:creator>
      <dc:date>2024-11-01T00:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split up values in a field to create new fields? New field names should be extracted from original field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-up-values-in-a-field-to-create-new-fields-New/m-p/703305#M238381</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex max_match=0 field=tags "(?&amp;lt;namevalue&amp;gt;[^:,]+:[^, ]+)"
| mvexpand namevalue
| rex field=namevalue "(?&amp;lt;name&amp;gt;[^:]+):(?&amp;lt;value&amp;gt;.*)"
| eval {name}=value&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 01 Nov 2024 09:50:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-up-values-in-a-field-to-create-new-fields-New/m-p/703305#M238381</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-11-01T09:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I split up values in a field to create new fields? New field names should be extracted from original field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-up-values-in-a-field-to-create-new-fields-New/m-p/703345#M238396</link>
      <description>&lt;P&gt;Here's what I ended up doing, seems to work!&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex max_match=0 field=Tags "(?&amp;lt;namevalue&amp;gt;[^:, ]+:[^,]+)" 
| mvexpand namevalue 
| rex field=namevalue "(?&amp;lt;name&amp;gt;[^:]+):(?&amp;lt;value&amp;gt;.*)" 
| eval {name}=value &lt;/LI-CODE&gt;&lt;P&gt;The confusion about seeing only one of the fields being extracted was a result of the mvexpand. I didn't realize that created NEW events, one for each field. Makes sense now...thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2024 19:07:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-split-up-values-in-a-field-to-create-new-fields-New/m-p/703345#M238396</guid>
      <dc:creator>eraser</dc:creator>
      <dc:date>2024-11-01T19:07:54Z</dc:date>
    </item>
  </channel>
</rss>

