<?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: transform csv field value, split, join and create dynamic field value pair in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-transform-csv-field-value-split-join-and-create-dynamic/m-p/580053#M202114</link>
    <description>&lt;P&gt;This should work. We are doing a foreach on the field_name to match against the fields listed in "sli_dimensions_alert", and a true match will result in the field_value being appended to new variable "alert_values".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval env="PRD", service_name="EXGMGR", type="LOBREQUEST", class="TIMEOUTERROR", lob="GOV", product="APPLE", resource="SERVER" 
| eval sli_dimensions_alert="env,service_name,type,class"
| eval sli_dimensions_alert="env,service_name,type,class,product,resource,lob"

| eval alert_fields=SPLIT(sli_dimensions_alert, ",")
| foreach env service_name type class product resource lob [| eval field_name="&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;" | eval alert_values=IF(field_name=alert_fields, MVAPPEND(alert_values, &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;), alert_values)]
| eval alert_name=MVJOIN(alert_values, "-")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jan 2022 21:35:01 GMT</pubDate>
    <dc:creator>johnhuang</dc:creator>
    <dc:date>2022-01-05T21:35:01Z</dc:date>
    <item>
      <title>How: transform csv field value, split, join and create dynamic field value pair</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-transform-csv-field-value-split-join-and-create-dynamic/m-p/579931#M202057</link>
      <description>&lt;P&gt;I use a lookup to define alert/SLO specifications. I use the lookups as input filters to my alert searches where I can.&lt;/P&gt;&lt;P&gt;The lookup column name is sli_dimensions_alert: (there are other columns in the lookup):&lt;/P&gt;&lt;P&gt;sli_dimensions_alert="env,service_name,type,class"&lt;/P&gt;&lt;P&gt;The&amp;nbsp;sli_dimensions_alert field specification can have multiple comma separated values.&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;sli_dimensions_alert="env,service_name,type,class"&lt;/P&gt;&lt;P&gt;My goal is to create an alert_name based on that CSV value list.&lt;/P&gt;&lt;P&gt;Example raw data:&lt;BR /&gt;env="PRD"&lt;BR /&gt;service_name="EXGMGR"&lt;BR /&gt;type="ERROR"&lt;BR /&gt;class="TIMEOUT"&lt;/P&gt;&lt;P&gt;I want to create a macro, calculated field or automatic lookup to&amp;nbsp;transform sli_dimensions_alert="env,service_name,type,class" into alert_name="PRD-EXGMGR-ERROR-TIMEOUT".&lt;/P&gt;&lt;P&gt;I've tried a variety of combinations with split, mvjoin, mvmap, but haven't found a way to make it work.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 00:13:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-transform-csv-field-value-split-join-and-create-dynamic/m-p/579931#M202057</guid>
      <dc:creator>cmckenna</dc:creator>
      <dc:date>2022-01-05T00:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: How: transform csv field value, split, join and create dynamic field value pair</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-transform-csv-field-value-split-join-and-create-dynamic/m-p/579935#M202058</link>
      <description>&lt;P&gt;It would help to see what you've already tried and they didn't meet expectations, but perhaps this will help.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;... | eval parts=split(sli_dimensions_alert, ",")
