<?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: Multivalue field combining and dynamic field creation from extraction of values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-field-combining-and-dynamic-field-creation-from/m-p/172739#M49527</link>
    <description>&lt;P&gt;That seems a bit convoluted to me, is there a reason for not using key-value extraction capabilities in transforms.conf directly?&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your_sourcetype]
TRANSFORMS-keyvalue = PosTransactionProperties
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[PosTransactionProperties]
REGEX = PosTransactionProperties\[\d+\]\.PosTransactionPropertyCode\[\d+\]=(?&amp;lt;_KEY_1&amp;gt;[^\n\r]+)[\n\r]+PosTransactionProperties\[\d+\]\.PosTransactionPropertyValue\[\d+\]=(?&amp;lt;_VAL_1&amp;gt;[^\n\r]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will extract both the field name and the field value using the magic &lt;CODE&gt;_KEY_n&lt;/CODE&gt; and &lt;CODE&gt;_VAL_n&lt;/CODE&gt; names. Nothing to do in the search itself or in calculated fields, the fields will just be there automatically.&lt;/P&gt;

&lt;P&gt;Edit: The reason for your approach not working out is that calculated fields (&lt;CODE&gt;EVAL-foo&lt;/CODE&gt; in props.conf) are applied after field extractions, so your transforms.conf rules don't see those fields.&lt;/P&gt;</description>
    <pubDate>Sat, 18 Oct 2014 17:01:25 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-10-18T17:01:25Z</dc:date>
    <item>
      <title>Multivalue field combining and dynamic field creation from extraction of values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-field-combining-and-dynamic-field-creation-from/m-p/172738#M49526</link>
      <description>&lt;P&gt;Starting with the data in an event:&lt;/P&gt;

&lt;P&gt;Lines in Single Event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;PosTransactionProperties[1].PosTransactionPropertyCode[1]=RECEIPT_EMAIL_ADDRESS
PosTransactionProperties[1].PosTransactionPropertyValue[1]=user-email@domain.com
PosTransactionProperties[2].PosTransactionPropertyCode[1]=RECEIPT_DELIVERY_METHOD
PosTransactionProperties[2].PosTransactionPropertyValue[1]=EMAIL+PAPER
PosTransactionProperties[3].PosTransactionPropertyCode[1]=CUSTOMER_EMAIL_UPDATED
PosTransactionProperties[3].PosTransactionPropertyValue[1]=true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to create fields and values that look like the following for all events:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;RECEIPT_EMAIL_ADDRESS = user-email@domain.com
RECEIPT_DELIVERY_METHOD = EMAIL+PAPER
CUSTOMER_EMAIL_UPDATED = true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am taking a three (3) step process to achieving my goal: (Still having issues on Step 3)&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Extract the initial values from the original lines as multi-valued values&lt;/LI&gt;
&lt;LI&gt;Combine the values in a single field&lt;/LI&gt;
&lt;LI&gt;Break that field into parts, that will create the new field=values format I am desiring&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;&lt;STRONG&gt;Step 1&lt;/STRONG&gt; - I did this by extracting the fields using some multivalue field extractions in props.conf and transforms.conf, putting them into two fields (postransactionproperties_PosTransactionPropertyCode and postransactionproperties_PosTransactionPropertyValue)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;props.conf
REPORT-trans_PosTransactionProperties = t_PTP_PosTransactionPropertyCode, t_PTP_PosTransactionPropertyValue

transforms.conf
# =-=- PosTransactionProperties[1].PosTransactionPropertyCode[1]=RECEIPT_EMAIL_ADDRESS
[t_PTP_PosTransactionPropertyCode]
REGEX = PosTransactionProperties\[[0-9]+\]\.PosTransactionPropertyCode\[[0-9]+\]\=([^\n]+)\n
FORMAT = postransactionproperties_PosTransactionPropertyCode::$1 
MV_ADD = true
REPEAT_MATCH = true

# =-=- PosTransactionProperties[1].PosTransactionPropertyValue[1]=user-email@domain.com
[t_PTP_PosTransactionPropertyValue]
REGEX = PosTransactionProperties\[[0-9]+\]\.PosTransactionPropertyValue\[[0-9]+\]\=([^\n]+)\n
FORMAT = postransactionproperties_PosTransactionPropertyValue::$1 
MV_ADD = true
REPEAT_MATCH = true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I then end up with the two mvfields, with all the values lines up in the order they show up in the event.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;postransactionproperties_PosTransactionPropertyCode 
RECEIPT_EMAIL_ADDRESS   
RECEIPT_DELIVERY_METHOD 
CUSTOMER_EMAIL_UPDATED

postransactionproperties_PosTransactionPropertyValue
user-email@domain.com   
EMAIL+PAPER 
true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Step 2&lt;/STRONG&gt; - I then combine the two fields in the order they exist, into a single field matching the values up together, with a separator using an eval statement in the props.conf file&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;props.conf
EVAL-glue = mvzip(postransactionproperties_PosTransactionPropertyCode,postransactionproperties_PosTransactionPropertyValue,":::")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result is a field named 'glue' that has values as such:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;CUSTOMER_EMAIL_UPDATED:::true
RECEIPT_DELIVERY_METHOD:::EMAIL+PAPER
RECEIPT_EMAIL_ADDRESS:::user-email@domain.com
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Step 3&lt;/STRONG&gt; - Which I am having trouble with, I want to now break the values of the field 'glue' up into Key =&amp;gt; Value pairs. I am thinking I can do this again with a props.conf and a transforms.conf statement as such:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;props.conf
REPORT-trans_glue = t_unglue

transforms.conf
[t_unglue]
SOURCE_KEY = glue
REGEX = ([a-zA-Z0-9\_\-]+):::([a-zA-Z0-9]+)
FORMAT = $1::$2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This unfortunately does not work at all, and I need a little help to either understand why, and how to get it to work, or attack this whole problem in a different fashion all together. (NOTE: I understand the REGEX statement is not 100% correct, but it should have at least matched the 'true' result and it does not).&lt;/P&gt;

&lt;P&gt;Thank you &lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:56:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multivalue-field-combining-and-dynamic-field-creation-from/m-p/172738#M49526</guid>
      <dc:creator>jmsiegma</dc:creator>
      <dc:date>2020-09-28T17:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Multivalue field combining and dynamic field creation from extraction of values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multivalue-field-combining-and-dynamic-field-creation-from/m-p/172739#M49527</link>
      <description>&lt;P&gt;That seems a bit convoluted to me, is there a reason for not using key-value extraction capabilities in transforms.conf directly?&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your_sourcetype]
TRANSFORMS-keyvalue = PosTransactionProperties
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[PosTransactionProperties]
REGEX = PosTransactionProperties\[\d+\]\.PosTransactionPropertyCode\[\d+\]=(?&amp;lt;_KEY_1&amp;gt;[^\n\r]+)[\n\r]+PosTransactionProperties\[\d+\]\.PosTransactionPropertyValue\[\d+\]=(?&amp;lt;_VAL_1&amp;gt;[^\n\r]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will extract both the field name and the field value using the magic &lt;CODE&gt;_KEY_n&lt;/CODE&gt; and &lt;CODE&gt;_VAL_n&lt;/CODE&gt; names. Nothing to do in the search itself or in calculated fields, the fields will just be there automatically.&lt;/P&gt;

&lt;P&gt;Edit: The reason for your approach not working out is that calculated fields (&lt;CODE&gt;EVAL-foo&lt;/CODE&gt; in props.conf) are applied after field extractions, so your transforms.conf rules don't see those fields.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Oct 2014 17:01:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multivalue-field-combining-and-dynamic-field-creation-from/m-p/172739#M49527</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-10-18T17:01:25Z</dc:date>
    </item>
  </channel>
</rss>

