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!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...