gpt4 book ai didi

java - LogstashTcpSocketAppender 未将日志发送到 Logstash

转载 作者:行者123 更新时间:2023-12-02 12:54:20 25 4
gpt4 key购买 nike

我正在将 Docker ELK 堆栈与我的 Spring Boot 应用程序一起使用。所有三个组件均已启动并运行于 http://192.168.99.100:5601/ , http://192.168.99.100:9200/和 192.168.99.100:5000 分别。

我的 logback-spring.xml 看起来像:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<appender name="stash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<keepAliveDuration>5 minutes</keepAliveDuration>
<reconnectionDelay>10 second</reconnectionDelay>
<waitStrategyType>sleeping</waitStrategyType>
<destination>192.168.99.100:5000</destination>
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<mdc/> <!-- MDC variables on the Thread will be written as JSON fields-->
<context/> <!--Outputs entries from logback's context -->
<logLevel/>
<loggerName/>
<pattern>
{
"timestamp": "%date{\"yyyy-MM-dd'T'HH:mm:ss,SSSXXX\", UTC}",
"level": "%level",
"logger": "%logger",
"message": "%message",
"logstashMarkers": "%marker"
}
</pattern>
<threadName/>
<message/>
<logstashMarkers/> <!-- Useful so we can add extra information for specific log lines as Markers-->
<arguments/> <!--or through StructuredArguments-->
<stackTrace>
<fieldName>stackTrace</fieldName>
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<exclude>net\.sf\.cglib\..*</exclude>
<maxDepthPerThrowable>30</maxDepthPerThrowable>
<rootCauseFirst>true</rootCauseFirst>
</throwableConverter>
</stackTrace>
</providers>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="stash"/>
</root>

问题是我无法在 Kibana 中看到我的日志,并且我怀疑 LogstashTcpSocketAppender 没有将日志发送到 Logstash。有没有办法可以验证 LogstashTcpSocketAppender 是否正在向 Logstash 发送日志?

最佳答案

-检查消息是否发送到elasticsearsh: 192.168.99.100:9200/_搜索

- 检查索引是否已创建: 192.168.99.100:9200/_cat/indices

-实际上,如果您想查看结果,您应该在 kibana 的索引中创建(与在 elasticsearh 中创建的名称/模式相同):

enter image description here

并在kibana中通过修改时间进行验证:

enter image description here

关于java - LogstashTcpSocketAppender 未将日志发送到 Logstash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44481187/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com