条件索引在摄取节点管道中不起作用



Am正在尝试实现一个启用数据流的索引模板,然后在摄取节点管道中设置包含。这样我就可以用下面提到的索引格式获得指标:

.ds度量kubernetesnamespace

我以前也尝试过,我做了上面提到的这些事情,它以这样的格式给出了度量,但现在当我实现同样的度量时,它不会改变我的索引中的任何内容。我在openshift集群中看不到任何日志,所以摄入似乎工作正常(当我添加一个文档并测试它工作正常时(

PUT _ingest/pipeline/metrics-index
{
"processors": [
{
"set": {
"field": "_index",
"value": "metrics-{{kubernetes.namespace}}",
"if": "ctx.kubernetes?.namespace=="dev""
}
}
]
}

这是我用于索引的摄取节点条件。

metricbeatConfig:
metricbeat.yml: |
metricbeat.modules:
- module: kubernetes
enabled: true
metricsets:
- state_node
- state_daemonset
- state_deployment
- state_replicaset
- state_statefulset
- state_pod
- state_container
- state_job
- state_cronjob
- state_resourcequota
- state_service
- state_persistentvolume
- state_persistentvolumeclaim
- state_storageclass
- event

由于您使用的是Metricbeat,因此您有另一种更好的方法来实现这一点。

只需像这样配置elasticsearch输出:

output.elasticsearch:
hosts: ["http://<host>:<port>"]
indices:
- index: "%{[kubernetes.namespace]}"
mappings:
dev: "metrics-dev"
default: "metrics-default"

或者像这样:

output.elasticsearch:
hosts: ["http://<host>:<port>"]
indices:
- index: "metrics-%{[kubernetes.namespace]}"
when.equals:
kubernetes.namespace: "dev"
default: "metrics-default"

或者,如果你有很多不同的名称空间,并且你不想管理不同的映射,也可以这样做:

output.elasticsearch:
hosts: ["http://<host>:<port>"]
index: "metrics-%{[kubernetes.namespace]}"

在弹性堆栈中创建数据流的步骤:

  1. 创建ILM策略
  2. 创建一个索引模板,该模板的索引模式与度量/日志的索引模式相匹配。(在索引模板中设置主碎片/副本碎片的数量和映射(
  3. 在摄取管道中设置条件。(请确保不存在此类索引(

如果满足这些条件,它将创建一个数据流,日志/度量将有一个以.ds-开头的索引,并且它将隐藏在索引管理中。

在我的情况下,问题是我没有足够的权限来创建自定义索引。当我查看我的OpenShift日志时,我发现metricbeat在抱怨特权。所以我给了超级用户权限,然后使用摄取节点设置条件索引

PUT _ingest/pipeline/metrics-index
{
"processors": [
{
"set": {
"field": "_index",
"value": "metrics-{{kubernetes.namespace}}",
"if": "ctx.kubernetes?.namespace=="dev""
}
}
]
}

最新更新