Splunk Search

How to create a conditional search if license usage is above 80%, then show top 10 hosts?

fli
Explorer

There is default license alert when license usage is greater 80%, then you will get email notification. The alert is like

" | rest splunk_server=local /services/licenser/pools | rename title AS Pool | search [rest splunk_server=local /services/licenser/groups | search is_active=1 | eval stack_id=stack_ids | fields stack_id] | eval quota=if(isnull(effective_quota),quota,effective_quota) | eval "% used"=round(used_bytes/quota*100,2) | fields Pool "% used" | where '% used' > 80 "

Is there possible to create another alert that if the license usage is greater 80%, then sent the alert along with the top 10 usage hosts?

it's like the conditional search.

0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try

| rest splunk_server=local /services/licenser/pools | rename title AS Pool | search [rest splunk_server=local /services/licenser/groups | search is_active=1 | eval stack_id=stack_ids | fields stack_id] | eval quota=if(isnull(effective_quota),quota,effective_quota) | eval "% used"=round(used_bytes/quota*100,2) | fields Pool "% used" | where '% used' > 80 | map search="search index=_internal sourcetype=splunkd source=*license_usage.log type=Usage earliest=@d | stats sum(b) as usage by h | eval usage=round(usage/1024/1024/1024,3) | sort 10 -usage"

View solution in original post

0 Karma

somesoni2
Revered Legend

Give this a try

| rest splunk_server=local /services/licenser/pools | rename title AS Pool | search [rest splunk_server=local /services/licenser/groups | search is_active=1 | eval stack_id=stack_ids | fields stack_id] | eval quota=if(isnull(effective_quota),quota,effective_quota) | eval "% used"=round(used_bytes/quota*100,2) | fields Pool "% used" | where '% used' > 80 | map search="search index=_internal sourcetype=splunkd source=*license_usage.log type=Usage earliest=@d | stats sum(b) as usage by h | eval usage=round(usage/1024/1024/1024,3) | sort 10 -usage"
0 Karma

fli
Explorer

thanks somesoni2, it works!!

0 Karma

DalJeanis
Legend

@somesoni2 - I'm thinking that the original search could result in multiple records (one for each licenser pool above 80% usage with an active stack_id). Any way to pull top 10 usage hosts in each Pool?

0 Karma
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf24, and Community Connections

Thank you to everyone in the Splunk Community who joined us for .conf24 – starting with Splunk University and ...

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

 (view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...