Splunk Search

How to write a search that divides values in two distinct tables?

nmsaraujo
Explorer

Hello all,

 

I have a scenario where I need to make calculations regarding license consumed, per host. However, since in the license_usage log, host value was squashed and I can not fix it for past events.

 

My theory to calculate average license consumption per host is:
1 - Calculate license used per index, per day

 

index=_internal source="*license_usage.log" component=LicenseUsage type=usage (idx=set1_*)
| timechart useother=false limit=100 span=1d sum(b) by idx
| fillnull value=0

 



Output Example for daily license consumption:

Date set1_index1 set1_index2 set1_index3
22-02-2022 345 354 343
21-02-2022 3463 3463 234

 

2 - Calculate the distinct number of hosts in each index, using tstats:

 

| tstats values(host) as hosts, dc(host) as total_hosts where (index=set1_*) by _time,index
| timechart useother=false limit=100 span=1d max(total_hosts) as "TotalHosts" by index
| fillnull value=0

 

Output Example for number of hosts per index:

Date set1_index1 set1_index2 set1_index3
22-02-2022 2 6 4
21-02-2022 4 1 2

 

ISSUE: The name of the columns is not static. I can only use a prefix, defined in the index naming conventions.

 

Objective:

If I am able to divide the daily license consumption by the number of hosts, I have the average consumption per host.

Doe any of you can help me find how I made divide the values in the first query by the ones in the second query, geting a similar output to the table below?

Date set1_index1 set1_index2 set1_index3
22-02-2022 172,5 59 85,75
21-02-2022 865,75 3463 117

 

 

Thanks in advance for your help on this issue.

 

 

Labels (2)
0 Karma
Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...