Splunk Search

License Usage Calculation for a Particular Event ID

anandhalagaras1
Communicator

Hi Team,

I want to find the license usage in GB for last 30 days for a particular Event ID for index=wineventlog so kindly help with the query.

The fields are:

EventCode=4688

index=wineventlog

sourcetype=winlog

 

Labels (1)
0 Karma
1 Solution

nickhills
Ultra Champion

First, a correction. In my final query I should have removed "earliest=-24h latest=now" Please run the query again without those time constraints. (I have updated the original post)

Second, did you set a value for X? If you don't use sampling then ratio should be "ratio=1", if you used a 1:100,000 sampling ratio, then "ratio=100000"

Next, as I mentioned, Splunk measures volume licence against sourcetypes. It does not break licence usage down on a per field basis, hence the reason for the estimated calculation I have provided above.

If you want daily consumption, you can make a simple change to produce these values for each day.

index=wineventlog sourcetype=winlog EventCode=4688
| eval bytes=len(_raw)
| timechart avg(bytes) as avg_bytes count span=1d
| eval ratio=10000
| eval consumptionBytes=((avg_bytes*count)*ratio)
| eval consumptionKB=((avg_bytes*count)*ratio)/1024
| eval consumptionMB=((avg_bytes*count)*ratio)/1024/1024
| eval consumptionGB=((avg_bytes*count)*ratio)/1024/1024/1024

 

If my comment helps, please give it a thumbs up!

View solution in original post

nickhills
Ultra Champion

Did you set ratio to match the search sample ratio?

I am guessing you are not using sampling, so set the ratio=1

If my comment helps, please give it a thumbs up!

anandhalagaras1
Communicator

@nickhills 

Thank you. I have changed the ratio to 1 in the query post which I can see the exact License consumption size in GB for EventCode=4688. 

 

Thanks for your help.

0 Karma

nickhills
Ultra Champion

First, a correction. In my final query I should have removed "earliest=-24h latest=now" Please run the query again without those time constraints. (I have updated the original post)

Second, did you set a value for X? If you don't use sampling then ratio should be "ratio=1", if you used a 1:100,000 sampling ratio, then "ratio=100000"

Next, as I mentioned, Splunk measures volume licence against sourcetypes. It does not break licence usage down on a per field basis, hence the reason for the estimated calculation I have provided above.

If you want daily consumption, you can make a simple change to produce these values for each day.

index=wineventlog sourcetype=winlog EventCode=4688
| eval bytes=len(_raw)
| timechart avg(bytes) as avg_bytes count span=1d
| eval ratio=10000
| eval consumptionBytes=((avg_bytes*count)*ratio)
| eval consumptionKB=((avg_bytes*count)*ratio)/1024
| eval consumptionMB=((avg_bytes*count)*ratio)/1024/1024
| eval consumptionGB=((avg_bytes*count)*ratio)/1024/1024/1024

 

If my comment helps, please give it a thumbs up!

anandhalagaras1
Communicator

So when i searched using the following query for Last 4 Days.

index=wineventlog sourcetype=winlog EventCode=4688
| eval bytes=len(_raw)
| timechart avg(bytes) as avg_bytes count span=1d
| eval ratio=10000
| eval consumptionBytes=((avg_bytes*count)*ratio)
| eval consumptionKB=((avg_bytes*count)*ratio)/1024
| eval consumptionMB=((avg_bytes*count)*ratio)/1024/1024
| eval consumptionGB=((avg_bytes*count)*ratio)/1024/1024/1024

 

I can see that the data has been split up into following fields but when i checked the consumption in GB it states some irrelevant value since we have opted for 150 GB of overall licensing per day. But here in this case the 5093.016298 GB value seems to be odd.

Not sure what is the mistake which i have done. So is there any possibility to pull the license usage for the EventCode=4688 in GB for last 30 days.

 

_timeavg_bytes                count consumptionBytes  consumptionGBconsumptionKB        consumptionMB        ratio
12/11/2020845.35369666468995.46858E+125093.01629853404146585215248.6910000
12/12/2020861.212207233006192.84253E+1326473.1552775911498027108510.7210000
12/13/2020862.27155933680602.90418E+1327047.305812836115573227696441.1410000
12/14/2020858.471537533381612.86572E+1326689.061952798550982427329599.4410000
12/15/2020857.614470529679602.54537E+1323705.562992485708441424274496.510000
0 Karma

s2_splunk
Splunk Employee
Splunk Employee

