Logstash conf d 多個配置檔案

2021-10-21 13:49:58 字數 2997 閱讀 4552

今天在群裡乙個關於在 logstash 的配置目錄存在多個配置檔案的時候如何處理的問題?

我的結論是載入所有配置檔案並合併為乙個。

lcy@lcy:~/elk/logstash$ sudo /opt/logstash/bin/logstash --help

[sudo] password for lcy:

usage:

/bin/logstash agent [options]

options:

-f, --config config_path load the logstash config from a specific file

or directory. if a directory is given, all

files in that directory will be concatenated

in lexicographical order and then parsed as a

single config file. you can also specify

wildcards (globs) and any matched files will

be loaded in the order described above.

下面,做個小實驗用以說明。

存在2個配置檔案 1.conf 和 2.conf

// 存在2個配置檔案

lcy@lcy:/etc/logstash/conf.d$ ls

1.conf 2.conf

其中 1.conf 配置了 input ,使用 file 外掛程式來匯入檔案 file_1(input中引數配置為 file_*) 的內容。並且在 fileter 中加乙個 filed ,名稱叫 add_from_1。輸出格式為 rubydebug。

// 檔案1.conf的內容

lcy@lcy:/etc/logstash/conf.d$ cat .conf

input

}filter

}}output

}

其中 2.conf 沒有配置 input 。在 fileter 中加乙個 filed ,名稱叫 add_from_2。輸出格式為 json。

// 檔案2.conf的內容

lcy@lcy:/etc/logstash/conf.d$ cat .conf

filter

}}output

}

file_1 很簡單,就乙個單行 json 檔案。

// file_1 的檔案內容

lcy@lcy:~$ cat file_1

}

lcy@lcy:/etc/logstash/conf.d$ sudo /opt/logstash/bin/logstash -f /etc/logstash/conf.d/

settings: default pipeline workers:

logstash startup completed

可以執行:

對配置檔案進行除錯

/opt/logstash/bin/logstash agent -f /etc/logstash/conf.d –configtest

或從命令列以互動方式執行它.它會產生很多其他資訊.

/opt/logstash/bin/logstash –debug -f /etc/logstash/conf.d

或執行以下只是測試並檢視已編譯的配置

/opt/logstash/bin/logstash –debug –debug-config -t -f /etc/logstash/conf.d/

即輸出了 rubydebug 格式,又輸出了 json 格式。

lcy@lcy:/etc/logstash/conf.d$ sudo /opt/logstash/bin/logstash -f /etc/logstash/conf.d/

settings: default pipeline workers:

logstash startup completed

}","@version" => "",

"@timestamp" => "2016-04-28t06:42:43.050z",

"path" => "/home/lcy/file_1",

"host" => "lcy",

"add_from_1" => "",

"add_from_2" => ""

}}","@version":"","@timestamp":"2016-04-28t06:42:43.050z","path":"/home/lcy/file_1","host":"lcy","add_from_1":"","add_from_2":""}

^csigint received. shutting down the pipeline.

^csigint received. terminating immediately..

^csigint received. terminating immediately..

可以看出,實際執行中,把 1.conf 和 2.conf 檔案的內容完全合併為了乙個配置檔案

input :2.conf 沒有配置 input 不會報錯,因為 1.conf 中有(input 為必須)

fileter :輸出內容中即新增了 add_from_1 也新增了 add_from_2 兩個 field

output :輸出了2種格式,rubydebug 和 json

多個執行緒多個鎖

多個執行緒,每個執行緒都可以拿到自己指定的鎖,分別獲得鎖之後,執行synchronized方法體的內容。m1,m2兩個不同的物件呼叫printnum兩個執行緒都進到printnum方法裡了,如果m1進到執行緒裡,則列印結果輸出tar a num 100,然後輸出 而 的結果是m1,m2同時進來。總結...

python多個if python中的多個IF語句

我正在嘗試在特定單元格中列印內容。我知道在將內容提取到輸出之前要檢查的單元格。我正在使用多個if語句 18if linecount 5 if line 0 print line 0 a5 opfound 1 break if line 1 print line 1 b5 opfound 1 brea...

mysql 多個 Id MySQL查詢多個ID

從您的問題來看,我相信您當前的表結構如下 table user table project table shared id email id user id content id user id project id 1 james website.com 1 1 project for james...