普罗米修斯&PromQL/ HTTP API

Prometheus&PromQL/ HTTP API

我想使用 Prometheus 提供的 API 通过 HTTP 请求执行一些 PromQL 查询。

例如,有这个查询:

sum by (name) (container_memory_working_set_bytes{namespace="verification",pod=~".+",container!="POD",container=~".+"})

如何放入 HTTP 请求?

我试过这样写:

curl -g 'http://localhost:9090/api/v1/query?sum by (name) (container_memory_working_set_bytes{namespace="verification",pod=~".+",container!="POD",container=~".+"})' | jq

但我收到“curl: (56) Recv failure: Connection reset by peer”

任何人都可以帮助我了解如何使用查询设置请求(以及我是否写错了 curl 请求)? 谢谢大家!

尝试URL-encode查询参数,例如

curl 'http://localhost:9090/api/v1/query?query=sum%20by%20%28name%29%20%28container_memory_working_set_bytes%7Bnamespace%3D%22verification%22%2Cpod%3D~%22.%2B%22%2Ccontainer%21%3D%22POD%22%2Ccontainer%3D~%22.%2B%22%7D%29' | jq