lapis 項目添加prometheus 監控集成grafana

操做很簡單,主要是進行界面的配置以及prometheus 服務的配置,
能夠和http://www.javashuo.com/article/p-kentdmps-bh.html &&
http://www.javashuo.com/article/p-ocrexwys-co.html 結合起來看html

環境準備

  • docker-compose
version: "3"
services:
  api:
   build: ./
   ports:
   - "8080:8080"
   volumes:
   - "./web:/web"
  g:
    image: grafana/grafana
    ports:
    - "3000:3000"
  p:
    image: prom/prometheus
    volumes:
    - "./prometheus.yml:/etc/prometheus/prometheus.yml"
    ports:
    - "9090:9090"
  • prometheus 配置
    prometheus.yml 文件
scrape_configs:
  - job_name: nginx
    metrics_path: /status/format/prometheus
    static_configs:
      - targets: ['api:8080']
  • dockerfile
    基本項目,使用數據卷掛載
FROM dalongrong/lapis-1.7.0:metrics
ENTRYPOINT [ "lapis","server" ]
  • 添加幾個測試路由
    web/app.lua 文件,很簡單都是get 方法
local lapis = require("lapis")
local app = lapis.Application()

app:get("/", function()
  return "Welcome to Lapis dalongrong " .. require("lapis.version")
end)

app:get("/users", function()
  return "users" .. require("lapis.version")
end)

app:get("/apps", function()
  return "apps" .. require("lapis.version")
end)


app:get("/mobiles", function()
  return "mobiles" .. require("lapis.version")
end)


app:get("/paas", function()
  return "paas " .. require("lapis.version")
end)
app:get("/saas", function()
  return "saas " .. require("lapis.version")
end)

return app

啓動&&測試

  • 啓動
docker-compose up -d
  • 效果




參考資料

http://www.javashuo.com/article/p-kentdmps-bh.html
http://www.javashuo.com/article/p-ocrexwys-co.html
https://github.com/rongfengliang/lapis-dockernginx

相關文章
相關標籤/搜索