一、 创建索引

PUT ipu-cbs-warning-info

{

    "settings" : {

        "number_of_shards" : 1

    },

    "mappings" : {

        "properties" : {

            "timestamp": {"type": "date"},

            "rule_id" : { "type" : "text" },

            "rule_name" : { "type" : "text" },

            "alert_id" : { "type" : "text" },

            "context_reason" : { "type" : "text" },

            "context_group" : { "type" : "text" },

            "context_metric" : { "type" : "text" },

            "context_value" : { "type" : "text" },

            "context_threshold" : { "type" : "text" },

            "context_alertDetailsUrl" : { "type" : "text" }

        }

    }

}

二、 创建连接器

Kibana 自定义索引连接器告警-LMLPHP

三、 创建规则

3.1 使用索引

Kibana 自定义索引连接器告警-LMLPHP

3.2  选择索引

Kibana 自定义索引连接器告警-LMLPHP

3.3  填写要索引的文档

 到这一步,告警数据就可以正常发送到es中了,接下来需要从es中取出数据并发送邮件

四、 发送邮件

   这里采用java服务自定义从es中取数据并发送邮件的功能

4.1 java服务配置

server:
  port: 8080  # 配置应用程序监听的端口


spring:

  mail:

    default-encoding: UTF-8  # 邮件默认编码设置为UTF-8
    port: 25  # 邮件服务器端口
    host: 192.168.251.31  # 邮件服务器主机地址
    username: uap_no_replay@v-summit.com  # 邮件服务器用户名
    password: vNkZq;kwB  # 邮件服务器密码
    to: harrison.yuan@vteamsystem.com  # 收件人邮箱
#    to: miller.lai@vteamsystem.com  # 可选的第二个收件人邮箱
    properties:
      mail:
        smtp:
          auth: true  # 启用SMTP身份验证
          ssl:
            enable: false  # 禁用SSL
          socketFactory:
            class: javax.net.ssl.SSLSocketFactory  # 设置SocketFactory类为SSLSocketFactory



es:
  host: 192.168.10.161  # Elasticsearch主机地址
  port: 9200  # Elasticsearch端口
  username: elastic  # Elasticsearch用户名
  password: elastic  # Elasticsearch密码
  indexName: ipu-cbs-warning-info  # Elasticsearch索引名称

4.1 jar包下载

下载地址: es 邮件告警服务器jar包

 jar包下载后用上面修改的yml配置文件覆盖jar包中的application.yml的内容然后启动服务

01-05 13:56