Skip to main content

为 NoneBot 和其他插件提供 Prometheus 监控支持

Project description

nonebot

Nonebot Plugin Prometheus

✨ NoneBot Prometheus 监控插件 ✨

license pypi

✨功能

  • 自动挂载 /metrics 路径,提供 Prometheus 监控数据
  • 为其他插件提供统一的数据上报接口

📊支持统计的指标

  • Bot 在线状态
  • Bot 掉线次数
  • Bot 发送和接受消息次数
  • Matcher 执行次数

♿官方提供 Grafana 面板

23060

图片

📦 安装

  • 使用 nb-cli
nb plugin install nonebot-plugin-prometheus
  • 使用 uv
uv add nonebot-plugin-prometheus
  • 使用 poetry
poetry add nonebot-plugin-prometheus
  • 使用 pip
pip install nonebot-plugin-prometheus

🔌接入方式

先在插件代码最前面声明依赖

from nonebot import require

require("nonebot_plugin_prometheus")

然后可以从插件导入相关指标对象使用,详情请参考 Prometheus Python Client 官方文档

from nonebot_plugin_prometheus import Gauge, Counter, Histogram, Summary

# Request counter
request_counter = Counter(
    "request_counter", "The number of requests"
)
request_counter.inc()

Tips

为了统计 matcher 运行时间,本插件会自动在 Matcher.state 中插入 _prometheus_start_time 字段。

🔧配置

# 是否开启 Prometheus 插件
prometheus_enable = True
# Prometheus 挂载地址
prometheus_metrics_path = "/metrics"

Note

使用插件需要支持 ASGI 的驱动器,例如 fastapi

📝TODO

  • 提供快速上手 docker compose 文件
  • 支持通过对话查询指标数据

相关仓库

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_plugin_prometheus-0.3.14.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_prometheus-0.3.14-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_prometheus-0.3.14.tar.gz.

File metadata

File hashes

Hashes for nonebot_plugin_prometheus-0.3.14.tar.gz
Algorithm Hash digest
SHA256 b66e8a186da02b6672cf7e891c5fbf57cbb6fd2aab9a019b30c107dd1caa820c
MD5 3514a55f9166b8822632e7d12534b225
BLAKE2b-256 95ee77a5a3375ab2fdbb65f26931b6181f6140e312c1a8493548034ec26cdb06

See more details on using hashes here.

Provenance

The following attestation bundles were made for nonebot_plugin_prometheus-0.3.14.tar.gz:

Publisher: release.yml on suyiiyii/nonebot-plugin-prometheus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nonebot_plugin_prometheus-0.3.14-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_prometheus-0.3.14-py3-none-any.whl
Algorithm Hash digest
SHA256 7898a818790289fa6305ee6b68589a476b5dbffe2b17a509e61c2d69a868293d
MD5 70e651432ea5c5bfb50f77f35dbd3a76
BLAKE2b-256 cf930fa6d6df19ab173377503c26f680fae5fe7823920ef494654f2e7beca8bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for nonebot_plugin_prometheus-0.3.14-py3-none-any.whl:

Publisher: release.yml on suyiiyii/nonebot-plugin-prometheus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page