Splunk Search

Percentage in the return of a query about values ​​()

mseffrin
Engager

In the manual we have:

sourcetype=access_* action=purchase 
[search sourcetype=access_* action=purchase | top limit=1 clientip | table clientip] | 
stats count, values(product_id) as product_id by clientip | 
rename count AS "How much did he buy?", product_id AS "What did he buy?", clientip AS "VIP Customer"

If I need know de percentage of each product_id? What can I do?

Tags (2)
0 Karma

lguinn2
Legend

Will this work for you?

sourcetype=access_* action=purchase 
[search sourcetype=access_* action=purchase | top limit=1 clientip | fields clientip] | 
stats count by clientip product_id | eventstats sum(count) as totalPurchased |
eval Percentage = round(count*100/totalPurchased,1) |
table clientip product_id count Percentage |
rename count AS "How much did he buy?", product_id AS "What did he buy?", clientip AS "VIP Customer"
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...