lapis 项目添加prometheus 监控

Posted rongfengliang-荣锋亮

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了lapis 项目添加prometheus 监控相关的知识,希望对你有一定的参考价值。

lapis 是基于openresty 扩展的,所以直接将支持prometheus的模块构建进openresty 就可以了
我使用的是nginx-module-vts 模块

环境准备

我已经构建好了支持的基础镜像,可以直接配置即可,具体的可以看下面的参考资料

  • docker-compose 文件
version: "3"
services:
 api:
   build: ./
   ports:
   - "8080:8080"
   volumes:
   - "./web:/web"
  • dockerfile
FROM dalongrong/lapis-1.7.0:metrics
ENTRYPOINT [ "lapis","server" ]
  • dalongrong/lapis-1.7.0:metrics 镜像
FROM dalongrong/openresty-nginx-module-vts:fat
RUN apk add openssl-dev
WORKDIR /web
RUN /usr/local/openresty/luajit/bin/luarocks install lapis
worker_processes ${{NUM_WORKERS}};
error_log stderr notice;
daemon off;
pid logs/nginx.pid;

events {
  worker_connections 1024;
}

http {
  include mime.types;
  vhost_traffic_status_zone;
  server {
    listen ${{PORT}};
    lua_code_cache ${{CODE_CACHE}};
    vhost_traffic_status_filter_by_set_key $uri uris::$server_name;
    vhost_traffic_status_filter_by_host on;
    location / {
      vhost_traffic_status_bypass_limit on;
      default_type text/html;
      content_by_lua \'
        require("lapis").serve("app")
      \';
    }
    location /status {
        vhost_traffic_status_display;
        vhost_traffic_status_display_format html;
    }
    location /static/ {
      alias static/;
    }

    location /favicon.ico {
      alias static/favicon.ico;
    }
  }
}

启动&&测试

  • 启动
docker-compose up -d
  • 效果

    prometheus metrics

参考资料

https://github.com/rongfengliang/openresty-nginx-module-vts
https://github.com/rongfengliang/openresty_nginx-module-vts_prometheus_grafana
https://github.com/rongfengliang/lapis-docker

以上是关于lapis 项目添加prometheus 监控的主要内容,如果未能解决你的问题,请参考以下文章

监控利器Prometheus——Prometheus+Grafana监控SpringBoot项目业务指标监控

监控利器Prometheus——Prometheus+Grafana监控SpringBoot项目业务指标监控

监控利器Prometheus——Prometheus+Grafana监控SpringBoot项目业务指标监控

监控利器Prometheus——Prometheus+Grafana监控SpringBoot项目JVM信息

监控利器Prometheus——Prometheus+Grafana监控SpringBoot项目JVM信息

监控利器Prometheus——Prometheus+Grafana监控SpringBoot项目JVM信息