smooth
smooth operator は、フィールドの移動平均を計算し、値の平均を測定してランダムな変動を「平滑化」します。Smooth operator を使用して、クエリ内のデータ セットの傾向を把握できます。
smooth operator を含むクエリでは、ウィンドウを (下記の構文で説明されている window_length で) 選択すると、そのウィンドウ内での値の平均によってデータ ポイントが作成されます。
ウィンドウ長を 5 に指定したのに使用できるデータ ポイントが 4 つしかない場合、smooth operator は利用できるデータを活用します。
smooth operator を使用したクエリに group by 関数を追加することで、各グループの現在の平均が (各グループが別々に計算したデータから) 生成されます。
構文
smooth <field> [, <window length>] [as <field>]
ルール
- smooth のエイリアスは省略可能です。エイリアスを指定しないと、_smooth がデフォルトで使用されます。
- 指定されるフィールドには数値が含まれている必要があります。
- smooth operator を含むクエリをダッシュボードに追加する場合は、smooth operator の前に group by 関数を指定する必要があります。
- デフォルトのウィンドウ長は 10 です。
- 最大のウィンドウ長は 1000 です。
例
smooth を使用して Source ホストごとにグループ化された時間ポイント間でフィールドの差を確認
次のようなクエリを実行した場合:
_sourcecategory=katta
| timeslice by 1m
| count by _timeslice,_sourcehost
| sort + _timeslice
| smooth _count,1 by _sourcehost
結果は次のようになります。
時間ポイント間の分量の差の平滑化
smooth でタイムスライスを使用して、次のようなクエリを実行すると:
* | parse "bytes transmitted: '*'" as bytes
| timeslice 1m
| sum(bytes) as bytes by _timeslice
| sort _timeslice
| smooth bytes, 5
結果は次のようになります。
backshift を smooth および rollingstd と一緒に使用して受信バイトの平均を表示
次のようなクエリを実行した場合:
...| timeslice by 1m
| avg(oneMinuteRate) as avgRateByHost by _sourcehost,_timeslice
| sum(avgratebyhost) as totalIncomingRate by _timeslice
| sort + _timeslice
| backshift totalIncomingRate, 1 as lagRate
| smooth lagRate,10 as movingAvg
| rollingstd lagRate,10 as rollingStd
| movingAvg + (3 * rollingStd) as upper
| movingAvg - (3 * rollingStd) as lower
次のような結果が返されます。
ウィンドウ長を 5 に指定したのに使用できるデータ ポイントが 4 つしかない場合
値が 5 つ揃う前に、smooth operator は利用できるデータを活用します。例:
_sourcecategory=katta
| timeslice by 1m
| count by _timeslice,_sourcehost
| where _sourcehost="nite-katta-cold-4"
| sort + _timeslice
| smooth _count,5
結果は次のようになります。