因为prometheus支持restful API接口查询数据,所以核心思路是python使用request库,请求prometheus的API接口,得到响应对象后解析处理即可。 一、获取targets数据 1. prometheus查看targets数据