我試圖在運行ubuntu 16.04的aws ec2實例上使用systemd運行logstash。我在機器上安裝了heroku工具欄。正常運行管道(通過bin/logstash.bat)可以正常工作,並且事件被攝入(然而在幾分鐘後,得到「請求超時」錯誤並且管道停止,這是一個單獨的問題)。在Ubuntu(logstash 5.2.1)上運行的logstash-input-heroku服務
但是,當我嘗試在systemd上運行服務時,我得到錯誤,不知道這兩種類型的錯誤是否有關係。第一個是SSL錯誤:
Error: no cipher match (OpenSSL::SSL::SSLError)
[2017-02-15T13:08:44,037][ERROR][logstash.pipeline ] A plugin had an unrecoverable error. Will restart this plugin. Plugin: "xxxxxx", codec=>"^%{TIMESTAMP_ISO8601} %{WORD}\[\w+(\.\d+)?\]:(\s{3,}| \})", what=>"previous", id=>"032c3b317ae49982945ec7e8fbf11224be98f237-3", enable_metric=>true, negate=>false, charset=>"UTF-8", multiline_tag=>"multiline", max_lines=>500, max_bytes=>10485760>, id=>"032c3b317ae49982945ec7e8fbf11224be98f237-4", enable_metric=>true>
第二個問題是Heroku的工具區似乎被提示輸入憑據:
Feb 15 13:08:43 ip-10-0-1-216 logstash[4402]: Enter your Heroku credentials.
Feb 15 13:08:43 ip-10-0-1-216 logstash[4402]: Email: Password (typing will be hidden):
我logstash配置:
input {
heroku {
app => "xxx-1"
codec => multiline {
pattern => "^%{TIMESTAMP_ISO8601} %{WORD}\[\w+(\.\d+)?\]:(\s{3,}| \})"
what => "previous"
}
}
heroku {
app => "xxx-2"
codec => multiline {
pattern => "^%{TIMESTAMP_ISO8601} %{WORD}\[\w+(\.\d+)?\]:(\s{3,}| \})"
what => "previous"
}
}
heroku {
app => "xxx-3"
codec => multiline {
pattern => "^%{TIMESTAMP_ISO8601} %{WORD}\[\w+(\.\d+)?\]:(\s{3,}| \})"
what => "previous"
}
}
heroku {
app => "xxx-4"
codec => multiline {
pattern => "^%{TIMESTAMP_ISO8601} %{WORD}\[\w+(\.\d+)?\]:(\s{3,}| \})"
what => "previous"
}
}
}
filter {
grok {
break_on_match => true
patterns_dir => ["./grok_patterns"]
match => { "message" => [
"^%{TIMESTAMP_ISO8601:timestamp} %{WORD:heroku_source}\[%{DYNO:dyno}\]: %{LEVEL:level}: HTTP %{OPT_NOT_SPACE_COMMA:organization}, %{OPT_NOT_COMMA:user}, %{OPT_NOT_COMMA:device}, %{WORD:method} %{ENDPOINT:endpoint}%{QUERY:query} \[%{INT:responseCode:int}\].*? \(p%{INT:nodeProcess:int}\) \(%{INT:responseTime:int}ms\).*$",
"^%{TIMESTAMP_ISO8601:timestamp} %{WORD:heroku}\[%{WORD:component}\]: at=\w+ method=%{WORD:method} path=\"%{ENDPOINT:endpoint}\??%{QUERY:query}\" .*?fwd=\"%{IP:site_ip}\" dyno=%{DYNO:dyno} .*?service=%{INT:responseTime:int}ms status=%{INT:responseCode:int} bytes=%{INT:sizeBytes:int}.*?$",
"^%{TIMESTAMP_ISO8601:timestamp} %{WORD:heroku_source}\[%{DYNO:dyno}\]: (?<data>.*)"
] }
add_field => { "endpoint_template" => "%{endpoint}" }
}
mutate {
gsub => ["endpoint_template", "[0-9a-f]{24}", "ID"]
add_field => { "type" => "heroku" }
}
if ![heroku_source] {
geoip {
source => "site_ip"
}
mutate {
add_field => { "heroku_source" => "heroku" }
}
}
}
output {
elasticsearch {
hosts => [ "aws-es-endpoint:443" ]
ssl => true
}
}
(我肯定可以改進)
我試過以root身份運行服務,但結果是一樣的。只是爲了澄清,這個工作:
/usr/share/logstash/bin/logstash --path.settings /etc/logstash/
雖然這並不:
sudo systemctl start logstash
這是一個乾淨的安裝logstash 5.2.1以下的procedures on elastic的。 Systemd也根據their procedures運行,以便它執行與我手動執行相同的命令。 cat logstash.service
輸出:
[Unit]
Description=logstash
[Service]
Type=simple
User=logstash
Group=logstash
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
# Prefixing the path with '-' makes it try to load, but if the file doesn't
# exist, it continues onward.
EnvironmentFile=-/etc/default/logstash
EnvironmentFile=-/etc/sysconfig/logstash
ExecStart=/usr/share/logstash/bin/logstash "--path.settings" "/etc/logstash"
Restart=always
WorkingDirectory=/
Nice=19
LimitNOFILE=16384
[Install]
WantedBy=multi-user.target
(結果是一樣的,當我註釋掉用戶及以上組)