我正在使用EFK。
有人可以在此处提供有关如何通过流利的方法解析多行Java堆栈跟踪以在日志消息字段中推送整个stacktrace的帮助(我应该通过Kibana看到相同的ERROR / Exception stacktrace)。
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]
# 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>
fluent-plugin-detect-exceptions-with-error-0.0.3
fluent-plugin-detect-exceptions-0.0.12
fluent-plugin-concat-2.4.0
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