<?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 How to create a new key-value pair from various fieldnames with a similar pattern? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288665#M87391</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;my events can include a fieldname with a pattern like:&lt;/P&gt;

&lt;P&gt;product_type_a&lt;BR /&gt;
product_type_b&lt;BR /&gt;
product_type_c&lt;/P&gt;

&lt;P&gt;To group calculations by product type, I think about creating a new key-value pair like&lt;BR /&gt;
&lt;STRONG&gt;type=product_type_A&lt;/STRONG&gt;. I could use a CASE command, but then I need to know all product_type_* that will appear in the future.&lt;BR /&gt;
Is there a way to use something like COALESCE in combination with a wildcard or LIKE, to grab the first appearing fieldname as value?&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;BR /&gt;
Heinz&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 12:47:47 GMT</pubDate>
    <dc:creator>HeinzWaescher</dc:creator>
    <dc:date>2020-09-29T12:47:47Z</dc:date>
    <item>
      <title>How to create a new key-value pair from various fieldnames with a similar pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288665#M87391</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;my events can include a fieldname with a pattern like:&lt;/P&gt;

&lt;P&gt;product_type_a&lt;BR /&gt;
product_type_b&lt;BR /&gt;
product_type_c&lt;/P&gt;

&lt;P&gt;To group calculations by product type, I think about creating a new key-value pair like&lt;BR /&gt;
&lt;STRONG&gt;type=product_type_A&lt;/STRONG&gt;. I could use a CASE command, but then I need to know all product_type_* that will appear in the future.&lt;BR /&gt;
Is there a way to use something like COALESCE in combination with a wildcard or LIKE, to grab the first appearing fieldname as value?&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;BR /&gt;
Heinz&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:47:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288665#M87391</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2020-09-29T12:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new key-value pair from various fieldnames with a similar pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288666#M87392</link>
      <description>&lt;P&gt;Hi HeinzWaescher,&lt;BR /&gt;
could you detail your question?&lt;BR /&gt;
you can group events by type using stats command, but you already know!&lt;BR /&gt;
if you want, you could also populate a lookup with a scheduled search and list all the type values to use in your statistic searches.&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 10:52:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288666#M87392</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-02-07T10:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new key-value pair from various fieldnames with a similar pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288667#M87393</link>
      <description>&lt;P&gt;I'm not sure if I understand completely what your request is. Are you saying Splunk is extracting different product names from your events as their own individual fields? Could you provide a few samples of your events, and a screen shot? I may be able to help, but I'd need to see the data first. &lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 12:28:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288667#M87393</guid>
      <dc:creator>adayton20</dc:creator>
      <dc:date>2017-02-07T12:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new key-value pair from various fieldnames with a similar pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288668#M87394</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=1 "(?&amp;lt;type&amp;gt;product_type_\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Feb 2017 22:03:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288668#M87394</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-02-07T22:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new key-value pair from various fieldnames with a similar pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288669#M87395</link>
      <description>&lt;P&gt;I would like to extract a new key value pair from fieldnames that can appear in the events.&lt;BR /&gt;
Let's say we have 3 events, with these fieldnames and amounts.&lt;/P&gt;

&lt;P&gt;event1: product_type_a=5&lt;BR /&gt;
event2: product_type_b=8&lt;BR /&gt;
event:3 product_type_c=10&lt;/P&gt;

&lt;P&gt;What I want to do here, is to transform fieldnames with the pattern product_type_* into values for the new field "type". So in the end, I have a new field per event&lt;/P&gt;

&lt;P&gt;event1: type=product_type_a&lt;BR /&gt;
event2: type=product_type_b&lt;BR /&gt;
event3: type=product_type_c&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:45:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288669#M87395</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2020-09-29T12:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new key-value pair from various fieldnames with a similar pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288670#M87396</link>
      <description>&lt;P&gt;I tried that out but the search shows an error:&lt;/P&gt;

&lt;P&gt;Error in 'SearchOperator:regex': Usage: regex  (=|!=)  &lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 10:09:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288670#M87396</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2017-02-08T10:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new key-value pair from various fieldnames with a similar pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288671#M87397</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Sounds like your just looking to use the &lt;CODE&gt;rex&lt;/CODE&gt; command. So either of these depending on what format you want:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "product_type_(?&amp;lt;type&amp;gt;[^\s]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "(?&amp;lt;type2&amp;gt;product_type_[^\s]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which would look like this:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2458iA6414D73451F3FA4/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 10:32:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288671#M87397</guid>
      <dc:creator>gvmorley</dc:creator>
      <dc:date>2017-02-08T10:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a new key-value pair from various fieldnames with a similar pattern?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288672#M87398</link>
      <description>&lt;P&gt;I had a typo!  I meant &lt;CODE&gt;rex&lt;/CODE&gt;, not &lt;CODE&gt;regex&lt;/CODE&gt;!  Try the fixed answer now!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 17:58:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-new-key-value-pair-from-various-fieldnames-with/m-p/288672#M87398</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-02-08T17:58:52Z</dc:date>
    </item>
  </channel>
</rss>

