如何设置 logstash 以将日志转发到另一个 logstash?
How to setup logstash to forward logs to another logstash?
我有几个安装了 logstash 的 Web 服务器,我有一个也安装了 logstash 的日志服务器。
我想将 Web 服务器中的日志转发 /var/log/nginx/*log
到使用 logstash 的日志服务器。可能吗?
网络服务器:
input {
file {
path => "/var/log/nginx/*log"
}
}
output {
tcp {
host => "log.server.ip"
port => 12345
}
}
日志服务器:
input {
tcp {
port => 12345
}
}
output {
stdout {
codec => "rubydebug"
}
}
但没有转发任何日志。
正确的做法是在日志服务器上使用logstash-forwarder or preferably the newest Filebeat (logstash-forwarder replacement) tool on the web server and Logstash with the beats
input plugin。
因此您在 Web 服务器上的 Filebeat 配置应如下所示:
filebeat:
# List of prospectors to fetch data.
prospectors:
# Each - is a prospector. Below are the prospector specific configurations
-
paths:
- "/var/log/nginx/*.log"
document_type: weblog
fields:
service: nginx
output:
logstash:
# The Logstash hosts.
hosts:
- log.server.ip:12345
您在日志服务器上的 Logstash 配置将如下所示
input {
beats {
port => 12345
}
}
output {
stdout {
codec => "rubydebug"
}
}
如果你不想在网络服务器上安装 Filebeat,因为你想利用现有的 Logstash,这也是可以的。 Web 服务器上的 Logstash 配置需要使用 lumberjack
output,如下所示:
input {
file {
path => "/var/log/nginx/*log"
}
}
output {
lumberjack {
hosts => "log.server.ip"
port => 12345
ssl_certificate => "/path/to/certificate.pub"
}
}
并且在您的日志服务器上,您需要使用 lumberjack
input:
input {
lumberjack {
port => 12345
ssl_certificate => "/path/to/certificate.cer"
ssl_key => "/path/to/certificate.key"
}
}
output {
stdout {
codec => "rubydebug"
}
}
我有几个安装了 logstash 的 Web 服务器,我有一个也安装了 logstash 的日志服务器。
我想将 Web 服务器中的日志转发 /var/log/nginx/*log
到使用 logstash 的日志服务器。可能吗?
网络服务器:
input {
file {
path => "/var/log/nginx/*log"
}
}
output {
tcp {
host => "log.server.ip"
port => 12345
}
}
日志服务器:
input {
tcp {
port => 12345
}
}
output {
stdout {
codec => "rubydebug"
}
}
但没有转发任何日志。
正确的做法是在日志服务器上使用logstash-forwarder or preferably the newest Filebeat (logstash-forwarder replacement) tool on the web server and Logstash with the beats
input plugin。
因此您在 Web 服务器上的 Filebeat 配置应如下所示:
filebeat:
# List of prospectors to fetch data.
prospectors:
# Each - is a prospector. Below are the prospector specific configurations
-
paths:
- "/var/log/nginx/*.log"
document_type: weblog
fields:
service: nginx
output:
logstash:
# The Logstash hosts.
hosts:
- log.server.ip:12345
您在日志服务器上的 Logstash 配置将如下所示
input {
beats {
port => 12345
}
}
output {
stdout {
codec => "rubydebug"
}
}
如果你不想在网络服务器上安装 Filebeat,因为你想利用现有的 Logstash,这也是可以的。 Web 服务器上的 Logstash 配置需要使用 lumberjack
output,如下所示:
input {
file {
path => "/var/log/nginx/*log"
}
}
output {
lumberjack {
hosts => "log.server.ip"
port => 12345
ssl_certificate => "/path/to/certificate.pub"
}
}
并且在您的日志服务器上,您需要使用 lumberjack
input:
input {
lumberjack {
port => 12345
ssl_certificate => "/path/to/certificate.cer"
ssl_key => "/path/to/certificate.key"
}
}
output {
stdout {
codec => "rubydebug"
}
}