Logstash 如何设置日志存储以将日志转发到另一个日志存储?
我有几个安装了logstash的web服务器,还有一个也安装了logstash的日志服务器 我希望使用logstash将web服务器/var/log/nginx/*中的日志转发到日志服务器。可能吗 web服务器:Logstash 如何设置日志存储以将日志转发到另一个日志存储?,logstash,Logstash,我有几个安装了logstash的web服务器,还有一个也安装了logstash的日志服务器 我希望使用logstash将web服务器/var/log/nginx/*中的日志转发到日志服务器。可能吗 web服务器: input { file { path => "/var/log/nginx/*log" } } output { tcp { host => "log.server.ip" port => 12345 } } 日志服务器:
input {
file {
path => "/var/log/nginx/*log"
}
}
output {
tcp {
host => "log.server.ip"
port => 12345
}
}
日志服务器:
input {
tcp {
port => 12345
}
}
output {
stdout {
codec => "rubydebug"
}
}
但不会转发任何日志。正确的方法是在web服务器上使用或最好使用最新的logstash forwarder替换工具,并在日志服务器上使用logstash 因此,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
input {
file {
path => "/var/log/nginx/*log"
}
}
output {
lumberjack {
hosts => "log.server.ip"
port => 12345
ssl_certificate => "/path/to/certificate.pub"
}
}
日志服务器上的日志存储配置如下所示
input {
beats {
port => 12345
}
}
output {
stdout {
codec => "rubydebug"
}
}
如果您不想在web服务器上安装Filebeat,因为您想利用现有的日志存储,那么也可以这样做。您的web服务器上的日志存储配置需要使用以下命令:
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
input {
file {
path => "/var/log/nginx/*log"
}
}
output {
lumberjack {
hosts => "log.server.ip"
port => 12345
ssl_certificate => "/path/to/certificate.pub"
}
}
在日志服务器上,您需要使用:
正确的方法是在web服务器上使用或最好使用最新的logstash转发器替换工具,并在日志服务器上使用logstash 因此,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
input {
file {
path => "/var/log/nginx/*log"
}
}
output {
lumberjack {
hosts => "log.server.ip"
port => 12345
ssl_certificate => "/path/to/certificate.pub"
}
}
日志服务器上的日志存储配置如下所示
input {
beats {
port => 12345
}
}
output {
stdout {
codec => "rubydebug"
}
}
如果您不想在web服务器上安装Filebeat,因为您想利用现有的日志存储,那么也可以这样做。您的web服务器上的日志存储配置需要使用以下命令:
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
input {
file {
path => "/var/log/nginx/*log"
}
}
output {
lumberjack {
hosts => "log.server.ip"
port => 12345
ssl_certificate => "/path/to/certificate.pub"
}
}
在日志服务器上,您需要使用: