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!

Technical Workshop Series: Splunk Data Management and SPL2 | Register here!

Hey, Splunk Community! Ready to take your data management skills to the next level? Join us for a 3-part ...

Spotting Financial Fraud in the Haystack: A Guide to Behavioral Analytics with Splunk

In today's digital financial ecosystem, security teams face an unprecedented challenge. The sheer volume of ...

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability As businesses scale ...