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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...