Logstash 参考指南(Email输出插件)

Email输出插件

其余版本请参阅版本化的插件文档html

获取帮助

有关插件的问题,请在讨论论坛中打开一个主题,对于bug或特性请求,在Github中打开一个issue,关于Elastic支持的插件列表,请考虑Elastic支持矩阵git

描述

当收到输出时发送email,或者,你能够使用条件包含或排除email输出执行。github

使用的例子

output {
  if "shouldmail" in [tags] {
    email {
      to => 'technical@example.com'
      from => 'monitor@example.com'
      subject => 'Alert - %{title}'
      body => "Tags: %{tags}\\n\\Content:\\n%{message}"
      template_file => "/tmp/email_template.mustache"
      domain => 'mail.example.com'
      port => 25
    }
  }
}

Email输出配置选项

此插件支持如下配置选项以及稍后描述的通用选项。服务器

设置 输入类型 要求
address string No
attachments array No
authentication string No
body string No
cc string No
bcc string No
contenttype string No
debug boolean No
domain string No
from string No
htmlbody string No
password string No
port number No
replyto string No
subject string No
to string Yes
use_tls boolean No
username string No
via string No
template_file path No

还能够查看全部输出插件支持的通用选项列表。dom

addresside

  • 值类型为string
  • 默认值为“localhost”
  • 用于链接到邮件服务器的地址

attachments测试

  • 值类型为array
  • 默认值为[]
  • 附件 — 指定文件的名称和位置

authenticationui

  • 值类型为string
  • 此设置没有默认值
  • 与服务器进行标识时使用的身份验证方法

body编码

  • 值类型为string
  • 默认值为 ""
  • 邮件正文 — 纯文本

cc插件

  • 值类型为string
  • 此设置没有默认值
  • 彻底合格的电子邮件地址包括为cc:地址

该字段还接受以逗号分隔的地址字符串,例如:“me@example.com, you@example.com”

bcc

  • 值类型为string
  • 此设置没有默认值
  • 彻底合格的电子邮件地址包括为bcc:地址,此字段接受多个地址,如cc

contenttype

  • 值类型为string
  • 默认值为"text/html; charset=UTF-8"
  • contenttype:对于多部分消息,设置HTML部分的content-type和/或字符集,这可能不是功能性的(KH)

debug

  • 值类型为boolean
  • 默认值是false
  • 在debug模式运行email传递

domain

  • 值类型为string
  • 默认值为“localhost”
  • 链接到远程SMTP服务器时,在问候语中使用的HELO/EHLO域名,有些服务器须要这个名称来匹配链接客户端的实际主机名

from

  • 值类型为string
  • 默认值为“logstash.alert@example.com”
  • From的email中的彻底限定电子邮件地址:email中的字段

htmlbody

  • 值类型为string
  • 默认值为""
  • 邮件的HTML主体,可能包含HTML标记

password

  • 值类型为string
  • 此设置没有默认值
  • 与服务器进行身份验证的密码

port

  • 值类型为number
  • 默认值为25
  • 用于与邮件服务器通讯的端口

replyto

  • 值类型为string
  • 此设置没有默认值
  • Reply-To的彻底限定电子邮件地址:字段

subject

  • 值类型为string
  • 默认值为""
  • Subject:email的主题

to

  • 这是必需的设置
  • 值类型为string
  • 此设置没有默认值
  • 发送电子邮件到的彻底限定的电子邮件地址,该字段还接受以逗号分隔的地址字符串,例如:“me@example.com, you@example.com”,你还能够使用%{fieldname}语法从事件中获取的动态字段

use_tls

  • 值类型为boolean
  • 默认值为false
  • 在与服务器通讯时启用TLS

username

  • 值类型为string
  • 此设置没有默认值
  • 使用服务器验证的用户名

via

  • 值类型为string
  • 默认值为"smtp"
  • Logstash应该如何发送邮件,或者经过SMTP,或者经过调用sendmail

template_file

  • 值类型为path
  • 此设置没有默认值
  • 用于电子邮件模板的Mustache模板文件路径,请参阅测试夹具中的示例,能够与body一块儿发送多部分的电子邮件,优先于htmlBody

通用选项

全部输出插件都支持如下配置选项:

设置 输入类型 要求
codec codec No
enable_metric boolean No
id string No

codec

  • 值类型为codec
  • 默认值为"plain"
  • 用于输出数据的编解码器,输出编解码器是一种方便的方法,能够在数据离开输出以前对其进行编码,而不须要在你的Logstash管道中使用单独的过滤器。

enable_metric

  • 值类型为boolean
  • 默认值为true
  • 为这个特定的插件实例禁用或启用指标日志记录,默认状况下,咱们记录了全部咱们能够记录的指标,可是你能够禁用特定插件的指标集合。

id

  • 值类型为string
  • 此设置没有默认值
  • 在插件配置中添加惟一的ID,若是没有指定ID,则Logstash将生成一个,强烈建议在配置中设置此ID,当你有两个或多个相同类型的插件时,这一点特别有用。例如,若是你有两个电子邮件输出,在本例中添加一个命名ID将有助于在使用监控API时监控Logstash。

    output {
      email {
        id => "my_plugin_id"
      }
    }
相关文章
相关标签/搜索