我成功地从我的应用程序日志中发送了日志,我从这个教程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.logpom依赖
<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]}"
}
}发布于 2019-04-12 08:13:55
您没有使用Filebeat。使用<destination>localhost:4560</destination>,您可以直接将其发送到Logstash。这很好,因为您不需要关心日志文件、解析它们或填满磁盘。缺点是,如果网络关闭,你将不会收到任何消息,Logback将只缓冲我记忆中200MB的日志-所以你可能会在长时间的停机期间丢失日志。
PS:当使用此配置时,您可以从logstash.conf中删除beats {块,因为您不会使用它(以及文件节拍)。
https://stackoverflow.com/questions/55634857
复制相似问题