kong的安装见
https://mp.youkuaiyun.com/mp_blog/creation/success/133136026
konga的安装见
https://mp.youkuaiyun.com/mp_blog/creation/success/133136539
启用prometheus插件
首先在Konga控制台启用prometheus插件,如下图所示,直接在全局范围启用该插件,关于prometheus插件更多配置详见官方文档。
konga->PLUGINS->Add Global Plugins ->Analytics & Monitoring->prometheus
启动好之后在服务器上测试
http://localhost:8001/metrics
如果见到类似以下数据说明启动成功
# HELP kong_bandwidth Total bandwidth in bytes consumed per service/route in Kong
# TYPE kong_bandwidth counter
kong_bandwidth{service="baidu",route="baidu",type="egress"} 92622
kong_bandwidth{service="baidu",route="baidu",type="ingress"} 9677
kong_bandwidth{service="google",route="google",type="egress"} 3565288
kong_bandwidth{service="google",route="google",type="ingress"} 1449
kong_bandwidth{service="alibaba",route="alibaba",type="egress"} 1983
kong_bandwidth{service="alibaba",route="alibaba",type="ingress"} 51364
安装prometheus
在服务器使用docker命令安装
首先配置prometheus.yml文件,配置信息如下
文档地址:/home/prometheus/prometheus.yml:
global:
scrape_interval: 15s
evaluation_interval: 60s
scrape_timeout: 10s
scrape_configs:
- job_name: prometheus
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
static_configs:
- targets: ['IP:8001']
labels:
instance: kong
上面的IP要使用实际kong的IP,且不能使用localhost代替
启动prometheus
docker run -p 9090:9090 --name prometheus -v /home/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml -d prom/prometheus
检查prometheus是否安装成功
http://IP:9090/graph
在搜索框内输入kong_bandwidth,看是否能查询出数据,能查询说明安装成功