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

问题描述

使用kubernates配置了prometheus,并尝试使用API​​执行查询.遵循文档来配置和执行API https://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 -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.

是否需要进行其他任何配置才能以json格式输出普罗米修斯?

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

推荐答案

当我在本地计算机上运行prometheus时,根据Prometheus README.md,它默认情况下在端口9090上运行:

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 00:27