2017-10-19 119 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

相關問題