使用 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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...