Prometheus API 返回 HTML 而不是 JSON [英] Prometheus API returning HTML instead of JSON

查看:44
本文介绍了Prometheus API 返回 HTML 而不是 JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 kubernates 配置 prometheus 并尝试使用 API 执行查询.按照文档配置和执行 APIhttps://github.com/prometheus/prometheus/blob/master/docs/querying/api.md

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

执行以下 curl 命令进行输出:

Executing below curl command for output:

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

但是以 HTML 而不是 JSON 格式获取输出.

But getting output in HTML instead of JSON.

为了得到 prometheus 的 json 格式的输出,是否需要做任何额外的配置?

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

推荐答案

当我在本地机器上运行 prometheus 时,它默认运行在端口 9090 上,基于 Prometheus README.md:

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

所以如果我把端口放在你的 curl 调用中,我有

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"

我得到:

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

这篇关于Prometheus API 返回 HTML 而不是 JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