过滤启用的收集器 [英] Filtering Enabled Collectors

查看:68
本文介绍了过滤启用的收集器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Prometheus 节点导出器没有一种简单的方法来禁用所有默认指标而不向进程传递 20 个标志.在 文档 中,看起来可能有更简单的获取方式仅相关指标:

The Prometheus node exporter does not have a simple way to disable all default metrics without passing 20 flags to the process. In the documentation it looks like there might be an easier way to fetch only the relevant metrics:

过滤启用的收集器

...

对于高级使用,可以向 node_exporter 传递一个可选的收集器列表来过滤指标.collect[] 参数可以多次使用.在 Prometheus 配置中,您可以在抓取配置下使用此语法.

For advanced use the node_exporter can be passed an optional list of collectors to filter metrics. The collect[] parameter may be used multiple times. In Prometheus configuration you can use this syntax under the scrape config.

params:
  collect[]:
    - foo
    - bar

这对于让不同的 Prometheus 服务器从节点收集特定指标很有用.

This can be useful for having different Prometheus servers collect specific metrics from nodes.

我的假设是您将 params 直接放在您的 scrape_config 因为有一个匹配的 params 字段.但是,collect[] 下到底应该做什么?示例 foobar 的描述性再好不过了.它是命令行参数(例如--collector.cpu")、收集器名称(例如cpu")、收集器指标名称(例如node_cpu")、实际指标(例如node_cpu_seconds_total"吗?"),还是其他什么?

My assumption is you put the params directly under your scrape_config because there's a matching params field. However, what exactly is supposed to go under collect[]? The examples foo and bar couldn't be any less descriptive. Is it the command-line argument (e.g., "--collector.cpu"), the collector name (e.g., "cpu"), the collector metric name (e.g., "node_cpu"), the actual metric (e.g., "node_cpu_seconds_total"), or something else?

推荐答案

还有另一种通用的解决方案,可以与所有导出器一起使用.relabel_map_config 是一个配置选项,可以在里面设置普罗米修斯配置文件.如文档中所述:

There is another solution that is generic and can work with all exporters. relabel_map_config is a configuration option that can be set inside the prometheus config file. As specified in the documentation:

这样做的一个用途是将过于昂贵的时间序列列入黑名单摄取.

One use for this is to blacklist time series that are too expensive to ingest.

因此,您可以删除或保留与正则表达式匹配的指标.例如,要仅存储节点导出器收集的 cpu 指标,您可以在 prometheus.yml 文件中使用以下内容:

Thus you can drop or keep metrics that match a regex. For instance, to only store the cpu metrics collected by the node exporter, you can use the following inside the prometheus.yml file:

scrape_configs:
 - job_name: node
   static_configs:
    - targets:
       - localhost:9100
   metric_relabel_configs:
    - source_labels: [__name__]
      regex: node_cpu_.*
      action: keep

这篇关于过滤启用的收集器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