<?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 convert Key value into field value data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642110#M222430</link>
    <description>&lt;P&gt;Requirement is to break key value into fields and show data in below format for each hosts --&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hostname : server1.com&lt;/P&gt;&lt;P&gt;username : john&lt;/P&gt;&lt;P&gt;hardware manufacturer : HP&lt;/P&gt;&lt;P&gt;Puppet status : Active&lt;/P&gt;&lt;P&gt;CPU count : 12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hostname : server2.com&lt;/P&gt;&lt;P&gt;username : Tim&lt;/P&gt;&lt;P&gt;hardware manufacturer : IBM&lt;/P&gt;&lt;P&gt;Puppet status : Fail&lt;/P&gt;&lt;P&gt;CPU count : 12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 03 May 2023 09:01:29 GMT</pubDate>
    <dc:creator>srv007</dc:creator>
    <dc:date>2023-05-03T09:01:29Z</dc:date>
    <item>
      <title>How can I convert Key value into field value data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642023#M222403</link>
      <description>&lt;P&gt;The data is in key value format instead of field value due to limitation of fields to be used.&lt;/P&gt;
&lt;P&gt;There are 10+ key value for each host. I'm looking to convert these key value data into fields so that i can apply the drop down filter as input and search result get updated as per the field selected in the drop down input.&lt;/P&gt;
&lt;P&gt;Here is an example of how my data is appearing in splunk.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;index=this_is_demo source="demo-kv" script=demo.ps1 hostname IN (*)&lt;/P&gt;
&lt;P&gt;hostname - server1.com&lt;BR /&gt;IP - 128.xx.xx.xx&lt;BR /&gt;group -&lt;BR /&gt;key - username&lt;BR /&gt;value - john&lt;BR /&gt;script -demo.ps1&lt;/P&gt;
&lt;P&gt;hostname - server1.com&lt;BR /&gt;IP - 128.xx.xx.xx&lt;BR /&gt;group -&lt;BR /&gt;key - hardware manufacturer&lt;BR /&gt;value - HP&lt;BR /&gt;script -demo.ps1&lt;/P&gt;
&lt;P&gt;hostname - server1.com&lt;BR /&gt;IP - 128.xx.xx.xx&lt;BR /&gt;group -&lt;BR /&gt;key - Puppet status&lt;BR /&gt;value - active&lt;BR /&gt;script -demo.ps1&lt;/P&gt;
&lt;P&gt;hostname - server1.com&lt;BR /&gt;IP - 128.xx.xx.xx&lt;BR /&gt;group -&lt;BR /&gt;key - CPU count&lt;BR /&gt;value - 12&lt;BR /&gt;script -demo.ps1&lt;/P&gt;
&lt;P&gt;Appreciate all the knowledge and guidance here. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 18:24:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642023#M222403</guid>
      <dc:creator>srv007</dc:creator>
      <dc:date>2023-05-02T18:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Key value into field value data..</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642035#M222407</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/255618"&gt;@srv007&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I understood correctly, the example data is the _raw value for each row? If you want to solve this search time, you could try to use the extract command:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| extract kvdelim="-" pairdelim="\n"&lt;/LI-CODE&gt;&lt;P&gt;Note that the default behavior of the command is set to a max of 50 kv pairs and it that it only works on the _raw field.&lt;/P&gt;&lt;P&gt;You can read more about the command over here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Extract" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Extract&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If the above data is not contained in the _raw field, could you reply with an example of a data row?&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 17:14:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642035#M222407</guid>
      <dc:creator>rut</dc:creator>
      <dc:date>2023-05-02T17:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert Key value into field value data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642076#M222418</link>
      <description>&lt;P&gt;index=this_is_demo source="demo-kv" script=demo.ps1 hostname IN (*)&lt;BR /&gt;| rex "(?&amp;lt;key&amp;gt;\w+)\s+-\s+(?&amp;lt;value&amp;gt;[^\r\n]+)"&lt;BR /&gt;| kv&lt;BR /&gt;| stats values(*) as * by hostname&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 22:36:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642076#M222418</guid>
      <dc:creator>abi2023</dc:creator>
      <dc:date>2023-05-02T22:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert Key value into field value data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642083#M222421</link>
      <description>&lt;P&gt;If you mean key value as key=username, value=john for the first event, therefore what you are looking for are the keys&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;username&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;hardware manufacturer&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Puppet status&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CPU count&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the corresponding values for each of those keys&lt;/P&gt;&lt;P&gt;You can get those attributes from the data with (assuming your data is as presented)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "key\s*-\s*(?&amp;lt;key&amp;gt;.*)\nvalue\s*-\s*(?&amp;lt;value&amp;gt;.*)"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then you have key and value column that each contain the name of the key and the value of that key&lt;/P&gt;&lt;P&gt;If you want to use the key as a dropdown input for key selection, just use fieldForLabel and value as key&lt;/P&gt;&lt;P&gt;As for a dropdown for value where you only want the values shown for your selected key, then you have to add an addition search fragment&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| search key=$your_key_token|s$&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in your dropdown generating search, so it only shows the values for the selected key.,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 01:07:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642083#M222421</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-05-03T01:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert Key value into field value data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642110#M222430</link>
      <description>&lt;P&gt;Requirement is to break key value into fields and show data in below format for each hosts --&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hostname : server1.com&lt;/P&gt;&lt;P&gt;username : john&lt;/P&gt;&lt;P&gt;hardware manufacturer : HP&lt;/P&gt;&lt;P&gt;Puppet status : Active&lt;/P&gt;&lt;P&gt;CPU count : 12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hostname : server2.com&lt;/P&gt;&lt;P&gt;username : Tim&lt;/P&gt;&lt;P&gt;hardware manufacturer : IBM&lt;/P&gt;&lt;P&gt;Puppet status : Fail&lt;/P&gt;&lt;P&gt;CPU count : 12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 09:01:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642110#M222430</guid>
      <dc:creator>srv007</dc:creator>
      <dc:date>2023-05-03T09:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert Key value into field value data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642235#M222472</link>
      <description>&lt;P&gt;So something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=this_is_demo source="demo-kv" script=demo.ps1 hostname IN (*)
