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!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

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