我正在使用 EFK。
有人可以帮助这里如何通过 fludd 解析多行 java 堆栈跟踪,以便将整个堆栈跟踪推送到日志消息字段中(我应该通过 Kibana 看到相同的错误/异常堆栈跟踪)。
我需要解析以下错误堆栈跟踪:
2019-06-10 16:51:48.789 INFO 11360 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6293 ms
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
2019-06-10 16:51:52.633 ERROR 11360 --- [ost-startStop-1] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
java.sql.SQLException: Access denied for user 'root'@'ec2-13-233-117-154.ap-south-1.compute.amazonaws.com' (using password: YES)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.15.jar:8.0.15]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.15.jar:8.0.15]
我的flutter.conf文件配置如下:
# fluentd/conf/fluent.conf
<source>
@type forward
port 24224
bind 0.0.0.0
<parse>
@type multiline
format_firstline /\d{4}-\d{1,2}-\d{1,2}/
format /(?<time>[^ ]* [^ ]*) (?<path>[^ ]*) (?<method>[^ ]*) (?<message>[^ ](.*?(\n)).*$)/
</parse>
</source>
<match **>
#@type copy
@type detect_exceptions
<store>
@type elasticsearch
host elasticsearch
port 9200
logstash_format true
logstash_prefix fluentd
logstash_dateformat %Y%m%d
include_tag_key true
type_name access_log
tag_key @log_name
flush_interval 1s
</store>
</match>
尝试了以下3个插件,但没有得到所需的输入:
fluent-plugin-detect-exceptions-with-error-0.0.3
fluent-plugin-detect-exceptions-0.0.12
fluent-plugin-concat-2.4.0
当我使用上述配置时,我在 fluidd 容器日志中收到以下错误:
2019-08-02 12:46:23 +0000 [error]: config error file="/fluentd/etc/fluent.conf" error_class=Fluent::ConfigError error="Unknown output plugin 'detect_exceptions'. Run 'gem search -rd fluent-plugin' to find plugins"
最佳答案
确保您安装了该插件。 您可以使用以下命令安装它
gem install fluent-plugin-detect-exceptions
我在我的代理上使用以下配置。请注意,在检查消息是否是堆栈跟踪之前,我使用 Fluent-plugin-rewrite-tag-filter 进行重新标记。
<match tag>
@type rewrite_tag_filter
<rule>
key container_id
pattern /(.+)/
tag removeme.${tag}.$1
</rule>
</match>
<match removeme**>
@type detect_exceptions
remove_tag_prefix removeme
message message
languages java, python
multiline_flush_interval 1
</match>
<match tag_without_prefix**>
@type elasticsearch
host elasticsearch
port 9200
logstash_format true
...
</match>
或者您可以使用此示例中的 @label 参数: https://github.com/GoogleCloudPlatform/fluent-plugin-detect-exceptions/issues/19#issuecomment-406628486
关于java - 如何解析 fluidd 中输入的多行 java ERROR/Exception 堆栈跟踪(我应该通过 Kibana 看到相同的 ERROR/Exception 堆栈跟踪),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57327257/