| eval sli_dimensions_alert = mvindex(parts,0)."-".mvindex(parts,1)."-".mvindex(parts,2)."-".mvindex(parts,3)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 01:01:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-transform-csv-field-value-split-join-and-create-dynamic/m-p/579935#M202058</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-01-05T01:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: How: transform csv field value, split, join and create dynamic field value pair</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-transform-csv-field-value-split-join-and-create-dynamic/m-p/579937#M202060</link>
      <description>&lt;P&gt;The SLO lookup file that I use to filter and specify SLO configurations contains these columns (more info than needed really):&lt;/P&gt;&lt;P&gt;lookup file: hi2_slo_config&lt;/P&gt;&lt;P&gt;COLUMNS:&lt;BR /&gt;slo_spec_version, slo_name, slo_description, slo_service, slo_env, slo_domain, slo_type, slo_class, slo_lob, slo_severity, slo_category, slo_product, slo_eventtype, slo_time_isrolling, slo_time_count, slo_time_unit, slo_timeslices, slo_budget_method, slo_op, slo_threshold, slo_docref, sli_name, sli_type, sli_source, sli_sourcetype, sli_metric_name, sli_dimensions_metric, sli_dimensions_alert, slo_flag_mock, slo_flag_snow, slo_msg_id_snow, slo_flag_mm, slo_msg_id_mm, slo_webhook_id_mm, slo_flag_email, slo_msg_id_email, slo_msg_dest_email&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use the&amp;nbsp;sli_dimensions_alert field to define the alert naming conventions.&lt;/P&gt;&lt;P&gt;Here are two examples (I want to be able to customize sli_dimensions_alert as desired):&lt;/P&gt;&lt;P&gt;* sli_dimensions_alert="env,service_name,type,class,product,resource,lob"&lt;/P&gt;&lt;P&gt;* sli_dimensions_alert="env,service_name,type,class"&lt;/P&gt;&lt;P&gt;I've split and joined the sli_dimensions_alert field using the following:&lt;/P&gt;&lt;P&gt;| eval alert_name=mvjoin(split(replace(sli_dimensions_alert," ",""), ","), "-")&lt;/P&gt;&lt;P&gt;That eval creates the following:&lt;/P&gt;&lt;P&gt;alert_name="env-service_name-type-class-product-resource-lob"&lt;/P&gt;&lt;P&gt;alert_name="env-service_name-type-class"&lt;/P&gt;&lt;P&gt;I want to substitute/replace/map the fields env, service_name, type, class, product, resource, lob, etc with the value for those fields that come from my source. Example values in previous post.&lt;/P&gt;&lt;P&gt;I haven't nailed it with mvmap and am trying a for command to loop concatenation. Having a hard time with it.&lt;/P&gt;&lt;P&gt;I was thinking I could create a macro that passes in the CSV field (e.g. sli_dimensions_alert="env,service_name,type,class,product,resource,lob") and loop process it with a for command.&lt;/P&gt;&lt;P&gt;Struggling with that. I'm hoping there's a simpler solution that hasn't come to mind.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 02:00:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-transform-csv-field-value-split-join-and-create-dynamic/m-p/579937#M202060</guid>
      <dc:creator>cmckenna</dc:creator>
      <dc:date>2022-01-05T02:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: How: transform csv field value, split, join and create dynamic field value pair</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-transform-csv-field-value-split-join-and-create-dynamic/m-p/579947#M202067</link>
      <description>&lt;P&gt;Could you post what your current search looks like?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 04:25:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-transform-csv-field-value-split-join-and-create-dynamic/m-p/579947#M202067</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-01-05T04:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: How: transform csv field value, split, join and create dynamic field value pair</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-transform-csv-field-value-split-join-and-create-dynamic/m-p/580041#M202109</link>
      <description>&lt;P&gt;Mock up snippet:&lt;BR /&gt;&lt;BR /&gt;| makeresults&lt;BR /&gt;| eval COMMENT="The following fields are search time results"&lt;/P&gt;&lt;P&gt;| eval env="PRD", service_name="EXGMGR", type="LOBREQUEST", class="TIMEOUTERROR", lob="GOV"&lt;/P&gt;&lt;P&gt;| eval COMMENT="The sli_dimensions_alert field is retrieved from a lookup and has a variable number of comma delimited values. Two examples below"&lt;/P&gt;&lt;P&gt;| eval sli_dimensions_alert="env,service_name,type,class"&lt;/P&gt;&lt;P&gt;| eval sli_dimensions_alert="env,service_name,type,class,product,resource,lob"&lt;/P&gt;&lt;P&gt;| eval alert_name=mvjoin(split(sli_dimensions_alert,","),"-")&lt;/P&gt;&lt;P&gt;| eval COMMENT="I want alert_name to contain the actual field values"&lt;/P&gt;&lt;P&gt;| eval COMMENT="alert_name = PRD-EXGMGR-LOBREQUEST-TIMEOUTERROR-GOV"&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 17:47:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-transform-csv-field-value-split-join-and-create-dynamic/m-p/580041#M202109</guid>
      <dc:creator>cmckenna</dc:creator>
      <dc:date>2022-01-05T17:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: How: transform csv field value, split, join and create dynamic field value pair</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-transform-csv-field-value-split-join-and-create-dynamic/m-p/580053#M202114</link>
      <description>&lt;P&gt;This should work. We are doing a foreach on the field_name to match against the fields listed in "sli_dimensions_alert", and a true match will result in the field_value being appended to new variable "alert_values".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval env="PRD", service_name="EXGMGR", type="LOBREQUEST", class="TIMEOUTERROR", lob="GOV", product="APPLE", resource="SERVER" 
| eval sli_dimensions_alert="env,service_name,type,class"
| eval sli_dimensions_alert="env,service_name,type,class,product,resource,lob"

| eval alert_fields=SPLIT(sli_dimensions_alert, ",")
| foreach env service_name type class product resource lob [| eval field_name="&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;" | eval alert_values=IF(field_name=alert_fields, MVAPPEND(alert_values, &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;), alert_values)]
| eval alert_name=MVJOIN(alert_values, "-")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 21:35:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-transform-csv-field-value-split-join-and-create-dynamic/m-p/580053#M202114</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-01-05T21:35:01Z</dc:date>
    </item>
  </channel>
</rss>

