<?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 report on the top 10 fields when logs have a variable number of key value pairs that are numeric? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-report-on-the-top-10-fields-when-logs-have-a-variable/m-p/317197#M59277</link>
    <description>&lt;P&gt;I have log records with a variable number of KV (key value) pairs.  Both the field and the values are numeric.  The following search parses all of the log records correctly and builds a very long row of results given that there are thousands of potential key values to sum. &lt;BR /&gt;
I have a transforms.conf &amp;amp; props.conf setup  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[root@splunk local]# cat transforms.conf 
[get_rule_stat]
REGEX = ([0-9]+)=([0-9]+)
FORMAT = $1::$2
MV_ADD =true
CLEAN_KEYS = false

[get_rule_id]
REGEX =(?&amp;lt;_KEY_1&amp;gt;[0-9]+)=(?&amp;lt;_VAL_1&amp;gt;[0-9]+)
MV_ADD = true
CLEAN_KEYS = false
--------
[root@splunk local]# cat props.conf 
[ScoutShield]
KV_MODE = multi
REPORT-Stats = get_rule_stat
REPORT-R-ID = get_rule_id
---




source="qa_debug.log" host="splunk.localdomain" sourcetype="ScoutShield" 
| rex field=_raw "(?ms)(?=[^N]*(?:NetDefender Rule Hits Digest|N.*NetDefender Rule Hits Digest))^(?P[^\\[]+)[^\\]\\n]*\\]\\[(?P[^\\]]+)\\]\\[(?P\\d+)\\]\\[(?P\\d+)[^\\]\\n]*\\]\\[(?P[^\\]]+)" offset_field=_extracted_fields_bounds 
| rex field=stats max_match=100 "(?\d*=\d*)" 
|stats sum(*)  
| addtotals   fieldname=TotalHits 
| rename sum(*) as * 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I would like to do is report on the top fields (as in top 10 with largest count) or to do a timechart with only those fields where the fields belong to the top 10.&lt;BR /&gt;&lt;BR /&gt;
It seems as though I can only use &lt;CODE&gt;*&lt;/CODE&gt; for the field names, and there isn't a way to sub set the names.&lt;BR /&gt;
Any suggestions would be appreciated.&lt;/P&gt;</description>
    <pubDate>Mon, 10 Apr 2017 18:10:48 GMT</pubDate>
    <dc:creator>plynch52</dc:creator>
    <dc:date>2017-04-10T18:10:48Z</dc:date>
    <item>
      <title>How to report on the top 10 fields when logs have a variable number of key value pairs that are numeric?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-report-on-the-top-10-fields-when-logs-have-a-variable/m-p/317197#M59277</link>
      <description>&lt;P&gt;I have log records with a variable number of KV (key value) pairs.  Both the field and the values are numeric.  The following search parses all of the log records correctly and builds a very long row of results given that there are thousands of potential key values to sum. &lt;BR /&gt;
I have a transforms.conf &amp;amp; props.conf setup  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[root@splunk local]# cat transforms.conf 
[get_rule_stat]
REGEX = ([0-9]+)=([0-9]+)
FORMAT = $1::$2
MV_ADD =true
CLEAN_KEYS = false

[get_rule_id]
REGEX =(?&amp;lt;_KEY_1&amp;gt;[0-9]+)=(?&amp;lt;_VAL_1&amp;gt;[0-9]+)
MV_ADD = true
CLEAN_KEYS = false
--------
[root@splunk local]# cat props.conf 
[ScoutShield]
KV_MODE = multi
REPORT-Stats = get_rule_stat
REPORT-R-ID = get_rule_id
---




source="qa_debug.log" host="splunk.localdomain" sourcetype="ScoutShield" 
| rex field=_raw "(?ms)(?=[^N]*(?:NetDefender Rule Hits Digest|N.*NetDefender Rule Hits Digest))^(?P[^\\[]+)[^\\]\\n]*\\]\\[(?P[^\\]]+)\\]\\[(?P\\d+)\\]\\[(?P\\d+)[^\\]\\n]*\\]\\[(?P[^\\]]+)" offset_field=_extracted_fields_bounds 
| rex field=stats max_match=100 "(?\d*=\d*)" 
|stats sum(*)  
| addtotals   fieldname=TotalHits 
| rename sum(*) as * 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I would like to do is report on the top fields (as in top 10 with largest count) or to do a timechart with only those fields where the fields belong to the top 10.&lt;BR /&gt;&lt;BR /&gt;
It seems as though I can only use &lt;CODE&gt;*&lt;/CODE&gt; for the field names, and there isn't a way to sub set the names.&lt;BR /&gt;
Any suggestions would be appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 18:10:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-report-on-the-top-10-fields-when-logs-have-a-variable/m-p/317197#M59277</guid>
      <dc:creator>plynch52</dc:creator>
      <dc:date>2017-04-10T18:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to report on the top 10 fields when logs have a variable number of key value pairs that are numeric?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-report-on-the-top-10-fields-when-logs-have-a-variable/m-p/317198#M59278</link>
      <description>&lt;P&gt;Assuming your field extraction is working fine and you're getting fields with numeric names, give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | table _time 1* 2* 3* 4* 5* 6* 7* 8* 9* 0*
| untable _time fieldnames fieldvalues
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Once you get one row for each field using above search, your run searches like this&lt;/P&gt;

&lt;P&gt;Top 10 fields based on count&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...above search.. | top fieldnames 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Top 10 fields based on fieldvalues column&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...above search.. | sort 10 -fieldvalues
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Top 10 based on sum of fieldvalues&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...above search.. | stats sum(fieldvalues) as fieldvalues by fieldnames | sort 10 -fieldvalues
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Apr 2017 18:50:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-report-on-the-top-10-fields-when-logs-have-a-variable/m-p/317198#M59278</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-04-10T18:50:54Z</dc:date>
    </item>
  </channel>
</rss>

