<?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 extract and aggregate by extracted fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-aggregate-by-extracted-fields/m-p/556960#M158176</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the data that looks like this&lt;BR /&gt;user, ip, (metrics kv pairs)&lt;/P&gt;&lt;P&gt;---- sample results for search --&amp;nbsp;&lt;BR /&gt;user=user1,ip=10.10.10.10,key1=10,key2=30&lt;BR /&gt;user=user2,ip=10.10.10.10,key1=5,key3=30&lt;BR /&gt;user=user1,ip=10.10.10.12,key2=10,key3=30,key4=2,key5=14,key6=4&lt;BR /&gt;user=user1,ip=10.10.10.10,key5=22&lt;BR /&gt;-------------&lt;BR /&gt;&lt;BR /&gt;How do I pull out the metrics - key1- key6 and aggregate by the metrics ?&lt;BR /&gt;say if i wanted a pie chart with all totals of all the keys for a given IP/ user (say IP and username are dashboard input tokens)&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jun 2021 09:06:30 GMT</pubDate>
    <dc:creator>ashriram</dc:creator>
    <dc:date>2021-06-24T09:06:30Z</dc:date>
    <item>
      <title>How to extract and aggregate by extracted fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-aggregate-by-extracted-fields/m-p/556960#M158176</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the data that looks like this&lt;BR /&gt;user, ip, (metrics kv pairs)&lt;/P&gt;&lt;P&gt;---- sample results for search --&amp;nbsp;&lt;BR /&gt;user=user1,ip=10.10.10.10,key1=10,key2=30&lt;BR /&gt;user=user2,ip=10.10.10.10,key1=5,key3=30&lt;BR /&gt;user=user1,ip=10.10.10.12,key2=10,key3=30,key4=2,key5=14,key6=4&lt;BR /&gt;user=user1,ip=10.10.10.10,key5=22&lt;BR /&gt;-------------&lt;BR /&gt;&lt;BR /&gt;How do I pull out the metrics - key1- key6 and aggregate by the metrics ?&lt;BR /&gt;say if i wanted a pie chart with all totals of all the keys for a given IP/ user (say IP and username are dashboard input tokens)&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 09:06:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-aggregate-by-extracted-fields/m-p/556960#M158176</guid>
      <dc:creator>ashriram</dc:creator>
      <dc:date>2021-06-24T09:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract and aggregate by extracted fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-aggregate-by-extracted-fields/m-p/556961#M158177</link>
      <description>&lt;LI-CODE lang="markup"&gt;| extract
| stats sum(*) as * by ip user
| eval userip=user.":".ip
| fields - ip user
| table userip *&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 24 Jun 2021 09:33:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-aggregate-by-extracted-fields/m-p/556961#M158177</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-06-24T09:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract and aggregate by extracted fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-aggregate-by-extracted-fields/m-p/556963#M158178</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/235747"&gt;@ashriram&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please try this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;YOUR_SEARCH
| rex field=_raw "user=(?&amp;lt;user&amp;gt;[^,]*),ip=(?&amp;lt;ip&amp;gt;[^,]*),(?&amp;lt;keys&amp;gt;[^\n]*)"
| rex field=keys "key\d=(?&amp;lt;k&amp;gt;[^\n|,]*)" max_match=0
| stats sum(k) as key_sum by ip user&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can changes as per your requirement like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats sum(k) as key_sum by ip&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats sum(k) as key_sum by user&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Sample Search :&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval raw="user=user1,ip=10.10.10.10,key1=10,key2=30|user=user2,ip=10.10.10.10,key1=5,key3=30|user=user1,ip=10.10.10.12,key2=10,key3=30,key4=2,key5=14,key6=4|user=user1,ip=10.10.10.10,key5=22", raw=split(raw,"|")|mvexpand raw|rename raw as _raw
| rex field=_raw "user=(?&amp;lt;user&amp;gt;[^,]*),ip=(?&amp;lt;ip&amp;gt;[^,]*),(?&amp;lt;keys&amp;gt;[^\n]*)"
| rex field=keys "key\d=(?&amp;lt;k&amp;gt;[^\n|,]*)" max_match=0
| stats sum(k) as key_sum by ip user&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;▄︻̷̿┻̿═━一&lt;BR /&gt;&lt;BR /&gt;If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 10:18:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-aggregate-by-extracted-fields/m-p/556963#M158178</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-06-24T10:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract and aggregate by extracted fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-aggregate-by-extracted-fields/m-p/557036#M158198</link>
      <description>&lt;P&gt;This helped me solve my use case&lt;BR /&gt;&lt;BR /&gt;Had to make a few tweaks, because my keys were Not in the format `key{number}`&lt;BR /&gt;&lt;BR /&gt;`max_match=0` is what really solved it for me&lt;BR /&gt;&lt;BR /&gt;this is how my solution looked:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SEARCH
| rex field=_raw "user=(?&amp;lt;user&amp;gt;[^,]*),ip=(?&amp;lt;ip&amp;gt;[^,]*),(?&amp;lt;metrics&amp;gt;[^\"]+)""
| rex field=metrics "(?&amp;lt;metric&amp;gt;\w+)=(?&amp;lt;m_count&amp;gt;\d+),?" max_match=0 
| stats sum(m_count) as total_counts by metric, ip user&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;thanks a lot&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 17:48:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-aggregate-by-extracted-fields/m-p/557036#M158198</guid>
      <dc:creator>ashriram</dc:creator>
      <dc:date>2021-06-24T17:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract and aggregate by extracted fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-aggregate-by-extracted-fields/m-p/557130#M158216</link>
      <description>&lt;P&gt;Cool.&lt;/P&gt;&lt;P&gt;Glad to help you.&amp;nbsp;Please accept the answer to close this question.&lt;/P&gt;&lt;P&gt;KV&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jun 2021 07:24:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-and-aggregate-by-extracted-fields/m-p/557130#M158216</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-06-25T07:24:58Z</dc:date>
    </item>
  </channel>
</rss>

