2017-10-19 442 views
1

我正在试图用名为“YYYYMMDD.json”的当前日期处理Logstash中的文件。但是我不能在这个配置文件中使用date变量。是否可以在不对日期进行硬编码的情况下执行此操作?如何在logstash配置文件中使用当前日期作为输入文件

input { 
     file { 
       path => "/home/ubuntu/YYYYMMDD.json 
         type => "ip-address" 
         start_position => "beginning" 
         sincedb_path => "/dev/null" 
     } 
} 
filter { 
     json { 
       source => "message" 
     } 
} 
output { 
     elasticsearch { 
       hosts => ["IP:Port"] 
         index => "results" 
         document_id => "%{ip}" 
         doc_as_upsert => true 
         action => "update" 
         retry_on_conflict => 10 
     } 
} 

回答

1

path你在路径的末尾缺少一个"

path => "/home/ubuntu/YYYYMMDD.json" 

试试这个

file { 
    path => "/home/ubuntu/%{+YYYYMMDD}.json" 
    type => "ip-address" 
    start_position => "beginning" 
    sincedb_path => "/dev/null" 
} 

您可以使用:path => "/home/ubuntu/*.json"和解析所有JSON的文件夹中。

如果您每天添加一个文件,则可以使用filebeats

相关问题