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

Ama*_*man 3 configuration monitoring kubernetes prometheus istio

有没有办法配置普罗米修斯忽略属于特定命名空间的所有资源的抓取指标?我无法通过阅读文档来弄清楚。

ane*_*yte 6

您可以relabel_config使用drop操作来删除目标。从文档中:

drop:删除与regex串联的 . 匹配的目标source_labels

例子:

  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
Run Code Online (Sandbox Code Playgroud)