<?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 to map extracted keys to values and separate them? in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-map-extracted-keys-to-values-and-separate-them/m-p/630197#M15348</link>
    <description>&lt;P&gt;If your data is JSON, then spath or json_extract can extract that, e.g. something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval p=json_extract(_raw, "profilesCount")
| spath input=p
| fields - _raw _time totalProfilesCount p
| transpose&lt;/LI-CODE&gt;&lt;P&gt;or you can use foreach to make a field of the account, e.g.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex max_match=0 "\"(?&amp;lt;account&amp;gt;\d{8})\" : (?&amp;lt;pCount&amp;gt;\d+)"
| foreach 0 1 2 3 4 5 [ eval n=mvindex(account,&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;), {n}=mvindex(pCount,&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) | fields - n]&lt;/LI-CODE&gt;&lt;P&gt;or you can use zip/expand/extract&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval zip=mvzip(account, pCount, "=")
| fields - account pCount
| mvexpand zip
| rex field=zip "(?&amp;lt;account&amp;gt;\d{8})=(?&amp;lt;pCount&amp;gt;\d+)"&lt;/LI-CODE&gt;&lt;P&gt;Hopefully one of these approaches will get you where you want to get to&lt;/P&gt;</description>
    <pubDate>Wed, 08 Feb 2023 23:22:00 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2023-02-08T23:22:00Z</dc:date>
    <item>
      <title>How to map extracted keys to values and separate them?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-map-extracted-keys-to-values-and-separate-them/m-p/630185#M15345</link>
      <description>&lt;P&gt;I have logs which contain parts like:&lt;BR /&gt;&lt;SPAN&gt;.. { "&lt;/SPAN&gt;&lt;SPAN class=""&gt;profilesCount&lt;/SPAN&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;&lt;SPAN&gt; { "&lt;/SPAN&gt;&lt;SPAN class=""&gt;120000&lt;/SPAN&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;100&lt;/SPAN&gt;&lt;SPAN&gt; , "&lt;/SPAN&gt;&lt;SPAN class=""&gt;120001&lt;/SPAN&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;500&lt;/SPAN&gt;&lt;SPAN&gt; , "&lt;/SPAN&gt;&lt;SPAN class=""&gt;110105&lt;/SPAN&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;200&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;, "&lt;/SPAN&gt;&lt;SPAN class=""&gt;totalProfilesCount&lt;/SPAN&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;&amp;nbsp;1057&lt;SPAN&gt;}} ..&lt;BR /&gt;&lt;/SPAN&gt;here the key is accountId and value is the number of profiles in it.&lt;BR /&gt;&lt;BR /&gt;when I use max_count=0 in rex and extract these values I get:&lt;BR /&gt;accountId=[12000000, 12000001, 11001005] and pCount=[100, 500, 200] for this example event.&lt;BR /&gt;&lt;BR /&gt;Since these accountIds are not mapped to their corresponding pCount when I visualize them I get&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;accountId&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;pCount&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="69px"&gt;12000000&lt;/TD&gt;
&lt;TD width="50%" height="69px"&gt;100&lt;BR /&gt;500&lt;BR /&gt;200&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="69px"&gt;12000001&lt;/TD&gt;
&lt;TD height="69px"&gt;100&lt;BR /&gt;500&lt;BR /&gt;200&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%" height="25px"&gt;11001005&lt;/TD&gt;
&lt;TD width="50%" height="25px"&gt;100&lt;BR /&gt;500&lt;BR /&gt;200&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;BR /&gt;how can I map them correctly and show in a table form?&lt;BR /&gt;&lt;BR /&gt;This was my search query:&lt;BR /&gt;search &amp;lt;search_logic&amp;gt; | rex max_match=0 "\"(?&amp;lt;account&amp;gt;\d{8})\" : (?&amp;lt;pCount&amp;gt;\d+)"] | stats values(pCount) by account&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 22:22:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-map-extracted-keys-to-values-and-separate-them/m-p/630185#M15345</guid>
      <dc:creator>piyushpandey</dc:creator>
      <dc:date>2023-02-08T22:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to map extracted keys to values and separate them?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-map-extracted-keys-to-values-and-separate-them/m-p/630197#M15348</link>
      <description>&lt;P&gt;If your data is JSON, then spath or json_extract can extract that, e.g. something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval p=json_extract(_raw, "profilesCount")
| spath input=p
| fields - _raw _time totalProfilesCount p
| transpose&lt;/LI-CODE&gt;&lt;P&gt;or you can use foreach to make a field of the account, e.g.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex max_match=0 "\"(?&amp;lt;account&amp;gt;\d{8})\" : (?&amp;lt;pCount&amp;gt;\d+)"
| foreach 0 1 2 3 4 5 [ eval n=mvindex(account,&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;), {n}=mvindex(pCount,&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) | fields - n]&lt;/LI-CODE&gt;&lt;P&gt;or you can use zip/expand/extract&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval zip=mvzip(account, pCount, "=")
| fields - account pCount
| mvexpand zip
| rex field=zip "(?&amp;lt;account&amp;gt;\d{8})=(?&amp;lt;pCount&amp;gt;\d+)"&lt;/LI-CODE&gt;&lt;P&gt;Hopefully one of these approaches will get you where you want to get to&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 23:22:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-map-extracted-keys-to-values-and-separate-them/m-p/630197#M15348</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-02-08T23:22:00Z</dc:date>
    </item>
  </channel>
</rss>

