go - Prometheus Exporter - Filtering targets
问题描述
I'm in the process of writing a Prometheus Exporter in Go to expose metrics pushed from AIX severs. The AIX servers push their metrics (in json) to a central listener (the exporter program) that converts them to standard Prometheus metrics and exposes them for scraping.
The issue I have is that the hostname for the metrics is extracted from the pushed json. I store this as a label in each metric. E.g. njmon_memory_free{lpar="myhostname"}. While this works, it's less than ideal as there doesn't seem to be a way to relabel this to the usual instance
label (njmon_memory_free{instance="myhostname"}. The Prometheus relabelling happens before the scrape so the lpar label isn't there to be relabelled.
One option seems to be to rewrite the exporter so that the Prometheus server probes defined targets, each target being the lpar. In order for that to work, I'd need a means to filter the stored metrics by lpar so only metrics relating to the target/lpar are returned. Is this a practical solution or am I forced to create a dedicated listener or url for every lpar?
解决方案
所以我正在修正我在评论中给出的答案,因为它对作者有帮助。
- 在导出器中使用“实例”标签,而不是“lpar”(更改导出器代码)
- 在 Prometheus scrape_config 中使用“honor_labels: true”
推荐阅读
- c# - 在 C# 中为泛型参数赋予默认值
- kubernetes - 无法在 Docker/Kubernetes 容器内执行 netcat
- c - 如何以整数形式保存 for 循环的输出?
- reactjs - 使用本机反应在当前行上显示激活的活动指示器
- python-3.x - 使用 python 函数堆叠函数模型会导致 Keras 中的图形断开连接
- postgresql - 如何在spring数据jpa查询的where子句中编写hstore列
- eclipse - Eclipse 基本语法字体更改
- javascript - 使用循环和 ifs 在 componentDidMount 中设置状态
- jquery - 如何使用 JQuery 检查 Ajax Control Toolkit CollapsiblePanelExtender 是否折叠?
- docker - 运行 npm install 时 Pod 进入驱逐状态