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!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

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 ...