| rex "key\s*-\s*(?&amp;lt;key&amp;gt;.*)\nvalue\s*-\s*(?&amp;lt;value&amp;gt;.*)"
| eval kv=key.":".value
| stats values(kv) as kvs by hostname
``` And now put hostname into that list ```
| eval kvs = mvappend("hostname:".hostname, kvs)
| fields - hostname&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 06:55:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642235#M222472</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-05-04T06:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert Key value into field value data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642334#M222502</link>
      <description>&lt;P&gt;This is how the output is from above query&amp;nbsp; which is not what im looking for.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="srv007_0-1683232080008.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/25234iB82029B5CFFC4F74/image-size/medium?v=v2&amp;amp;px=400" role="button" title="srv007_0-1683232080008.png" alt="srv007_0-1683232080008.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;What i want to achieve is something like below --&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="srv007_1-1683232270805.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/25235iC1321D5730C04F5C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="srv007_1-1683232270805.png" alt="srv007_1-1683232270805.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Sorry if i have not been clear much&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 20:31:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642334#M222502</guid>
      <dc:creator>srv007</dc:creator>
      <dc:date>2023-05-04T20:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert Key value into field value data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642335#M222503</link>
      <description>&lt;P&gt;And later on need to apply drop down filter on those fields such as username, Puppet status.&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 20:35:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642335#M222503</guid>
      <dc:creator>srv007</dc:creator>
      <dc:date>2023-05-04T20:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert Key value into field value data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642403#M222531</link>
      <description>&lt;P&gt;I managed to get the data displayed in below format by using chart command.&lt;BR /&gt;&lt;BR /&gt;index=this_is_demo source="demo-kv" script=demo.ps1 hostname IN (*)&lt;BR /&gt;|chart limit=0 list(value) over hostname by key&lt;BR /&gt;|transpose 0&lt;BR /&gt;&lt;BR /&gt;My only requirement left is use filters where we can select the keys such as username or puppet status and it should display the selected filter only.&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 12:06:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642403#M222531</guid>
      <dc:creator>srv007</dc:creator>
      <dc:date>2023-05-05T12:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert Key value into field value data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642471#M222554</link>
      <description>&lt;P&gt;Assuming each group is a separate event and each event is multi-lined, try something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| extract pairdelim="\n" kvdelim="-"
| eval {key}=value
| fields - key value
| stats values(*) as * by hostname&lt;/LI-CODE&gt;&lt;P&gt;If not, please share you events in a code block (similar to above code using the &amp;lt;/&amp;gt; button), so we can see what you are actually dealing with&lt;/P&gt;</description>
      <pubDate>Sat, 06 May 2023 11:42:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-convert-Key-value-into-field-value-data/m-p/642471#M222554</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-05-06T11:42:11Z</dc:date>
    </item>
  </channel>
</rss>

