简体   繁体   中英

Prometheus API returning HTML instead of JSON

Configured prometheus with kubernates and trying to execute queries using API's. Followed document to configure and execute the API https://github.com/prometheus/prometheus/blob/master/docs/querying/api.md

Executing below curl command for output:

curl -k -X GET "https://127.0.0.1/api/v1/query?query=kubelet_volume_stats_available_bytes"

But getting output in HTML instead of JSON.

Is any additional configuration needed to be done to get output in json format for prometheus?

Per the Prometheus documentation , Prometheus "[does] not provide any server-side authentication, authorisation or encryption".

It would seem that you're hitting some proxy, so you need to figure out how to get past that proxy and through to Prometheus. Once you do that, you'll get the response you expect.

When I run prometheus on my local machine, it runs on port 9090 by default based on the Prometheus README.md:

* Install docker
* change the prometheus.yml section called target
#static_configs: (example)
#      - targets: ['172.16.129.33:8080']
the target IP should be your localhost IP. Just providing localhost also would work.
* docker build -t prometheus_simple .
* docker run -p 9090:9090 prometheus_simple
* endpoint for prometheus is http://localhost:9090

So if I put the port in your curl call I have

curl -k -X GET "https://127.0.0.1:9090/api/v1/query?query=kubelet_volume_stats_available_bytes"

And I get:

 {"status":"success","data":{"resultType":"vector","result":[]}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM