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!

Preparing your Splunk Environment for OpenSSL3

The Splunk platform will transition to OpenSSL version 3 in a future release. Actions are required to prepare ...

Unleash Unified Security and Observability with Splunk Cloud Platform

     Now Available on Microsoft AzureThursday, March 27, 2025  |  11AM PST / 2PM EST | Register NowStep boldly ...

Splunk AppDynamics with Cisco Secure Application

Web applications unfortunately present a target rich environment for security vulnerabilities and attacks. ...