在json_exporter中执行jsonpath失败

问题描述 投票:0回答:1

目标是这样的:用鞭子转到 url 并从中获取信息,然后将此信息传输到警报。这样,当收到一封表明某物损坏的信件时,会立即写明具体损坏的情况(并且在支票中写明具体损坏的情况)。

我已进行健康检查。:

{
  "status": "OK",
  "description": "All good",
  "sql": null
}

我需要获取描述。结果我做了这样的配置,重点是例子:

modules:
  default:
    headers:
      MyHeader: MyHeaderValue
    metrics:
      - name: jsonhc
        type: object
        help: healthcheks description
        path: '{.description}'
        labels:
          env: prod
        values:
          status: 1
          description: '{.description}'

我得到的答案是这样的:

json_exporter | ts=2023-06-22T11:12:38.760Z caller=collector.go:136 level=error msg="无法执行jsonpath" err="未找到描述" path={.description} data=""一切都好”“

json_exporter | ts=2023-06-22T11:12:38.761Z caller=collector.go:88 level=error msg="无法提取指标值" path={.description} err="未找到说明" metric="Desc {fqName:“jsonhc_description”,帮助:“healthcheks 描述”,constLabels:{},variableLabels:[env]}

我得到的数据是正确的,但我不能将其视为警报。当我检查目标的卷曲时,它不在那里。

我跑了:

#curl http://localhost:7979/probe

并收到:

目标参数缺失

我尝试了

path
变量的不同变体(例如
'$.*' and '{ [*] }'
),但它不起作用。请帮我弄清楚这是一个错误还是我做错了什么?

json prometheus metrics exporter prometheus-json-exporter
1个回答
0
投票

所以问题出在 Healthcheck 本身。这才是本来应该的样子。

{
  "healthcheck": [
    {
      "status": "OK",
      "description": "All good",
      "sql": null
    }
  ]
}

此后,该模块按照我想要的方式工作。 另外,为了实现我的想法,我需要一个这样的模块。

path: '{.healthcheck[?(@.status != "OK")]}'

然后,如果没有“确定”,我设置了一个警报,以便在状态 == 1 时向我发送电子邮件

© www.soinside.com 2019 - 2024. All rights reserved.