情況說明:三台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