如何解决使用 Fluentd 问题在 Kubernetes 中登录 ASP.Net Core sidecar
我有一个 K8s 部署,它沿着它的 sidecar 部署一个应用程序的容器(一个 ASP.Net Core 应用程序)以进行日志记录。我使用 Serilog 的控制台接收器来登录标准输出。我还有一个配置映射来存储 fluentd 的配置。关于这部分的一篇非常好的文章是this。
我想要做的是使用 sidecar 将日志从应用程序转发到 Elastic Search。我使用相应的输出插件来做到这一点。但是应该在源代码和过滤器标签中使用什么来实现这一点?
fluentd的配置如下:
<source>
@type forward
port 24224
bind 0.0.0.0
</source>
<filter *.**="">
@type parser
key_name log
format json
reserve_data true
</filter>
<match *.**="">
@type copy
<store>
@type elasticsearch
host 192.168.1.41
port 9200
logstash_format true
logstash_prefix fluentd
logstash_dateformat %Y%m%d
include_tag_key true
user elastic
index_name "ap-*"
password xxxxxxxxx
type_name access_log
tag_key @log_name
flush_interval 1s
</store>
<store>
@type stdout
</store>
</match>
使用此配置,fluentd 工作正常,但我没有收到任何转发到 Elastic Search 的消息。
这里是 fluentd 的日志
2021-04-08 11:37:25 +0000 [info]: parsing config file is succeeded path="/fluentd/etc/fluent.conf"
2021-04-08 11:37:25 +0000 [info]: gem 'fluent-plugin-elasticsearch' version '5.0.2'
2021-04-08 11:37:25 +0000 [info]: gem 'fluentd' version '1.12.2'
2021-04-08 11:37:25 +0000 [info]: 'flush_interval' is configured at out side of <buffer>. 'flush_mode' is set to 'interval' to keep existing behavIoUr
2021-04-08 11:37:25 +0000 [info]: using configuration file: <ROOT>
<source>
@type forward
port 24224
bind "0.0.0.0"
</source>
<filter *.**="">
@type parser
key_name "log"
format json
reserve_data true
<parse>
@type json
</parse>
</filter>
<match *.**="">
@type copy
<store>
@type "elasticsearch"
host "192.168.1.41"
port 9200
logstash_format true
logstash_prefix "fluentd"
logstash_dateformat "%Y%m%d"
include_tag_key true
user "elastic"
index_name "catalogapi-*"
password xxxxxx
type_name "access_log"
tag_key "@log_name"
flush_interval 1s
<buffer>
flush_interval 1s
</buffer>
</store>
<store>
@type "stdout"
</store>
</match>
</ROOT>
2021-04-08 11:37:25 +0000 [info]: starting fluentd-1.12.2 pid=7 ruby="2.6.6"
2021-04-08 11:37:25 +0000 [info]: spawn command to main: cmdline=["/usr/local/bin/ruby","-Eascii-8bit:ascii-8bit","/usr/local/bundle/bin/fluentd","-c","/fluentd/etc/fluent.conf","-p","/fluentd/plugins","--under-supervisor"]
2021-04-08 11:37:26 +0000 [info]: adding filter pattern="*.**=\"\"" type="parser"
2021-04-08 11:37:26 +0000 [info]: adding match pattern="*.**=\"\"" type="copy"
2021-04-08 11:37:26 +0000 [info]: #0 'flush_interval' is configured at out side of <buffer>. 'flush_mode' is set to 'interval' to keep existing behavIoUr
2021-04-08 11:37:26 +0000 [warn]: #0 Detected ES 7.x: `_doc` will be used as the document `_type`.
2021-04-08 11:37:26 +0000 [info]: adding source type="forward"
2021-04-08 11:37:26 +0000 [info]: #0 starting fluentd worker pid=16 ppid=7 worker=0
2021-04-08 11:37:26 +0000 [info]: #0 listening port port=24224 bind="0.0.0.0"
我进行了多次尝试,使用各种配置,但没有任何效果。
提前感谢您的时间。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。