-
大小: 1KB文件类型: .zip金币: 2下载: 1 次发布日期: 2021-05-11
- 语言: Python
- 标签: Prometheus api python
资源简介
使用python,通过Prometheus http api,导出Prometheus采集的各种机器指标的数据。

代码片段和文件信息
import requests
def get_metric_data(config metric_list start_time end_time):
“““Get metric data from Prometheus API“““
metric_datas = []
for m in metric_list:
try:
params = {
“query“: m
“start“: start_time
“end“: end_time
“step“: ‘60s‘
}
url = config[“PROMETHEUS_URL“] + “/api/v1/query_range“
response = requests.get(url params=params)
if response.status_code == 200:
res = response.json()
if res and res.get(‘status‘) == ‘success‘:
datas = res.get(‘data‘ {}).get(‘result‘ [])
metric_datas.extend(datas)
except Exception as e:
print e
return metric_datas
print get_metric_data({“PROMETHEUS_URL“: “http://localhost:32769/“}
[‘up‘ ‘go_gc_duration_seconds_sum‘]
1533538200
1533538260)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2033-12-20 19:44 prometheus_api\
文件 1008 2077-09-07 11:56 prometheus_api\run.py
文件 8 2046-09-12 19:06 prometheus_api\requirements.txt
文件 0 2094-05-27 12:40 prometheus_api\__init__.py
文件 165 2063-10-05 09:23 prometheus_api\README.md
相关资源
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
- 一个简单的python爬虫
- csv文件行列转换python实现代码
- Python操作Mysql教程手册
- Python Machine Learning Case Studies
- python获取硬件信息
- 量化交易(附python常见函数的使用方
- python 名字用字排行
评论
共有 条评论