1

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?

va1bhav
  • 365
  • 1
  • 5
  • 21
  • What is the output you are getting? – brian-brazil Oct 26 '18 at 10:01
  • Its returning login page in HTML – va1bhav Oct 26 '18 at 10:30
  • 1
    If you're getting a login page, I'm guessing that your Prometheus has some sort of auth set up in front of it? If so, you'll probably need to provide some sort of auth token (e.g. an oauth2 bearer token) for your request to send in its request headers in order to get past the login page. – wbh1 Oct 26 '18 at 13:01
  • already tried with command - curl --user test:aaa -k -X GET "https://127.0.0.1/api/v1/query?query=kubelet_volume_stats_available_bytes". But getting same error – va1bhav Oct 29 '18 at 06:35

2 Answers2

0

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.

Alin Sînpălean
  • 8,774
  • 1
  • 25
  • 29
0

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":[]}}
Joseph Ishak
  • 1,194
  • 1
  • 9
  • 18