feat(monitoring): 监控编排统一到 FruitServer compose
把原先散落在 D:\fruitshorts\monitoring 的手工栈收编进仓库:prometheus 增加 cAdvisor 与 blackbox 抓取、15 天保留期;grafana 改为 provisioning 自动加载数据源与看板;新增 blackbox/cadvisor 服务;Grafana 管理员密码改走环境变量(必填),不再硬编码 admin/admin。
This commit is contained in:
1 parent
b391ad31af
commit
530da2b1b4
7 files changed
+210
-3
No files matched your search
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"uid": "fruitshorts-backend",
|
||||
"title": "FruitShorts 后端监控",
|
||||
"tags": ["fruitshorts", "backend"],
|
||||
"timezone": "browser",
|
||||
"editable": true,
|
||||
"schemaVersion": 39,
|
||||
"version": 1,
|
||||
"refresh": "30s",
|
||||
"time": { "from": "now-6h", "to": "now" },
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"type": "stat",
|
||||
"title": "服务探活(1=正常 0=异常)",
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"gridPos": { "x": 0, "y": 0, "w": 8, "h": 6 },
|
||||
"options": {
|
||||
"colorMode": "background",
|
||||
"graphMode": "none",
|
||||
"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"mappings": [
|
||||
{ "type": "value", "options": { "0": { "text": "异常", "color": "red", "index": 0 } } },
|
||||
{ "type": "value", "options": { "1": { "text": "正常", "color": "green", "index": 1 } } }
|
||||
],
|
||||
"thresholds": { "mode": "absolute", "steps": [{ "color": "red", "value": null }, { "color": "green", "value": 1 }] }
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"targets": [
|
||||
{ "refId": "A", "expr": "probe_success{job=\"blackbox\"}", "legendFormat": "{{instance}}" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"type": "timeseries",
|
||||
"title": "接口探测耗时(秒)",
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"gridPos": { "x": 8, "y": 0, "w": 16, "h": 6 },
|
||||
"fieldConfig": { "defaults": { "unit": "s", "custom": { "lineWidth": 2, "fillOpacity": 10 } }, "overrides": [] },
|
||||
"targets": [
|
||||
{ "refId": "A", "expr": "probe_duration_seconds{job=\"blackbox\"}", "legendFormat": "{{instance}}" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"type": "timeseries",
|
||||
"title": "容器 CPU 使用(核)",
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"gridPos": { "x": 0, "y": 6, "w": 12, "h": 8 },
|
||||
"fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 2, "fillOpacity": 10 } }, "overrides": [] },
|
||||
"targets": [
|
||||
{ "refId": "A", "expr": "sum(rate(container_cpu_usage_seconds_total{name=~\"fruitshorts-(app-api|admin-api|db|redis|transcode-worker)\"}[1m])) by (name)", "legendFormat": "{{name}}" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"type": "timeseries",
|
||||
"title": "容器内存(GiB)",
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"gridPos": { "x": 12, "y": 6, "w": 12, "h": 8 },
|
||||
"fieldConfig": { "defaults": { "unit": "bytes", "custom": { "lineWidth": 2, "fillOpacity": 10 } }, "overrides": [] },
|
||||
"targets": [
|
||||
{ "refId": "A", "expr": "sum(container_memory_working_set_bytes{name=~\"fruitshorts-(app-api|admin-api|db|redis|transcode-worker)\"}) by (name)", "legendFormat": "{{name}}" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"type": "timeseries",
|
||||
"title": "容器网络接收(B/s)",
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"gridPos": { "x": 0, "y": 14, "w": 12, "h": 8 },
|
||||
"fieldConfig": { "defaults": { "unit": "Bps", "custom": { "lineWidth": 2, "fillOpacity": 10 } }, "overrides": [] },
|
||||
"targets": [
|
||||
{ "refId": "A", "expr": "sum(rate(container_network_receive_bytes_total{name=~\"fruitshorts-(app-api|admin-api|db|redis|transcode-worker)\"}[1m])) by (name)", "legendFormat": "{{name}}" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"type": "timeseries",
|
||||
"title": "Prometheus 抓取目标状态(1=UP)",
|
||||
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||
"gridPos": { "x": 12, "y": 14, "w": 12, "h": 8 },
|
||||
"fieldConfig": { "defaults": { "unit": "short", "min": 0, "max": 1, "custom": { "lineWidth": 2, "fillOpacity": 10 } }, "overrides": [] },
|
||||
"targets": [
|
||||
{ "refId": "A", "expr": "up", "legendFormat": "{{job}} {{instance}}" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
# Author: fruit.com.cn
|
||||
# 看板自动加载:容器内 /var/lib/grafana/dashboards 挂载的是仓库里的 grafana/dashboards
|
||||
apiVersion: 1
|
||||
|
||||
providers:
|
||||
- name: 'FruitShorts'
|
||||
orgId: 1
|
||||
folder: 'FruitShorts'
|
||||
type: file
|
||||
disableDeletion: false
|
||||
updateIntervalSeconds: 30
|
||||
allowUiUpdates: true
|
||||
options:
|
||||
path: /var/lib/grafana/dashboards
|
||||
@@ -0,0 +1,14 @@
|
||||
# Author: fruit.com.cn
|
||||
# Grafana 数据源:compose 内网直连 prometheus 服务
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
uid: prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
url: http://prometheus:9090
|
||||
isDefault: true
|
||||
editable: false
|
||||
jsonData:
|
||||
timeInterval: 15s
|
||||
Reference in new issue
Block a user