Splunk Search

Need to pull the Top 100 Hosts License Usage In Splunk Cloud

anandhalagaras1
Contributor

Need to pull the License Usage in GB for the top 100 Host along with their respective Index Source and Souretype information on monthly basis for reports.

So kindly help with the query. 

0 Karma

gcasaldi
Explorer

try like this (select time range from the search):

index=_internal source=*license_usage.log type="Usage"
| stats sum(b) as totalBytes by host, index, source, sourcetype
| eval host=lower(host)
| eval MB=totalBytes/1024/1024
| eval GB=round(MB/1024,2)
| sort - GB
| head 100
| table host index source sourcetype GB


Let me know 🙂 
Best,

Giulia

0 Karma

anandhalagaras1
Contributor

@gcasaldi 

Here it just pulls the cluster master server information with GB when I ran the query for last month and not any other results. Refer screenshot for reference.

anandhalagaras1_1-1718010111530.png

 

0 Karma

gcasaldi
Explorer

right, change the index, for license:

index=summary 
| stats sum(b) as totalBytes by host, index, source, sourcetype
| eval host=lower(host)
| eval MB=totalBytes/1024/1024
| eval GB=round(MB/1024,2)
| sort - GB
| head 100
| table host index source sourcetype GB



Best,

Giulia

0 Karma

anandhalagaras1
Contributor

@gcasaldi Now also i am getting the hostname of Clustermaster and not the client machine information.

anandhalagaras1_0-1718014204161.png

 

I need to get the top 100 client machines with their respective index source and sourcetype information 

0 Karma

gcasaldi
Explorer

You can achieve this by leveraging internal indexes and configuring a report. Here's how:

Search Query below

This search query retrieves license usage data by host for a specific time range:

index=_internal source=*license_usage.log type="Usage" | eval host=lower(host) # Standardize hostname (optional) | eval MB=b/1024/1024 # Convert bytes to Megabytes | eval GB=round(MB/1024,2) # Convert Megabytes to Gigabytes (round to 2 decimals) | search earliest=-1mo@d latest=now@d # Adjust timeframe as needed (e.g., -3mo@d for past 3 months) | sort - GB # Sort by license usage in descending order | head 100 # Limit results to top 100 hosts | table host GB source sourcetype
0 Karma

anandhalagaras1
Contributor

@gcasaldi ,

Thank you for your prompt response. For example, I want to pull the report for the entire month of May (from May 1st to May 31st, 2024) for the top 100 hosts by license usage, along with their index, host, source, and sourcetype. I used the following query:


index=_internal source=*license_usage.log type="Usage" | eval host=lower(host) | eval MB=b/1024/1024 | eval GB=round(MB/1024,2) | search earliest=-1mo@d latest=now@d | sort - GB | head 100 | table host index source sourcetype GB
```

However, the query seems to be running continuously and does not produce any results. It is still running when I search for the previous month in the Search and Reporting app. Could you please let me know where I might have made a mistake?

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!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...