You set ratio=10000 in your search. Did you follow @nickhills  advice and select the corresponding sampling ratio when running the search (it doesn't look like you did, hence the 10000x consumption numbers):

Screen Shot 2020-12-15 at 10.24.56 AM.png

0 Karma

nickhills
Ultra Champion

Splunk does not record licence consumption per event but you can make a good guess on this yourself.

Build a search which includes your events, and calculate the size in bytes of each event over 24 hours

 

index=wineventlog sourcetype=winlog EventCode=4688 earliest=-24h latest=now|eval bytes=len(_raw)

 

 Splunk uses UTF-8, so its 8bits, 1 byte per character.

Each event will be slightly different with varying hostnames and other parameters etc so calculate an average.

 

|stats avg(bytes) as avg_bytes

 

 

Now you need to know how many events there have been - I presume its a lot - a.) because you are asking, and b.) because 4688 is common and noisy!

You could run a |stats count over 30 days, but that may take some time. (Im also working on the assumption you don't have an accelerated datamodel for this)

This is a good use case for a sampled search, set a sample rate that matches your dataset. 1:10,000 or 1:100,000 is probably the ballpark.

To calculate the volume, you need to multiply the number of events the samples search returns by the avg_bytes and then multiply that by the ratio you choose.

 

So the complete search would be:

 

index=wineventlog sourcetype=winlog EventCode=4688
| eval bytes=len(_raw) 
| stats avg(bytes) as avg_bytes count 
| eval ratio=10000 
| eval consumptionBytes=((avg_bytes*count)*ratio) 
| eval consumptionKB=((avg_bytes*count)*ratio)/1024 
| eval consumptionMB=((avg_bytes*count)*ratio)/1024/1024 
| eval consumptionGB=((avg_bytes*count)*ratio)/1024/1024/1024

 

 remember to set "|eval ratio=x" to the sample ratio you use for the search

If my comment helps, please give it a thumbs up!

anandhalagaras1
Communicator

Thank you for your swift response.

I  believe that we can able to calculate the license usage in GB per day based on the internal logs. So I used the following query and I can able to see the license usage in GB for the specific sourcetype "winlog"

index="_internal" source="*license_usage.log" type=Usage st=winlog | bin _time span=1d | stats sum(b) AS bytes by _time,st | eval DailyGB=round (bytes/1024/1024/1024, 3) | timechart sum(DailyGB) by st span=1d limit=0 |sort - _time

So how to modify the same query i.e. I want to additionally include the EventCode=4688 so that it will calculate and pull the exact license usage for the sourcetype=winlog & EventCode=4688.

So kindly help with the query.

Also when i ran the query which you have provided for last 7 days.

index=wineventlog sourcetype=winlog EventCode=4688 earliest=-24h latest=now
| eval bytes=len(_raw)
| stats avg(bytes) as avg_bytes count
| eval ratio=x
| eval consumptionBytes=((avg_bytes*count)*ratio)
| eval consumptionKB=((avg_bytes*count)*ratio)/1024
| eval consumptionMB=((avg_bytes*count)*ratio)/1024/1024
| eval consumptionGB=((avg_bytes*count)*ratio)/1024/1024/1024

I can see two fields in the stats avg_bytes and count.

But I want the daily license usage stats for the sourcetype=winlog EventCode=4688 for past 30 days.

 

So kindly help on the same.

0 Karma

harishsplunk7
Explorer

I am looking to find out the license usage for particular dataset in events. Please let me know if any clue. 

index=aws sourcetype=aws accoutn=123456 

 

0 Karma

KHJean
Moderator
Moderator

Hi @harishsplunk7 ,

 

I’m a Community Moderator in the Splunk Community. 
This question was posted 3 years ago, so it might not get the attention you need for your question to be answered. We recommend that you post a new question so that your issue can get the  visibility it deserves. To increase your chances of getting help from the community, follow these guidelines in the Splunk Answers User Manual when creating your post.
 

Thank you!

0 Karma

PickleRick
SplunkTrust
SplunkTrust

1. Usually starting a new thread instead of digging up an old one (possibly posting a link to the old one for reference) yields bigger chance of getting reasonable results.

2. As you've already read, Splunk does measure only general license usage as well as split by index or sourcetype. But not much more. So you have to either count it yourself by measuring the aggregate data size (which can be very costly) or estimate it by sampling as showed in this thread.

3. License measurement might or might not make sense in context of datasets since datasets can be defined in various way. In general - datasets as such don't consume license. Only the events that dataset is based on have already consumed the license. But this is in no way an "exclusive count" - the same events can be used to for example Network Traffic and Network Sessions datamodels. So it's not really clear what you need.

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...