【发布时间】:2021-09-18 15:15:34
【问题描述】:
我使用代码将 json 数据从 Yarn REST API 转换为 Prometheus 数据类型: https://github.com/prometheus-community/json_exporter。 但是,它打印错误:
level=error ts=2021-07-08T06:31:03.712Z caller=collector.go:83 msg="无法提取指标值" path={.capacity} err="未找到容量"指标="Desc{fqName: "queues_capacity", help: "队列信息", constLabels: {}, variableLabels: [type]}"
我想知道是我的 YAML 文件配置有问题(例如嵌套 json 方面)还是只是代码的原因。
我的 yaml 配置是:
metrics:
- name: queues
path: "{ .scheduler.schedulerInfo.queues.queue }"
help: information on queues
type: object
labels:
type: '{.type}'
values:
capacity: '{.capacity}'
而部分json文件是:
{
"scheduler": {
"schedulerInfo": {
"type": "capacityScheduler",
"capacity": 100,
"usedCapacity": 1.0526316,
"maxCapacity": 100,
"queueName": "root",
"queues": {
"queue": [
{
"type": "capacitySchedulerLeafQueueInfo",
"capacity": 10,
"usedCapacity": 10.526316,
"maxCapacity": 100,
【问题讨论】:
-
会不会是响应json中的field key容量不一致,有些情况下json对象中根本没有返回?
-
我查了一下,队列对象一共有五个,每个都有容量字段