使用 Ingest 节点管道在 metricbeat 中进行条件索引创建数据流

Conditional indexing in metricbeat using Ingest node pipeline creates a datastream

我正在尝试使用摄取节点管道实现弹性命名空间的条件索引。我使用了下面的管道,但是当我在 metricbeat.yml 中添加管道时创建的索引是数据流的形式。

PUT _ingest/pipeline/sample-pipeline
{
  "processors": [
    {
      "set": {
        "field": "_index",
        "copy_from": "metricbeat-dev",
        "if": "ctx.kubernetes?.namespace==\"dev\"",
        "ignore_failure": true
      }
    }
  ]
}

预期的索引名称是 metricbeat-dev,但我在 _index 中获取的值为 .ds-metricbeat-dev。 当我使用一个文档进行测试时,这工作正常,但是当我在 yml 文件中实现它时,我得到以 .ds 开头的索引名称-为什么会这样?

模板更新:

{
   "metricbeat" : {
     "order" : 1,
     "index_patterns" : [
       "metricbeat-*"
     ],
     "settings" : {
       "index" : {
         "lifecycle" : {
           "name" : "metricbeat",
           "rollover_alias" : "metricbeat-metrics"
         },

如果您在索引模板中启用了数据流,则可能会创建数据流。这将取决于您如何配置优先级。如果未提及优先级,那么它将创建遗留索引,但如果在索引模板中提及高于 100 的优先级。然后这将创建一个数据流(遗留索引的优先级为 100,因此如果您想要数据流形式的索引,请使用大于 100 的优先级值)。

如果它创建了一个数据流并且它不是预期的,请检查是否有一个模板指向您正在编写的启用数据流的索引!这就是我的原因。

几个月来我一直在使用它,这是我观察到的!