日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

SLS机器学习最佳实战:批量时序异常检测

發布時間:2024/8/23 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SLS机器学习最佳实战:批量时序异常检测 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

0.文章系列鏈接

  • SLS機器學習介紹(01):時序統計建模
  • SLS機器學習介紹(02):時序聚類建模
  • SLS機器學習介紹(03):時序異常檢測建模
  • SLS機器學習介紹(04):規則模式挖掘
  • SLS機器學習介紹(05):時間序列預測

  • 一眼看盡上億日志-SLS智能聚類(LogReduce)發布
  • SLS機器學習最佳實戰:時序異常檢測和報警
  • SLS機器學習最佳實戰:時序預測
  • SLS機器學習最佳實戰:日志聚類+異常告警

1. 高頻檢測場景

1.1 場景一

集群中有N臺機器,每臺機器中有M個時序指標(CPU、內存、IO、流量等),若單獨的針對每條時序曲線做建模,要手寫太多重復的SQL,且對平臺的計算消耗特別大。該如何更好的應用SQL實現上述的場景需求?

1.2 場景二

針對系統中的N條時序曲線進行異常檢測后,有要如何快速知道:這其中有哪些時序曲線是有異常的呢?

2. 平臺實驗

2.1 解決一

針對場景一中描述的問題,我們給出如下的數據約束。其中數據在日志服務的LogStore中按照如下結構存儲:

timestamp : unix_time_stamp machine: name1 metricName: cpu0 metricValue: 50 --- timestamp : unix_time_stamp machine: name1 metricName: cpu1 metricValue: 50 --- timestamp : unix_time_stamp machine: name1 metricName: mem metricValue: 50 --- timestamp : unix_time_stamp machine: name2 metricName: mem metricValue: 60

在上述的LogStore中我們先獲取N個指標的時序信息:

* | select timestamp - timestamp % 60 as time, machine, metricName, avg(metricValue) from log group by time, machine, metricName

現在我們針對上述結果做批量的時序異常檢測算法,并得到N個指標的檢測結果:

* | select machine, metricName, ts_predicate_aram(time, value, 5, 1, 1) as res from ( selecttimestamp - timestamp % 60 as time, machine, metricName, avg(metricValue) as valuefrom log group by time, machine, metricName ) group by machine, metricName

通過上述SQL,我們得到的結果的結構如下

| machine | metricName | [[time, src, pred, upper, lower, prob]] | | ------- | ---------- | --------------------------------------- |

針對上述結果,我們利用矩陣轉置操作,將結果轉換成如下格式,具體的SQL如下:

* | select machine, metricName, res[1] as ts, res[2] as ds, res[3] as preds, res[4] as uppers, res[5] as lowers, res[6] as probs from ( select machine, metricName, array_transpose(ts_predicate_aram(time, value, 5, 1, 1)) as res from ( selecttimestamp - timestamp % 60 as time, machine, metricName, avg(metricValue) as valuefrom log group by time, machine, metricName ) group by machine, metricName )

經過對二維數組的轉換后,我們將每行的內容拆分出來,得到符合預期的結果,具體格式如下:

| machine | metricName | ts | ds | preds | uppers | lowers | probs | | ------- | ---------- | -- | -- | ----- | ------ | ------ | ----- |

2.2 解決二

針對批量檢測的結果,我們該如何快速的將存在特定異常的結果過濾篩選出來呢?日志服務平臺提供了針對異常檢測結果的過濾操作。

select ts_anomaly_filter(lineName, ts, ds, preds, probs, nWatch, anomalyType)

其中,針對anomalyType有如下說明:

  • 0:表示關注全部異常
  • 1:表示關注上升沿異常
  • -1:表示下降沿異常

其中,針對nWatch有如下說明:

  • 表示從實際時序數據的最后一個有效的觀測點開始到最近nWatch個觀測點的長度。

具體使用如下所示:

* | select ts_anomaly_filter(lineName, ts, ds, preds, probs, cast(5 as bigint), cast(1 as bigint)) from ( select concat(machine, '-', metricName) as lineName, res[1] as ts, res[2] as ds, res[3] as preds, res[4] as uppers, res[5] as lowers, res[6] as probs from ( select machine, metricName, array_transpose(ts_predicate_aram(time, value, 5, 1, 1)) as res from ( selecttimestamp - timestamp % 60 as time, machine, metricName, avg(metricValue) as valuefrom log group by time, machine, metricName ) group by machine, metricName ) )

通過上述結果,我們拿到的是一個Row類型的數據,我們可以使用如下方式,將具體的結構提煉出來:

* | select res.name, res.ts, res.ds, res.preds, res.probs from( select ts_anomaly_filter(lineName, ts, ds, preds, probs, cast(5 as bigint), cast(1 as bigint)) as resfrom( select concat(machine, '-', metricName) as lineName, res[1] as ts, res[2] as ds, res[3] as preds, res[4] as uppers, res[5] as lowers, res[6] as probsfrom ( select machine, metricName, array_transpose(ts_predicate_aram(time, value, 5, 1, 1)) as res from ( selecttimestamp - timestamp % 60 as time, machine, metricName, avg(metricValue) as valuefrom log group by time, machine, metricName )group by machine, metricName ) ) )

通過上述操作,就可以實現對批量異常檢測的結果進行過濾處理操作,幫助用戶更好的批量設置告警。


3.硬廣時間

3.1 日志進階

這里是日志服務的各種功能的演示?日志服務整體介紹,各種Demo


原文鏈接
本文為云棲社區原創內容,未經允許不得轉載。

總結

以上是生活随笔為你收集整理的SLS机器学习最佳实战:批量时序异常检测的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。