Skip to content

openresty监控

基于prometheus监控

nginx-lua-prometheus

nginx-lua-prometheus对应的grafana dashboards

示例的详细配置请参考 链接

使用开源的项目nginx-lua-prometheus监控openresty状态

配置prometheus监控openresty步骤如下:

  1. 编译openresty,注意:编译openresty需要添加参数--with-http_stub_status_module,否则nginx-lua-prometheus插件无法读取ngx.var.connections_reading变量导致不能正常运行。

  2. 配置openresty metrics端点,用于给prometheus收集监控信息

    • 参考 nginx-lua-prometheus README.md说明文档配置openresty
    • 配置成功后访问http://localhost:9145/metrics查看openresty metrics端点prometheus数据
  3. 配置prometheus收集openresty metrics数据prometheus.yml配置如下:

    yaml
    scrape_configs:
      - job_name: "prometheus"
        static_configs:
          - targets: ["prometheus:9090"]
      # openresty metrics端点配置
      - job_name: 'openresty'
        static_configs:
          - targets: ['openresty:9145']
  4. 启动prometheus,登录grafana http://localhost:3000,手动导入模板ID 10223

  5. 使用jmeter运行 jmeter.jmx 创建测试数据