logstash獲取異常日誌推送釘釘

logstash.conf配置
input {
file {
path => "/data/home/services/xxx/logs/xxx.log"
#path => "/opt/test.log"
#設置logstash開始讀取文件內容位置,begining爲從頭開始,end爲只讀取最新數據
start_position => "end"
}
}

output {
if '"errorCode":1306' in [message] {
#stdout { codec => rubydebug }
http {
url => "https://oapi.dingtalk.com/robot/send?access_token=xxx"
http_method => "post"
content_type => "application/json; charset=utf-8"
format => "message"
message => '{"msgtype":"text","text":{"content": "音視頻播放異常: service:xxx ip:172.17.8.226 APP_LOG errcode is 1306"}}'
}
}else if '"errorCode" : "1307"' in [message] {
http {
url => "https://oapi.dingtalk.com/robot/send?access_token=xx"
http_method => "post"
content_type => "application/json; charset=utf-8"
format => "message"
message => '{"msgtype":"text","text":{"content": "音視頻播放異常: service:xx-api ip:172.17.8.226 APP_LOG errcode is 1307"}}'
}
}
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章