community.general.logstash 回调 - 发送事件到 Logstash
注意
此回调插件是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。您需要其他要求才能使用此回调插件,请参阅 要求 了解详细信息。
要在 playbook 中使用它,请指定:community.general.logstash
。
回调插件
此插件是一个通知回调。它将 playbook 运行的信息发送到其他应用程序、服务或系统。有关回调插件的更多信息,请参阅 回调插件。
概要
此回调将向 Logstash 报告事实和任务事件 https://elastic.ac.cn/products/logstash。
要求
在执行此回调的本地控制器节点上需要以下要求。
配置中的白名单
logstash(Python 库)
参数
参数 |
注释 |
---|---|
日志记录格式。 选择
配置
|
|
Logstash 正在监听的端口。 默认值: 配置
|
|
在运行之前执行命令,其结果将添加到 配置
|
|
Logstash 服务器的地址。 默认值: 配置
|
|
消息类型。 默认值: 配置
|
示例
ansible.cfg: |
# Enable Callback plugin
[defaults]
callback_whitelist = community.general.logstash
[callback_logstash]
server = logstash.example.com
port = 5000
pre_command = git rev-parse HEAD
type = ansible
11-input-tcp.conf: |
# Enable Logstash TCP Input
input {
tcp {
port => 5000
codec => json
add_field => { "[@metadata][beat]" => "notify" }
add_field => { "[@metadata][type]" => "ansible" }
}
}