用logstash发邮件告警

logstash input http

该输入插件会让logstash在一个端口上监听http请求,用户可以通过http请求发送告警请求。

input {
    http {
        host => "0.0.0.0"
        port => 9500
        type => "heartbeat"
        user => "loguser"
        password => "logpwd"
        #codec => json{}
    }
}
  • 如果设置了user,password,则发送http请求时需要Auth Basic验证
  • 如果http请求header包含:Content-Type: application/json,则http插件将自动调用codec json将输入内容解析成json格式
  • 发送请求:
POST http://localhost:9500
{
  "appid": "app_heaertbead_monit",
  "to": "jiaofuyou@qq.com",
  "subject": "heaertbead monit",
  "body": "heaertbead monit body"
}

logstash output email

output {
    if [type] == "heartbeat" {
        email {
            to => "%{to}"
            from => "from@qq.com"
            address => "smtp.qq.com"
            username => "username "
            password => "password "
            subject => "%{subject}"
            body => "%{body}"
            htmlbody => ""
        }
    }

    #同时也经redis再保存到elasticsearch中
    redis {
        host => '172.16.18.116'
        data_type => 'list'
        key => 'logstash:redis'
    }
}
发布了136 篇原创文章 · 获赞 80 · 访问量 106万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览