目錄
1. 准備工作
3. 為kong添加 prometheus插件
curl -i -X POST --url http://localhost:8001/plugins --data "name=prometheus"
4. 打開kong的metrics支持
http://localhost:8001/metrics 端點上的Admin API提供了度量標准。需要配置權限使promtheus server能夠從這個api訪問並取數據
4. 配置prometheus.yml添加kong提供的數據信息
$PROMETHEUS_HOME/prometheus.yml
找到 - targets: ['localhost:9090']
這一行,添加 Kong 管理節點,添加后如下:
- targets: ['localhost:9090','localhost:8001']
重啟prometheus服務:
systemctl restart prometheus
驗證prometheus是否能正常獲取kong api數據, 訪問ip:9090,輸入kong關鍵字:
5. 在 Grafana 管理界面添加數據源
“Configuration” => “Add data source” => “Prometheus” => “select”
配置URL:http://localhost:9090
6. 添加官方 Dashboard
- 登錄 Grafana 后,點擊左邊的 “+” => “Create” => “Import”。
- 輸入 7424 ,7424 是 Kong 官方提供的與 Prometheus 插件配套的 Dashboard。
- 完成,調用 Kong 網關接口即可查看數據。
[sleepy↓]