是否可以参数化Logstash输入节?

时间:2014-09-15 11:25:23

标签: configuration logstash

我们使用几个非常相似的部分配置了Logstash文件输入(见下文)。如您所见,部分几乎相同:它们在“_application”和“_appPath”变量中不同,其余部分相同。所以我想知道是否有一种参数化Logstash输入节的方法,所以我们只能描述一个“文件”参数组,但它会产生几个“文件”节的实例,如下所示。

input {
  file {
    add_field => { "_environment" => "#{Octopus.Environment.Name}" }
    add_field => { "_application" => "potion" }
    add_field => { "_appPath" => "#{Octopus.Tentacle.Agent.ApplicationDirectoryPath}/%{[_environment]}/Potion" }
    path => "%{[_appPath]}/logs/log.*.txt"
    sincedb_path => "%{[_appPath]}/logs/sincedb"
    codec => "json"
    tags => [potion, local]
    start_position => "beginning"
  }
  file {
    add_field => { "_environment" => "#{Octopus.Environment.Name}" }
    add_field => { "_application" => "bridge_soap" }
    add_field => { "_appPath" => "#{Octopus.Tentacle.Agent.ApplicationDirectoryPath}/%{[_environment]}/Bridge.Web" }
    path => "%{[_appPath]}/logs/log.*.txt"
    sincedb_path => "%{[_appPath]}/logs/sincedb"
    codec => json
    tags => [bridge_soap, local]
    start_position => "beginning"
   }
  file {
    add_field => { "_environment" => "#{Octopus.Environment.Name}" }
    add_field => { "_application" => "bridge_rest" }
    add_field => { "_appPath" => "#{Octopus.Tentacle.Agent.ApplicationDirectoryPath}/%{[_environment]}/Bridge.Rest.Host" }
    path => "%{[_appPath]}/logs/log.*.txt"
    sincedb_path => "%{[_appPath]}/logs/sincedb"
    codec => json
    tags => [bridge_rest, local]
    start_position => "beginning"
   }
}

1 个答案:

答案 0 :(得分:2)

本地不在logstash中,但您可以在配置管理系统(ansible等)中执行类似的操作。