<?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 Stats command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Stats-command/m-p/709450#M239784</link>
    <description>&lt;P&gt;I am trying to get total traffic vs attack traffic splunk query in order to keep it in dashboard panel.&lt;/P&gt;
&lt;P&gt;We have a field called attack_type which contains all the attacks and those will be dynamic (daily new ones will be coming).&lt;/P&gt;
&lt;P&gt;For last 24 hours, we have 1000 total events and 400 attack_type events.&lt;/P&gt;
&lt;P&gt;how can I show this in single dashboard panel:&lt;/P&gt;
&lt;P&gt;tried to write this query:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=* *jupiter* | stats count as "Total Traffic" count(eval(attack_type="*")) as "Attack Traffic"&lt;/LI-CODE&gt;
&lt;P&gt;but getting this error:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Error in 'stats' command: The eval expression for dynamic field 'attack_type=*' is invalid. Error='The expression is malformed. An unexpected character is reached at '*'.'.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;please help me in this regards.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jan 2025 17:35:50 GMT</pubDate>
    <dc:creator>Karthikeya</dc:creator>
    <dc:date>2025-01-22T17:35:50Z</dc:date>
    <item>
      <title>Stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-command/m-p/709450#M239784</link>
      <description>&lt;P&gt;I am trying to get total traffic vs attack traffic splunk query in order to keep it in dashboard panel.&lt;/P&gt;
&lt;P&gt;We have a field called attack_type which contains all the attacks and those will be dynamic (daily new ones will be coming).&lt;/P&gt;
&lt;P&gt;For last 24 hours, we have 1000 total events and 400 attack_type events.&lt;/P&gt;
&lt;P&gt;how can I show this in single dashboard panel:&lt;/P&gt;
&lt;P&gt;tried to write this query:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=* *jupiter* | stats count as "Total Traffic" count(eval(attack_type="*")) as "Attack Traffic"&lt;/LI-CODE&gt;
&lt;P&gt;but getting this error:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Error in 'stats' command: The eval expression for dynamic field 'attack_type=*' is invalid. Error='The expression is malformed. An unexpected character is reached at '*'.'.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;please help me in this regards.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 17:35:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-command/m-p/709450#M239784</guid>
      <dc:creator>Karthikeya</dc:creator>
      <dc:date>2025-01-22T17:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-command/m-p/709451#M239785</link>
      <description>&lt;P&gt;Wildcards don't work everywhere and the &lt;FONT face="courier new,courier"&gt;eval&lt;/FONT&gt; function may be one of those places.&amp;nbsp; Try using &lt;FONT face="courier new,courier"&gt;isnotnull()&lt;/FONT&gt;, instead.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* *jupiter* 
| stats count as "Total Traffic" count(eval(isnotnull(attack_type))) as "Attack Traffic"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;On the subject of wildcards, avoid using &lt;FONT face="courier new,courier"&gt;index=*&lt;/FONT&gt;, except in special circumstances.&amp;nbsp; Also, a leading wildcard in the search command (as in "*jupiter*") is very inefficient.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 13:20:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-command/m-p/709451#M239785</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2025-01-22T13:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: Stats command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-command/m-p/709470#M239792</link>
      <description>&lt;P&gt;You probably wanted to do something like&lt;/P&gt;&lt;PRE&gt;stats count(eval(isnotnull(attack_type)))&lt;/PRE&gt;&lt;P&gt;I must say though that I don't like the stats eval syntax - it can be confusing. I prefer to do stuff explicitly. Like this:&lt;/P&gt;&lt;PRE&gt;| eval isattack=if(isnotnull(attack_type),1,0)&lt;BR /&gt;| stats sum(attack_type)&lt;/PRE&gt;&lt;P&gt;PS: Oh, and don't search across all your indexes. While it might work relatively not that bad on some small deployments or for a user with very limited permissions, it's a very bad habit which doesn't scale well. And don't use wildcards at the beginning of your search term (like *juniper*).&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 15:02:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-command/m-p/709470#M239792</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-01-22T15:02:03Z</dc:date>
    </item>
  </channel>
</rss>

