Prometheus metrics_path 被编码

Prometheus metrics_path gets encoded

URL:localhost:15672/api/queues?columns=name,messages

结果:localhost:15672/api/queues%3Fcolumns=name,messages

普罗米修斯'?'被编码为“%3F”,因此请求失败

你能写出结果吗?

    static_configs:
  - targets: ['localhost:15672']
metrics_path: '/api/queues?columns=name,messages'

您必须使用 scrape configparams 配置。

# Optional HTTP URL parameters.
params:
  [ <string>: [<string>, ...] ]

你的情况:

static_configs:
- targets: ['localhost:15672']
  metrics_path: '/api/queues'
  params:
     columns:'name,messages'

这应该更适合你:

- job_name: samplejob
  metrics_path: /api/queues
  params:
    columns: [name,messages]
  static_configs:
    - targets:
      - localhost:15672

可在此处找到文档和示例:https://prometheus.io/docs/guides/multi-target-exporter/#querying-multi-target-exporters-with-prometheus