Reporting

サーチ内のサブサーチの実行順の制御

KagotaniMasato
Explorer

サブサーチがメインサーチよりも先に完了してしまい本来の計数と異なる値が返されます

具体的には

index=AAA | stats dc(field_1) as cnt_by_field_2 by field_2
| eval fill_total = [search index=AAA | stats dc(field_1) as total_cnt | return $total_cnt]

とした場合、「fill_total」は「cnt_by_field_2 」の合計値であってもらいたいのですがfill_totalを求めるためのサブサーチの途中結果しかfill_totalに代入されません。 サブサーチを単独で実行した場合の値とも異なります。 サブサーチが確実に完了した後にfill_totalに代入されるように制御することは可能でしょうか?

KagotaniMasato
Explorer

同じ結果を得ることができました。 ありがとうございました

0 Karma

Suda
Communicator

eventstatsコマンドを使う事で、サブサーチなどを使わずに期待結果を取得できると思います。ぜひ、ご確認ください。

index=AAA 
| stats dc(field_1) as cnt_by_field_2 by field_2
| eventstats sum(cnt_by_field_2) AS fill_total

eventstatsは、統計処理を行う元の情報を残したまま、統計処理結果を追加して表示できます。

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...