微服務-3、環境搭建(測試logstash 讀取文字,輸出)
阿新 • • 發佈:2020-07-03
一、配置
input { file { path => "../config/account.txt" } } output{ stdout{codec =>json } }
複雜化
input { file { path => ["/data/apps/logstash/config/account.txt"] # 監聽檔案的起始位置,預設是end start_position => end # 設定多長時間檢測檔案是否修改(單位:秒) stat_interval => 1 # 監聽檔案讀取資訊記錄的位置 sincedb_path=> "/data/apps/logstash/test/since_db.txt" # 設定多長時間會寫入讀取的位置資訊(單位:秒) sincedb_write_interval => 5 codec => plain{ charset=>"GBK" } } } filter { #去除每行記錄中需要過濾的\N,替換為空字串 mutate{ gsub => [ "message", "\\N", "" ] } # 日期格式化 #date{ # match=> ["create_time", "yyyy-MM-dd HH:mm:ss"] # locale => "cn" #} csv { # 每行記錄的欄位之間以|分隔 separator => "," #指定csv檔案的欄位,必須要和csv檔案中的欄位順序一致 columns => ["id","name"] # 過濾掉預設加上的欄位 remove_field => ["@timestamp","@version","host", "tags", "path", "message"] } } output { #stdout { codec => json } stdout { codec => json_lines } }