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!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...