Python3专用的pushgateway客户端,可以向Pushgateway中推送指标数据,支持多标签设定
Project description
安装模块
pip install pushgateway-client
如果国内下载较慢可以临时加速一下
# pypi官网(原版拉取)
pip install pushgateway-client --upgrade -i https://pypi.org/project
# 阿里云源(加速拉取)
pip install pushgateway-client --upgrade -i http://mirrors.aliyun.com/pypi/simple
# 清华大学源(加速拉取)
pip install pushgateway-client --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple
使用说明
from pushgateway_client import client # 导入该模块
result = client.push_data(
url="127.0.0.1:9091", # 连接地址:此处只需要填写Pushgateway的IP地址+端口就行了,不用写http协议头,暂时只支持http连接
metric_name="my_metric_name", # 指标名称:此处指的就是Prometheus中的指标名(至于如何让Pushgateway中的指标投送到Prometheus中,请参阅官方文档)
metric_value="123", # 指标的值:受官网当前版本的限制,目前只支持数字做为值
job_name="demo", # Job名字:Prometheus会为所有的指标都追加一个job标签,在Prometheus这个job只是一个标签,但是在Pushgateway中这个job就是一个唯一标识符
labels={ # 标签可以自己随意设定,支持多标签;需要注意的是:<instance>标签如果不明确的指定的话,本模块会自动获取<您的主机名>来成为<instance>标签的值
"aaa": "111",
"bbb": "222",
"ccc": "333",
},
timeout=5, # 设定推送数据时的超时时间,默认值为5秒
)
print(result) # 返回值是一个布尔类型,便于您进行后续的集成开发
print(type(result))
查看效果
This is a simple example package.You can check out the details at blog.taycc.com https://blog.taycc.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pushgateway_client-0.0.12.tar.gz.
File metadata
- Download URL: pushgateway_client-0.0.12.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5505f8336407be447d2bb10ad706e905685ce9ff6866dc1b19053e09915cda21
|
|
| MD5 |
35737b034e067b7c949417f1d06d9774
|
|
| BLAKE2b-256 |
216f83beb1e0a1407991f47864b8f3b60540173f7376e08086ce68973cf8a7b0
|
File details
Details for the file pushgateway_client-0.0.12-py3-none-any.whl.
File metadata
- Download URL: pushgateway_client-0.0.12-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b137de01aff206ee227462cc37b7e780db6f03962ea990cf5cd0224e83890f8b
|
|
| MD5 |
cf0c36e474d42c44a71c908f3f9d2149
|
|
| BLAKE2b-256 |
48967743800cb19b3c19bc3a335e42169c36c01cda25bc0c5ef4b3c4a69acdd4
|