0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Splunk マルチバリューの外れ値を削除する

Posted at

https://community.splunk.com/t5/Reporting/replacing-large-numeric-values-with-0/m-p/507054
でやったことのまとめ

課題

multivalue.spl
| makeresults 
| eval _raw="xTemp_wl0
48
50
43
60
60
54
61
60
1161181233
43
60
49"
| multikv forceheader=1
| stats list(xTemp_wl0) as xTemp_wl0
xTemp_wl0
48
50
43
60
60
54
61
60
1161181233
43
60
49
このような一つだけとても大きい数があるマルチバリューの平均を出したい
そのままavg()すると大きな値になるので、外れ値を除外、にしたい
という課題でした。

mvmap

mvmap.spl
| makeresults 
| eval _raw="xTemp_wl0
48
50
43
60
60
54
61
60
1161181233
43
60
49"
| multikv forceheader=1
| stats list(xTemp_wl0) as xTemp_wl0
| stats avg(eval(mvmap(xTemp_wl0,if(xTemp_wl0>100,0,xTemp_wl0)))) as average
average
49
Splunk ver 8以降でつかえるmvmapを使用するとこんな感じ
やってることはevalifの評価なのでわかりやすい

rex

rex.spl
| makeresults 
| eval _raw="xTemp_wl0
48
50
43
60
60
54
61
60
1161181233
43
60
49"
| multikv forceheader=1
| stats list(xTemp_wl0) as xTemp_wl0
| rex mode=sed field=xTemp_wl0 "s/\d{3,}/0/g"
| stats avg(xTemp_wl0) as average
average
49

rexはマルチバリューでも普通に使えるので、正規表現\d{3,}で三桁以上の数字を0にしている。

まとめ

:sweat: 小ネタばかりだな

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?