zoukankan      html  css  js  c++  java
  • Elasticsearch Alert配置邮件告警

    情况说明:三台es集群,一台kibana

    es版本要求白金版,基础版不行,可以试用30天白金版

    1、三台es都需要配置,修改elasticsearch.yml配置文件

    说明,使用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 # 发件箱

    2、设置发件箱密码

    # 注意:aliyun_account要跟配置文件中的发件箱配置名称那个保持一致
    # 设置邮箱密码
    [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 # 确保有这个

    3、重启es集群

    4、在kibana中配置Watcher

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

    官方关于邮件告警的设置

    地址:https://www.elastic.co/guide/en/kibana/7.3/watcher-ui.html#_define_the_watch_input_and_schedule
    1、.删除,修改等操作看官网文档

    接下里说官方配置邮件的示例
    地址: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
  • 相关阅读:
    Codeforces Round #522(Div. 2) C.Playing Piano
    zstu月赛 招生
    Codeforces Round #519 D
    RMQ[区间最值查询] 算法
    Codeforces #364 (Div. 2) D. As Fa(数学公式推导 或者二分)
    尺取法
    Codeforces #366 (Div. 2) D. Ant Man (贪心)
    Codeforces #366 Div. 2 C. Thor (模拟
    裴蜀定理
    CF850 E. Random Elections
  • 原文地址:https://www.cnblogs.com/fat-girl-spring/p/12881608.html
Copyright © 2011-2022 走看看