zoukankan      html  css  js  c++  java
  • ES7.3.0配置邮件告警

    情况说明:
    三台es组成集群,一台kibana,版本均为7.3.0
    es版本要求是白金版,基础版的不行,不过可以试用30天的白金版

    步骤:先说我自己走通的流程,然后介绍官方说明

    1.因为我这边使用的是三台es,所以我这边三台都需要配置
    原因如下:只配置一台的话,电子邮件选项是灰色的不可用状态,只有三台都配置了才行

    2.修改elasticsearch.yml配置文件
    我这边使用的是阿里云企业邮箱,开启的有smtp和pop3服务,走的是常规端口,加密端口还未测试验证

    说明,使用QQ邮箱,163邮箱的话,需要注意,在配置发件箱中使用的密码不是登陆这个邮箱使用的密码,而是使用这个邮箱的邮箱授权码

    xpack.notification.email.account:
        aliyun_account:  # 发件箱配置名称,可以随意指定,配置多个发件箱地址时会根据这个进行区分
            profile: standard # 采用默认的邮件模板
            email_defaults: # 设置默认发件箱
                from: elk@tongchuangkeji.net  # 发件箱
            smtp:
                auth: true # 开启账号验证
                starttls.enable: false # 关闭ssl
                starttls.required: false # 不要ssl
                host: smtp.qiye.aliyun.com # 阿里云企业邮箱smtp地址
                port: 25 # 端口
                user: elk@tongchuangkeji.net # 发件箱
    

    附:阿里云企业邮箱的POP3、SMTP、IMAP地址
    新老地址都可以,建议使用新地址

    新地址
    协议	服务器地址	                服务器端口号(常规)	服务器端口号(加密)
    POP3	pop.qiye.aliyun.com	     110	               995
    IMAP	imap.qiye.aliyun.com	   143	               993
    SMTP	smtp.qiye.aliyun.com	   25	                       465
    
    老地址
    协议	   服务器地址	             服务器端口号(常规)	 服务器端口号(加密)
    POP3	 pop3.mxhichina.com	  110	                    995
    SMTP	 smtp.mxhichina.com	  25	                            465
    IMAP	 imap.mxhichina.com	  143	                    993
    

    3.设置发件箱密码
    在es程序根目录下执行这个命令

    # 注意:aliyun_account要跟配置文件中的发件箱配置名称那个保持一致
    bin/elasticsearch-keystore add xpack.notification.email.account.aliyun_account.smtp.secure_password
    # 接下来输入邮箱密码即可
    
    # 完成的命令步骤,供参考
    # 设置邮箱密码
    [root@bogon elasticsearch]# bin/elasticsearch-keystore add xpack.notification.email.account.aliyun_account.smtp.secure_password
    # 输入密码
    Enter value for xpack.notification.email.account.aliyun_account1.smtp.secure_password: 
    # 查看
    [root@bogon elasticsearch]# bin/elasticsearch-keystore list
    keystore.seed # 系统自带的
    xpack.notification.email.account.aliyun_account.smtp.secure_password # 确保有这个
    

    4.重启es集群

    5.在kibana中设置Watcher

    邮件发送成功的话界面右下角会有提示。

    查看发件箱的发件情况

    6.说明
    该文档只是说明配置告警邮件,具体告警参数,邮件内容根据个人具体情况而定

    官方关于邮件告警的设置

    地址:https://www.elastic.co/guide/en/kibana/7.3/watcher-ui.html#_define_the_watch_input_and_schedule
    1.进入Management > Elasticsearch > Watcher
    若Elasticsearch security features 开启的话,需要给使用kibana的用户设置如下角色,确保该用户有权限配置这个邮件告警:manage_watcher or monitor_watcher

    2.点击Create,选择Create threshold alert,输入告警名称,选择索引,选择日期字段,选择时间频率

    3.设置告警条件
    WHEN条件选择max(),监控项选择system.process.cpu.total.norm.pct,监控值选择 IS ABOVE 填写0.25

    4.添加监控动作
    点击Add action,选择Email,输入收件箱地址,邮件主题,邮件内容等,发送测试邮件。
    若能收到测试邮件,最后点Create alert。

    5.删除,修改等操作看官网文档

    接下里说官方配置邮件的示例
    地址:https://www.elastic.co/guide/en/elasticsearch/reference/7.3/actions-email.html

    在es配置文件中进行修改

    邮件模板有三个,standard (default), gmail, and outlook 。若发件箱不是gmail和outlook,则选择standard。后面会有说明

    若是有多个发件箱的话,采用如下配置,只有一个的话不用配置

    xpack.notification.email:
      default_account: team1
      account:
        team1:
          ...
        team2:
          ...
    

    gmail发件箱设置

    xpack.notification.email.account:
        gmail_account: # 注意这个名称,设置邮箱密码的时候用得着
            profile: gmail
            smtp:
                auth: true
                starttls.enable: true
                host: smtp.gmail.com
                port: 587
                user: <username> # 发件箱地址
    

    设置发件箱密码
    这个是执行命令,不是在es配置文件中修改

    # 注意gmail_account要跟上面的保持一致
    bin/elasticsearch-keystore add xpack.notification.email.account.gmail_account.smtp.secure_password
    
    

    outlook配置

    xpack.notification.email.account:
        exchange_account:
            profile: outlook
            email_defaults:
                from: <email address of service account> 
            smtp:
                auth: true
                starttls.enable: true
                host: <your exchange server>
                port: 587
                user: <email address of service account> 
    

    设置发件箱密码
    这个是执行命令,不是在es配置文件中修改

    # 注意exchange_account要跟上面的保持一致
    bin/elasticsearch-keystore add xpack.notification.email.account.exchange_account.smtp.secure_password
    
    

    既不是gmail,也不是outlook,采取两者结合的方式,根据自己实际情况修改

    xpack.notification.email.account:
        email_account:
            profile: standard
            email_defaults:
                from: xxxx@xx.com
            smtp:
                auth: true
                starttls.enable: false
                starttls.required: false
                host: smtp.qiye.aliyun.com 
                port: 25
                user: xxxx@xx.com
    # 设置密码
    bin/elasticsearch-keystore add xpack.notification.email.account.email_account.smtp.secure_password
    

    关于安全设置的官方地址:https://www.elastic.co/guide/en/elasticsearch/reference/7.3/secure-settings.html#

    其他邮箱配置大致一样,看官方文档

    邮件内容设置相关,是否允许发送html内容的配置等

    # 关闭
    xpack.notification.email.html.sanitization.enabled: false
    
    # 开启
    xpack.notification.email.html.sanitization.enabled: true
    
    # 进一步限制html页面内容,哪些能发,哪些不能发
    xpack.notification.email.html.sanitization:
        allow: _tables, _blocks
        disallow: h4, h5, h6
    
  • 相关阅读:
    TCP和UDP的区别
    项目--华为商城---登录页面(一)
    Servlet(一)—— 文件上传(表单文件上传)
    LeetCode(一) —— 存在重复
    电脑右击不能创建txt文件
    边工作边刷题:70天一遍leetcode: day 92-2
    自底向上集成 Bottom-Up
    分层集成(线性关系) Layers
    基干集成(内核耦合度高) Backbone
    三明治集成(分而治之策略) 又分为传统型和改进型 Sandwich
  • 原文地址:https://www.cnblogs.com/sanduzxcvbnm/p/12021538.html
Copyright © 2011-2022 走看看