Prometheus API 返回 HTML 而不是 JSON

编程入门 行业动态 更新时间:2024-10-24 10:22:27
本文介绍了Prometheus API 返回 HTML 而不是 JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

使用 kubernates 配置 prometheus 并尝试使用 API 执行查询.按照文档配置和执行 APIhttps://github/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/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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-18 05:55:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/932775.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:而不是   API   Prometheus   JSON   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!