文章目录
前言
来,咱们今天接着聊ELK,前面我们讲了ELK的基本操作,ELK的日志检索。咱们今天来聊聊如何配置敏感信息的邮件通知,作为一个程序员不可能无时无刻的盯着ELK的日志大屏(后面再来聊聊日志的可视化操作),针对ELK的错误日志得及时关注,以免造成不必要的影响。下面我们以每10分钟发送503错误邮件通知为例。
一、使用管理工具Kibana: Elasticsearch watcher
1.1.编辑/etc/elasticsearch/elasticsearch.yml,在最后添加邮件发送者的相关设置。
xpack.notification.email.account:
outlook_account:
profile: outlook
smtp:
auth: true
starttls.enable: true
host: smtp.office365.com
port: 587
user: xxx@outlook.com
password: xxx
1.2.在Kibana创建一个定制watch。(或者直接使用curl命令添加到watch)
Kibana = > Management = > Elasticsearch = > Watcher = > Create new watch = > Advanced Watch:
{
"trigger" : {
"schedule" : {
"cron" : "*/10 * * * * ?" }
},
"input" : {
"search" : {
"request" : {
"indices" : [
"test-qa-access*"
],
"body" : {
"query" : {
"bool" : {
"must" : {
"match": {
"response": 503
}
},
"filter" : {
"range": {
"@timestamp": {
"from": "{
{ctx.trigger.scheduled_time}}||-10m",
"to": "{
{ctx.trigger.triggered_time}}"
}
}
}
}
}
}
}
}
},
"condition" : {
"compare" : {
"ctx.payload.hits.total" : {


712

被折叠的 条评论
为什么被折叠?



