0
0

streamstatsを使ってみた

Posted at

Splunk Version 9.2.1(Free_無課金)

streamstatsは、イベント1つずつを参照して集計していく。

集計対象がどのイベントか分かりにくい時があるので、
そういう時はvalues(field名) を使うと、対象イベントが見やすい。

image.png

window=xx (default 0) について

window=2 で集計するとこんな感じ。
注意点として、1回目の処理は window=2 にしても1つ目のデータしか参照しない。
処理対象は、(対象データ + 前のデータ) らしい。

image.png

後のデータを、前のデータに持ってきたい場合は、
一旦「sort - 」で降順にして集計後、「sort」しなおす必要がある。多少面倒
 ※sortは 0 を付けないと、10000件までしか結果反映してくれないので注意。

image.png

SPL例

qiita.rb
| makeresults format=csv
data="my_cnt,my_group,my_data
1,g1,g1-aaa
2,g1,g1-bbb
3,g1,g1-ccc
4,g1,g1-ddd"
| table my_cnt my_group my_data

| sort - 0 my_cnt
| streamstats window=2 current=t first(my_data)
| sort 0 my_cnt

他の引数も、時間があるとき追記します。

公式URL

記事終了

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0