如何在 logstash conf 文件中使用 include?
How to use includes in logstash conf files?
可以在 logstash 配置文件中使用 include 吗?
最小、完整且可验证的示例
我可以更换这个吗...
文件: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" ]
}
}
实际上不支持 "include" 并且 Logstash 无法加载拆分为不同文件的管道以重用公共部分。
编辑: 从不同文件组成管道的唯一方法是在 path.config
设置中指定文件夹或通配符“*”,以便按字母顺序读取配置文件(感谢@Badger).
如果您不想定义自己的管道 composition/compilation 系统,您可以查看 "Pipeline-to-Pipeline" 通信,它可用于分解复杂的管道并重用您对不同流程的过滤器:https://www.elastic.co/guide/en/logstash/current/pipeline-to-pipeline.html。请注意,使用这种方法,您将支付 运行 多个管道的开销。
例如:
pipelines.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] } }
date.conf
input { pipeline { address => commonFilters } }
filter {
date {
match => ["myTimestamp", "yyyyMMdd_HH:mm:ss.SSS"]
target => "date_time"
}
}
output { pipeline { send_to => [output] } }
elasticsearch.conf
input { pipeline { address => output } }
output {
elasticsearch {
hosts => [ "localhost:9200" ]
}
}
可以在 logstash 配置文件中使用 include 吗?
最小、完整且可验证的示例
我可以更换这个吗...
文件: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" ]
}
}
实际上不支持 "include" 并且 Logstash 无法加载拆分为不同文件的管道以重用公共部分。
编辑: 从不同文件组成管道的唯一方法是在 path.config
设置中指定文件夹或通配符“*”,以便按字母顺序读取配置文件(感谢@Badger).
如果您不想定义自己的管道 composition/compilation 系统,您可以查看 "Pipeline-to-Pipeline" 通信,它可用于分解复杂的管道并重用您对不同流程的过滤器:https://www.elastic.co/guide/en/logstash/current/pipeline-to-pipeline.html。请注意,使用这种方法,您将支付 运行 多个管道的开销。
例如:
pipelines.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] } }
date.conf
input { pipeline { address => commonFilters } }
filter {
date {
match => ["myTimestamp", "yyyyMMdd_HH:mm:ss.SSS"]
target => "date_time"
}
}
output { pipeline { send_to => [output] } }
elasticsearch.conf
input { pipeline { address => output } }
output {
elasticsearch {
hosts => [ "localhost:9200" ]
}
}