prometheus配置nginx监控

2021/9/29 promethenusnginx

由于没有能力自己写,去github (opens new window)找到两个方案

# nginx-module-vts方案

# 安装

编译nginxnginx-module-vts模块编译进去

./configure --add-module=nginx-module-vts && make && make install
1

# 配置

nginx.conf添加 vhost_traffic_status_zone 示例如下

http {
    vhost_traffic_status_zone;
    ...
    server {
        ...
        /metrics {
            vhost_traffic_status_display;
            vhost_traffic_status_display_format prometheus;
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11

更多使用方式, 请参考帮助文档 (opens new window)

访问 http://xxxxx:xxx/metrics 示例

prometheus-nginx

# nginx-lua-prometheus方案

由于使用的是 nginx-1.16 , lua-nginx-module (opens new window)没有明确支持 nginx-1.16 ,暂未使用

最后更新时间: 2025/2/27 19:03:05