在此 java spring 启动应用程序中使用 logstash 时如何调用 filebeats?
How does filebeats get invoked when using logstash in this java spring boot app?
我成功地从我的应用程序 logstash 发送日志,我从本教程开始 http://www.andrew-programming.com/2018/09/18/integrate-springboot-application-with-elk-and-filebeat/ 然后轻松地将我的代码实现到我自己的应用程序中。
我的问题是我没有在我的应用程序中的任何地方提到 filebeats,它是如何使用的?
一切正常,但很想知道 filebeats 是从哪里来的,是通过 pom 文件中的 logstash 依赖项实现的吗?
logback-spring.xml
<!DOCTYPE configuration>
<configuration>
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>localhost:4560</destination>
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder">
</encoder>
</appender>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<root level="INFO">
<appender-ref ref="LOGSTASH" />
<!--<appender-ref ref="CONSOLE" />-->
</root>
</configuration>
application.properties
logging.file=/tmp/filebeatDemoApp.log
pom 依赖
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>5.1</version>
</dependency>
logstash.conf
input {
tcp {
port => 4560
codec => json_lines
}
beats {
host => "127.0.0.1"
port => "5044"
}
}
output{
stdout { codec => rubydebug }
elasticsearch {
hosts => ["localhost:9200"]
index => "app-%{+YYYY.MM.dd}"
document_type => "%{[@metadata][type]}"
}
}
您没有使用 Filebeat。使用 <destination>localhost:4560</destination>
,您将直接发送到 Logstash。这很好,因为您不需要关心日志文件、解析它们或填满磁盘。缺点是,如果网络中断,您将不会收到任何消息,并且 Logback 只会缓冲我记得的 200MB 日志——因此您可能会在长时间中断期间丢失日志。
PS:使用此配置时,您可以从 logstash.conf 中删除 beats {
块,因为您没有使用它(也没有使用 Filebeat)。
我成功地从我的应用程序 logstash 发送日志,我从本教程开始 http://www.andrew-programming.com/2018/09/18/integrate-springboot-application-with-elk-and-filebeat/ 然后轻松地将我的代码实现到我自己的应用程序中。
我的问题是我没有在我的应用程序中的任何地方提到 filebeats,它是如何使用的?
一切正常,但很想知道 filebeats 是从哪里来的,是通过 pom 文件中的 logstash 依赖项实现的吗?
logback-spring.xml
<!DOCTYPE configuration>
<configuration>
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>localhost:4560</destination>
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder">
</encoder>
</appender>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<root level="INFO">
<appender-ref ref="LOGSTASH" />
<!--<appender-ref ref="CONSOLE" />-->
</root>
</configuration>
application.properties
logging.file=/tmp/filebeatDemoApp.log
pom 依赖
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>5.1</version>
</dependency>
logstash.conf
input {
tcp {
port => 4560
codec => json_lines
}
beats {
host => "127.0.0.1"
port => "5044"
}
}
output{
stdout { codec => rubydebug }
elasticsearch {
hosts => ["localhost:9200"]
index => "app-%{+YYYY.MM.dd}"
document_type => "%{[@metadata][type]}"
}
}
您没有使用 Filebeat。使用 <destination>localhost:4560</destination>
,您将直接发送到 Logstash。这很好,因为您不需要关心日志文件、解析它们或填满磁盘。缺点是,如果网络中断,您将不会收到任何消息,并且 Logback 只会缓冲我记得的 200MB 日志——因此您可能会在长时间中断期间丢失日志。
PS:使用此配置时,您可以从 logstash.conf 中删除 beats {
块,因为您没有使用它(也没有使用 Filebeat)。