把原先散落在 D:\fruitshorts\monitoring 的手工栈收编进仓库:prometheus 增加 cAdvisor 与 blackbox 抓取、15 天保留期;grafana 改为 provisioning 自动加载数据源与看板;新增 blackbox/cadvisor 服务;Grafana 管理员密码改走环境变量(必填),不再硬编码 admin/admin。
94 lines
3.8 KiB
JSON
94 lines
3.8 KiB
JSON
{
|
||
"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}}" }
|
||
]
|
||
}
|
||
]
|
||
}
|