<?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: Count values from fields that may not exist in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Count-values-from-fields-that-may-not-exist/m-p/328226#M97707</link>
    <description>&lt;P&gt;Try this.  The &lt;CODE&gt;foreach&lt;/CODE&gt; command accepts wildcards, but not regular expressions.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype=mysourcetype | eval count=0 | foreach network.*.rx_bytes [eval count=count+&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;] | table count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you need to be specific about field matching, try this query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype=mysourcetype | eval count=0 | foreach network.*.rx_bytes [eval count=if(match(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,"networks.^[a-zA-Z0-9]*$.rx_bytes"),count+&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;, count)] | table count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 27 Oct 2017 12:58:32 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2017-10-27T12:58:32Z</dc:date>
    <item>
      <title>Count values from fields that may not exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-values-from-fields-that-may-not-exist/m-p/328225#M97706</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
How to sums values from fields that may not exists? I want to sums fields (if exists ) with this pattern: networks.^[a-zA-Z0-9]*$.rx_bytes&lt;/P&gt;

&lt;P&gt;For example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    index=myindex sourcetype=mysourcetype| eval count=('networks.eth0.rx_bytes' + 'networks.eth1.rx_bytes' + 'networks.eth2.rx_bytes' + 'networks.eth(n).rx_bytes' )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 11:26:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-values-from-fields-that-may-not-exist/m-p/328225#M97706</guid>
      <dc:creator>Rialf1959</dc:creator>
      <dc:date>2017-10-27T11:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: Count values from fields that may not exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-values-from-fields-that-may-not-exist/m-p/328226#M97707</link>
      <description>&lt;P&gt;Try this.  The &lt;CODE&gt;foreach&lt;/CODE&gt; command accepts wildcards, but not regular expressions.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype=mysourcetype | eval count=0 | foreach network.*.rx_bytes [eval count=count+&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;] | table count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you need to be specific about field matching, try this query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myindex sourcetype=mysourcetype | eval count=0 | foreach network.*.rx_bytes [eval count=if(match(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,"networks.^[a-zA-Z0-9]*$.rx_bytes"),count+&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;, count)] | table count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Oct 2017 12:58:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-values-from-fields-that-may-not-exist/m-p/328226#M97707</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-10-27T12:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Count values from fields that may not exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-values-from-fields-that-may-not-exist/m-p/328227#M97708</link>
      <description>&lt;P&gt;Try this!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | addtotals fieldname=count network.*.rx_bytes
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Oct 2017 13:03:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-values-from-fields-that-may-not-exist/m-p/328227#M97708</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2017-10-27T13:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: Count values from fields that may not exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-values-from-fields-that-may-not-exist/m-p/328228#M97709</link>
      <description>&lt;P&gt;Does not work.&lt;BR /&gt;
Sample data:&lt;BR /&gt;
&lt;A href="https://pastebin.com/9sRs35Z3"&gt;https://pastebin.com/9sRs35Z3&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;EDIT: ofcourse, there is typo in field name. Network vs Networks&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2017 07:39:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-values-from-fields-that-may-not-exist/m-p/328228#M97709</guid>
      <dc:creator>Rialf1959</dc:creator>
      <dc:date>2017-10-30T07:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: Count values from fields that may not exist</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-values-from-fields-that-may-not-exist/m-p/328229#M97710</link>
      <description>&lt;P&gt;Does not work.&lt;BR /&gt;
Sample data:&lt;BR /&gt;
&lt;A href="https://pastebin.com/9sRs35Z3"&gt;https://pastebin.com/9sRs35Z3&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;EDIT: ofcourse, there is typo in field name. Network vs Networks&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2017 07:39:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-values-from-fields-that-may-not-exist/m-p/328229#M97710</guid>
      <dc:creator>Rialf1959</dc:creator>
      <dc:date>2017-10-30T07:39:43Z</dc:date>
    </item>
  </channel>
</rss>

