Splunk Search

How to list a count ONLY if the value within a query is above a certain threshold?

CTHolt01
New Member

Hello. Today, I have several panels in a dashboard to provide us daily, weekly, and monthly counts of certain problem areas. When it comes to one of the scripts though, I would like to only provide a count if the number is higher than 10. Below is one of the queries we currently have in place:

<panel>
  <title>Today</title>
  <table>
    <title>Kickouts for CSC</title>
    <search>
      <query>host=hfs-p2-ma-a* source=*console.log "Pinging" | stats count as Total</query>
      <earliest>@d</earliest>
      <latest>now</latest>
      <sampleRatio>1</sampleRatio>
    </search>
    <option name="count">100</option>
    <option name="list.drilldown">full</option>
    <option name="list.wrap">1</option>
    <option name="maxLines">5</option>
    <option name="raw.drilldown">none</option>
    <option name="rowNumbers">1</option>
    <option name="table.drilldown">all</option>
    <option name="table.sortDirection">asc</option>
    <option name="table.wrap">1</option>
    <option name="type">raw</option>
  </table>
</panel>

Also, below are examples of the output in splunk today in order to gather those counts:

STATUS | wrapper | main | 2018/09/06 16:47:38.283 | Pinging the JVM took 11 seconds to respond.
STATUS | wrapper | main | 2018/09/06 16:47:38.283 | Pinging the JVM took 2 seconds to respond.
STATUS | wrapper | main | 2018/09/06 16:47:10.731 | Pinging the JVM took 11 seconds to respond.
STATUS | wrapper | main | 2018/09/06 16:47:10.731 | Pinging the JVM took 2 seconds to respond.

We know that a "kick out" takes place if the Pinging takes longer than 10 seconds today. Is there a way to rewrite the query to only count if the pinging takes longer than 10 seconds or is it something where we would have to rewrite the regular expression to read something like --> Pinging the JVM took [0-9][1-9] seconds to respond.

Any help would be greatly appreciated!

-Cameron

0 Karma

horsefez
Motivator

Hi @CTHolt01,

just add the following to your base search.

| search Total>10

Should look like this:
host=hfs-p2-ma-a* source=*console.log "Pinging" | stats count as Total | search Total>10

0 Karma

horsefez
Motivator

Hi @CTHolt01,

was I able to help you with my solution?
Need any further assistance?

0 Karma

adonio
Ultra Champion

... | where count > 10

also, in general it is always better to assign a new field name to the count (or other functions).
so .... | more search ... | stats count as event_count | ... more stuff if needed ... | where event_count > 10

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...