I have a prometheus query like below. Screenshot
(100 * avg by (instance) (rate(node_cpu_seconds_total{mode!="idle"}[1m])))
It give a sumarized CPU usage of an instance via the GUI
You have access to a prometheus demo instance here
And I want to have the same result via the prometheus API
curl 'http://localhost:9090/api/v1/query?query=MYQUERY
I tried & searched...
curl -g 'http://localhost:9090/api/v1/query?query=node_cpu_seconds_total'
Give me the CPU usage for all CPU individually...
curl -g 'http://localhost:9090/api/v1/query?query=(100 * avg by (instance) (rate(node_cpu_seconds_total{mode!="idle"}[1m])))'
Give me 400 Bad Request
Can someone give me a clue or help me to transform my request?
Thanks in advance
CodePudding user response:
Use the following query:
curl -g 'http://localhost:9090/api/v1/query?query=(100*avg by (instance)(rate(node_cpu_seconds_total{mode!=\"idle\"}[1m])))'