Elastaticsearch日誌告警(elastalert)
阿新 • • 發佈:2018-11-08
Elastaticsearch日誌告警
elastalert正確使用姿勢
前言
五月份網上尋找ELK日誌告警解決方案,Github發現一款開源軟體elastalert
傳送門
看最近更新時間為兩年前,所以一直處於半質疑狀態看待該軟體,直到進一步...深入...
最新訊息: 截止發稿時間,看該專案已經有最新改動,新增Kibana外掛支援!
錯誤姿勢
由於對elastalert
瞭解不深,前期使用過程中沒有使用ES查詢(可能當時ES6剛釋出,對ES6版本沒針對性修改),進行一些沒必要的二次開發.
後面隨時不斷嘗試,發現
elastalert
還是蠻強大的,越來越看好,且漸漸瞭解到真正用法 ...領悟到正確姿勢...
正確姿勢
針對需求
監控站點50X告警, 當一分鐘內出現100個50X
時告警
name: nginx access 50X rule type: frequency index: access* num_events: 100 timeframe: minutes: 1 filter: - range: status: from: 500 to: 599 alert: "modules.eagle_post.EagleAlerter" eagle_post_url: "" eagle_post_all_values: False eagle_time_start: "02:00" eagle_time_end: "06:00" eagle_post_payload: host: "host" status: "status" request: "request_uri" remoteaddr: "remote_addr" requesttime: "request_time" useragent: "http_user_agent" method: "request_method" time: "time_local"
效果圖
監控系統執行危險操作
index: system_history* timeframe: minutes: 0 filter: - query: - bool: should: - match: {"command":"mysqldump"} - match: {"command":"rm -rf"} - match: {"command":"shutdown"} - match: {"command":"passwd"} ...
監控資料庫錯誤日誌
type: blacklist_v2
index: mysql_log*
timeframe:
minutes: 1
reverse: False
compare_key: message
filter:
- query:
- bool:
must:
- term: {"tag":"error_log"}
must_not:
- match: {"message":"[Warning]"}
- match: {"message":"[Note]"}
blacklist_v2:
- "Too many connections"
- "ERROR"
- "error"
- "table full"
後語
技術人員不能稍微瞭解後就妄下定論!
後續將會繼續關注
elastalert
,歡迎各位大佬經驗交流.