【问题标题】:Custom logstash index in Fluend with timestampFluend中带有时间戳的自定义logstash索引
【发布时间】:2019-07-09 19:37:01
【问题描述】:

我正在尝试设置一个流利的服务来收集日志并将它们发送到弹性搜索。

一切都很好,除了我无法获得自定义索引名称并保持时间戳类似于 logstash_format: true 的时间戳。

这是我的 fluent.conf 文件:

<source>
  @type forward
  port 24224
  bind 0.0.0.0
</source>
<match *.**>
  @type copy
  <store>
    @type elasticsearch
    hosts hostaddressandport
    user theuser
    password password
    include_tag_key true
    tag_key @log_name
    index_name myindex-%Y.%m
    <buffer>
      flush_interval 3s
    </buffer>
  </store>
</match>

索引是在弹性字面上创建的,它显示myindex-%Y.%m 我已经尝试过 myindex-${%Y.%m} 并获得相同的行为。

如果我改用logstash_format: true,那么我会得到一个类似logstash-2019.07.09 的索引,但我不希望这样。

这是我从 https://docs.fluentd.org/output/elasticsearch 获得想法的地方,但我没有看到预期的行为。

我在上面提到的文档中找到了以下内容:

<buffer tag, time>
  timekey 1h # chunks per hours ("3600" also available)
</buffer>

但它很模糊,我不明白 chunk_keys 是什么。

【问题讨论】:

  • 你能试试这个,让我知道它是否有效吗? index_name "myindex-%Y.%m" 将引号移到外面。
  • 对我也不起作用?你找到解决办法了吗

标签: logstash fluentd


【解决方案1】:

您可以使用logstash_formatlogstash_prefix 更改索引前缀。不过,这不会使用您需要的日期格式。

logstash_format true
logstash_prefix myindex

【讨论】:

    【解决方案2】:

    请使用此配置,您将获得索引名称的自定义日期格式

    配置文件

    <source>
      @type forward
      port 24224
      bind 0.0.0.0
    </source>
    <match *.**>
      @type copy
      <store>
        @type elasticsearch
        hosts hostaddressandport
        user theuser
        password password
        include_tag_key true
        tag_key @log_name
        logstash_format true
        logstash_dateformat %Y.%m
        logstash_prefix index_name
        <buffer>
          flush_interval 3s
        </buffer>
      </store>
    </match>
    

    输出

    indexname-2021.08
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-06
      • 1970-01-01
      • 2021-11-16
      • 2019-11-08
      • 2015-05-04
      • 2023-03-30
      • 1970-01-01
      相关资源
      最近更新 更多