elasticsearch - 如何在 logstash conf 文件中使用包含?
问题描述
可以在 logstash 配置文件中使用包含吗?
最小、完整和可验证的示例
这个可以换吗...
文件:beats.conf
input {
beats {
port => 5044
}
}
filter {
date {
match => ["myTimestamp", "yyyyMMdd_HH:mm:ss.SSS"]
target => "date_time"
}
}
output {
elasticsearch {
hosts => [ "localhost:9200" ]
}
}
...有了这个?
文件:date.inc
date {
match => ["myTimestamp", "yyyyMMdd_HH:mm:ss.SSS"]
target => "date_time"
}
文件:beats.conf
input {
beats {
port => 5044
}
}
filter {
#include <date.inc> // <- THIS THIS THIS THIS THIS
}
output {
elasticsearch {
hosts => [ "localhost:9200" ]
}
}
解决方案
实际上不支持“包含”,并且 Logstash 无法加载拆分为不同文件的管道以重用公共部分。
编辑:从不同文件组成管道的唯一方法是在设置中指定文件夹或通配符“*”,path.config
以便按字母顺序读取配置文件(感谢@Badger)。
如果您不想定义自己的管道的组合/编译系统,您可以查看“管道到管道”通信,该通信可用于分解复杂的管道并在不同的流上重用过滤器:https ://www.elastic.co/guide/en/logstash/current/pipeline-to-pipeline.html 。请注意,使用这种方法,您将支付运行多个管道的开销。
例如:
管道.yml
- pipeline.id: input
path.config: "<path-to-file>/beats.conf"
- pipeline.id: date-filters
# This common pipeline allow to reuse the same logic for complex filters
path.config: "<path-to-file>/date.conf"
- pipeline.id: output
path.config: "<path-to-file>/elasticsearch.conf"
beats.conf
input {
beats {
port => 5044
}
}
output { pipeline { send_to => [commonFilters] } }
日期.conf
input { pipeline { address => commonFilters } }
filter {
date {
match => ["myTimestamp", "yyyyMMdd_HH:mm:ss.SSS"]
target => "date_time"
}
}
output { pipeline { send_to => [output] } }
弹性搜索.conf
input { pipeline { address => output } }
output {
elasticsearch {
hosts => [ "localhost:9200" ]
}
}
推荐阅读
- twilio - Twilio:通话和语音功能?
- swift - 如何在 Swift 中获取共享文件夹列表
- electron - 尝试使用 Electron Forge 为 Raspberry Pi Zero 构建应用程序
- mysql - MYSQL 8 - 如何在 CTE 中找出“节点”是否是“叶节点”而检索树
- assembly - 如果没有标志标志 (SF),x86 是否仍可完全编程?
- visual-studio-code - VScode 直播服务器问题
- javascript - Javascript:从 ajax / 时间问题加载 Google Charts
- rust - 如何在 Near 协议合约中将“AccountId”转换为“ValidAccountId”?
- xml - finvoice/xml 文件电子发票的电子邮件 mime 类型是什么(xml 而不是 pdf)?
- sql - 根据列中的状态更改创建触发器并在表的另一列中插入值