简体   繁体   English

Prometheus 配置以忽略对 Kubernetes 中特定命名空间的指标的抓取

[英]Prometheus config to ignore scraping of metrics for a specific namespace in Kubernetes

Is there a way to configure prometheus to ignore scraping metrics for all the resources belonging to a particular namespace?有没有办法将 prometheus 配置为忽略属于特定命名空间的所有资源的抓取指标? I am not able to figure it out by reading the documentation.我无法通过阅读文档来弄清楚。

You can drop targets with relabel_config by using drop action.您可以使用drop操作使用relabel_config删除目标。 From the documentation :文档中:

drop : Drop targets for which regex matches the concatenated source_labels . drop :删除regex与串联的source_labels匹配的目标。

Example:例子:

  relabel_configs:
  # This will ignore scraping targets from 'ignored_namespace_1', 
  # 'ignored_namespace_2', and 'ignored_namespace_N'.
  - source_labels: [__meta_kubernetes_namespace]
    action: drop
    regex: ignored_namespace_1|ignored_namespace_2|ignored_namespace_N

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM