Splunk Search

上位XX位とその他の合計値の集計について

clio706
Explorer

お世話になります。

集計のサーチ文の書き方についてご教示ください。

やりたいことは下記の通りです。

・販売数で集計し、Top3を出力する。
・その他は合計して集計する。
・販売数で集計した結果に、商品名をキーとして割引販売数の集計値をマージする。

出力イメージは以下の通りです。

商品名販売数
aaa300
aaa400
aaa500
bbb300
ccc200
ccc300
ccc500
ddd100
ddd100
eee800

 

商品名割引販売数
aaa100
aaa50
aaa200
bbb200
ccc10
ccc200
ccc100
ddd20
ddd50
eee100

 

集計後イメージ

商品名販売数割引販売数
aaa1200350
ccc1000310
eee800100
その他500270

 

宜しくお願い致します。

Labels (2)
Tags (1)
0 Karma

thambisetty
SplunkTrust
SplunkTrust
index=yourindex 
| stats sum("Number of sales") as sum_Number_of_sales by "Product name"
| append [search index=yourindex 
| stats sum("Discount sales") as sum_Discount_sales by "Product name"]
| stats values(*) as * by "Product name"
| sort - sum_Number_of_sales
————————————
If this helps, give a like below.

clio706
Explorer

Thank you for your comment.
I tried it, but I couldn't aggregate other total values.
Let's consider a little more with reference to the SPL you received.

0 Karma
Get Updates on the Splunk Community!

Get Schooled with Splunk Education: Explore Our Latest Courses

At Splunk Education, we’re dedicated to providing incredible learning experiences that cater to every skill ...

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL  The Splunk AI Assistant for SPL ...

Buttercup Games: Further Dashboarding Techniques (Part 5)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...