<?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 perform stats on large number of fields matching a certain pattern without doing stats on each one individual in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-stats-on-large-number-of-fields-matching-a/m-p/607653#M211293</link>
    <description>&lt;P&gt;Yes, that's the approach I would take, but haven't tested it.&lt;/P&gt;</description>
    <pubDate>Sun, 31 Jul 2022 13:52:33 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2022-07-31T13:52:33Z</dc:date>
    <item>
      <title>How to perform stats on large number of fields matching a certain pattern without doing stats on each one individually?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-stats-on-large-number-of-fields-matching-a/m-p/607627#M211282</link>
      <description>&lt;P&gt;How do I perform stats on a large number of fields matching a certain pattern without doing stats on each one individually? In a sample event below, there are 10+ fields with names beginning with "er_". My task is to fire an alert if any of the values in these fields increases from the previous event.&lt;/P&gt;
&lt;P&gt;Sample event:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;   er_bad_eof: 0
   er_bad_os: 0
   er_crc: 0
   er_crc_good_eof: 0
   er_enc_in: 0
   er_enc_out: 0
   er_inv_arb: 0
   er_lun_zone_miss: 0
   er_multi_credit_loss: 0
   er_other_discard: 11
   er_pcs_blk: 0
   er_rx_c3_timeout: 0
   er_single_credit_loss: 0
   er_toolong: 0
   er_trunc: 0
   er_tx_c3_timeout: 0
   er_type1_miss: 0
   er_type2_miss: 0
   er_type6_miss: 0
   er_unreachable: 0
   er_unroutable: 11
   er_zone_miss: 0
   lgc_stats_clear_ts: Never
   phy_stats_clear_ts: Never
   port_description: slot12 port46
   port_name: 382&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SPL where I run stats on just two of those fields and where the "er_..._delta" values will be used to fire an alert if they're &amp;gt; 0:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;index="sandbox" source="HEC"

| stats count AS events,
        min(er_enc_out) AS er_enc_out_min,
        max(er_enc_out) AS er_enc_out_max,
        min(er_other_discard) AS er_other_discard_min,
        max(er_other_discard) AS er_other_discard_max,
        by host port_name, port_description
| eval er_enc_out_delta = er_enc_out_max-er_enc_out_min,
       er_other_discard_delta = er_other_discard_max - er_other_discard_min
| sort -er_enc_out_delta -er_other_discard_delta -er_enc_out_max -er_other_discard_max port_name&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I run similar stats on &lt;EM&gt;all&lt;/EM&gt; fields with names beginning with "er_"?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jul 2022 23:55:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-stats-on-large-number-of-fields-matching-a/m-p/607627#M211282</guid>
      <dc:creator>mitag</dc:creator>
      <dc:date>2022-07-30T23:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform stats on large number of fields matching a certain pattern without doing stats on each one individual</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-stats-on-large-number-of-fields-matching-a/m-p/607628#M211283</link>
      <description>&lt;P&gt;You can use wildcards in &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats max(er_*) as er_*_max&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jul 2022 23:59:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-stats-on-large-number-of-fields-matching-a/m-p/607628#M211283</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-07-30T23:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform stats on large number of fields matching a certain pattern without doing stats on each one individual</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-stats-on-large-number-of-fields-matching-a/m-p/607629#M211284</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;&lt;STRIKE&gt;What about evaluating the delta (max - min)? Wildcards don't seem to work there.&lt;/STRIKE&gt;&amp;nbsp;(Never mind this - sounds like I'd just use the &lt;FONT face="andale mono,times"&gt;range&lt;/FONT&gt; stats function.)&lt;/P&gt;&lt;P&gt;To fire an alert, I'd need to eval the condition of &lt;FONT face="andale mono,times" color="#993300"&gt;range(er_*) &amp;gt; 0&lt;/FONT&gt;&amp;nbsp;and then expose the offending fields. Yet the&amp;nbsp;&lt;FONT face="andale mono,times" color="#993300"&gt;search er_*_range &amp;gt; 0&lt;/FONT&gt;&amp;nbsp;part in the below doesn't seem to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| stats count AS events,
        min(er_*) AS er_*_min,
        max(er_*) AS er_*_max,
        range(er_*) AS er_*_range,
        by host port_name, port_description
| fields host port_name port_description events er_*_range 
| search er_*_range &amp;gt; 0
| sort -er_*_range port_name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I do this? (Check if any of the&amp;nbsp;&lt;FONT face="andale mono,times" color="#993300"&gt;er_*_range&lt;/FONT&gt;&amp;nbsp;field values are positive?) Something like this?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| stats count AS events,
        range(er_*) AS er_*_range,
        by host port_name, port_description

| foreach er_*_range 
    [eval item='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;']
| where item != 0 

| fields host port_name port_description events er_*_range 

| sort -er_*_range port_name&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 31 Jul 2022 01:42:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-stats-on-large-number-of-fields-matching-a/m-p/607629#M211284</guid>
      <dc:creator>mitag</dc:creator>
      <dc:date>2022-07-31T01:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform stats on large number of fields matching a certain pattern without doing stats on each one individual</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-perform-stats-on-large-number-of-fields-matching-a/m-p/607653#M211293</link>
      <description>&lt;P&gt;Yes, that's the approach I would take, but haven't tested it.&lt;/P&gt;</description>
      <pubDate>Sun, 31 Jul 2022 13:52:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-perform-stats-on-large-number-of-fields-matching-a/m-p/607653#M211293</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-07-31T13:52:33Z</dc:date>
    </item>
  </channel>
</rss>

