I have some PromQL queries that I want to execute via HTTP request using the APIs given by Prometheus.
For example, having this query:
sum by (name) (container_memory_working_set_bytes{namespace="verification",pod=~".+",container!="POD",container=~".+"})
how can I put in the HTTP requests?
I tried writing like this:
curl -g 'http://localhost:9090/api/v1/query?sum by (name) (container_memory_working_set_bytes{namespace="verification",pod=~".+",container!="POD",container=~".+"})' | jq
but I received "curl: (56) Recv failure: Connection reset by peer"
Could enyone help me to understand how set te requests with the query (and if I'm wrong in writing the curl request)? Thank you all!
Try to URL-encode the query parameters, e.g.
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