【问题标题】:Subset of tag to a second output标记子集到第二个输出
【发布时间】:2016-07-19 01:31:09
【问题描述】:

我有一项服务正在尝试记录日志并将其发送到特定位置,具体取决于它们所指的内容。 Fluentd 是有道理的。目前,我只是把所有东西都扔到了 s3 上,而且效果很好。但是,我现在想要一个小子集(任何以短语“ACTION:”开头的行)也被发送到 mongo 数据库。我仍然希望将所有内容发送到 s3。

我这里有这个配置文件,当然不行

<source>
  @type  forward
  @id    input
  @label mainstream
  port   24224
</source>

<label @mainstream>

  <match foo.**>
    @type copy

    <store>
      @type s3

      ...
    </store>
    <store>
      @type rewrite_tag_filter
      rewriterule1 log "^ACTION:" foo.bar
    </store>

  </match>

  <match foo.bar>
    @type mongo

    ...
  </matc>
</label>

一旦我们到达第一个匹配标签,一切都会被收集并停止,rewrite_tag_filter 的正常行为似乎不会传递到 &lt;store&gt; 之后。

我尝试过的其他事情。

  • 复制 s3 store 所以它被使用了两次。但是我不希望我的 s3 输出被拆分。
  • 在不同的端口转发给它自己,通过不同的标签运行源,但它不会连接。

我确定我所问的并不是太疯狂。以前有人做过类似的事情吗?

【问题讨论】:

    标签: logging fluentd


    【解决方案1】:

    只需要注意重新标记的内容。如果您使用将被上述匹配匹配的东西,它不会继续前进,所以它需要有所不同。在这种情况下,即使标签不同,因为我是从 foo 开始的,所以它不会超过 &lt;match foo.**&gt;

    <source>
      @type  forward
      @id    input
      @label mainstream
      port   24224
    </source>
    
    <label @mainstream>
    
      <match foo.**>
        @type copy
    
        <store>
          @type s3
    
          ...
        </store>
        <store>
          @type rewrite_tag_filter
          # Changed tag from foo.bar to this
          rewriterule1 log "^ACTION:" totally.different.tag.name
        </store>
    
      </match>
    
    
      # the new totally.different.tag.name won't get caught by the 
      # first <match foo.**> so it will actually reach this one
      <match totally.different.tag.name>
        @type mongo
    
        ...
      </match>
    </label>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-11
      • 1970-01-01
      • 2018-05-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多