Prometheus 教程

Prometheus 管理 API

Prometheus 提供一套管理 API,以促进自动化和集成。

健康检查

GET /-/healthy
HEAD /-/healthy

该端点总是返回 200,应用于检查 Prometheus 的健康状况。如下图:

Prometheus 管理 API

就绪检查

GET /-/ready
HEAD /-/ready

当 Prometheus 准备好提供流量服务(即响应查询)时,该端点会返回 200。如下图:

Prometheus 管理 API

重新加载

PUT  /-/reload
POST /-/reload

该端点会触发 Prometheus 配置和规则文件的重新加载。默认情况下已禁用,可通过 --web.enable-lifecycle 标志启用。

另外,也可以通过向 Prometheus 进程发送 SIGHUP 来触发配置重载。

示例:

(1)使用 --web.enable-lifecycle 选项启动 Prometheus,如下:

D:\prometheus-2.45.4.windows-amd64> prometheus.exe --web.enable-lifecycle

(2)访问接口,如下图:

a、没有使用 --web.enable-lifecycle 选项开启功能,调用如下图:

Prometheus 管理 API

b、使用了 --web.enable-lifecycle 选项,调用如下图:

Prometheus 管理 API


退出

PUT  /-/quit
POST /-/quit

该端点会触发 Prometheus 的优雅关机。默认情况下已禁用,可通过 --web.enable-lifecycle 标志启用。

另外,也可以通过向 Prometheus 进程发送 SIGTERM 来触发优雅关机。

示例:

(1)使用 --web.enable-lifecycle 选项启动 Prometheus,如下:

D:\prometheus-2.45.4.windows-amd64> prometheus.exe --web.enable-lifecycle

(2)访问接口,发送关闭 Prometheus 服务的命令,如下图:

Prometheus 管理 API

说说我的看法
全部评论(
没有评论
关于
本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明,如果原文没有版权声明,请来信告知:hxstrive@outlook.com
公众号