fix: correct Grafana dashboard JSON format

- Remove dashboard wrapper from JSON files
- Dashboards now load successfully
- Update monitoring guide with correct instructions
This commit is contained in:
roma-dxunvrs
2026-10-03 22:59:11 +03:00
parent 96af109f6d
commit 91d54f4ef0
3 changed files with 474 additions and 376 deletions
+22 -5
View File
@@ -2,14 +2,31 @@
## Быстрый старт
1. **Доступ к сервисам:**
1. **Запуск:**
```bash
docker compose up -d
```
2. **Доступ к сервисам:**
- Приложение: http://localhost:8080
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000 (admin/admin)
- Grafana: http://localhost:3000 (логин: admin, пароль: admin)
2. **Дашборды автоматически загружены:**
- Spring Boot Application Metrics
- PostgreSQL & HikariCP Monitoring
3. **Дашборды:**
- Открой Grafana → Home → Dashboards
- Два дашборда загружены автоматически:
- **Spring Boot Application Metrics** — HTTP, JVM, CPU, GC
- **PostgreSQL & HikariCP Monitoring** — connection pool, база данных
4. **Создай нагрузку для проверки:**
```bash
# Создать задачу
curl -X POST http://localhost:8080/api/tasks \
-H "Content-Type: application/json" \
-d '{"title":"Test","description":"Load test","completed":false}'
# Посмотреть метрики появятся в Grafana через 5-15 секунд
```
## Основные метрики
+102 -67
View File
@@ -1,195 +1,230 @@
{
"dashboard": {
"title": "Spring Boot Application Metrics",
"tags": ["spring-boot", "todo-app"],
"timezone": "browser",
"schemaVersion": 16,
"version": 0,
"refresh": "5s",
"panels": [
{
"id": 1,
"title": "HTTP Request Rate",
"type": "graph",
"type": "timeseries",
"gridPos": {"x": 0, "y": 0, "w": 12, "h": 8},
"targets": [
{
"expr": "rate(http_server_requests_seconds_count{application=\"todo\"}[1m])",
"legendFormat": "{{method}} {{uri}} - {{status}}"
"legendFormat": "{{method}} {{uri}} - {{status}}",
"refId": "A"
}
],
"yaxes": [
{"format": "reqps", "label": "Requests/sec"},
{"format": "short"}
]
"fieldConfig": {
"defaults": {
"unit": "reqps",
"custom": {}
}
}
},
{
"id": 2,
"title": "HTTP Request Duration (p95, p99)",
"type": "graph",
"type": "timeseries",
"gridPos": {"x": 12, "y": 0, "w": 12, "h": 8},
"targets": [
{
"expr": "histogram_quantile(0.95, sum(rate(http_server_requests_seconds_bucket{application=\"todo\"}[5m])) by (le, uri))",
"legendFormat": "p95 - {{uri}}"
"legendFormat": "p95 - {{uri}}",
"refId": "A"
},
{
"expr": "histogram_quantile(0.99, sum(rate(http_server_requests_seconds_bucket{application=\"todo\"}[5m])) by (le, uri))",
"legendFormat": "p99 - {{uri}}"
"legendFormat": "p99 - {{uri}}",
"refId": "B"
}
],
"yaxes": [
{"format": "s", "label": "Duration"},
{"format": "short"}
]
"fieldConfig": {
"defaults": {
"unit": "s",
"custom": {}
}
}
},
{
"id": 3,
"title": "HTTP Status Codes",
"type": "graph",
"type": "timeseries",
"gridPos": {"x": 0, "y": 8, "w": 12, "h": 8},
"targets": [
{
"expr": "sum(rate(http_server_requests_seconds_count{application=\"todo\"}[1m])) by (status)",
"legendFormat": "{{status}}"
"legendFormat": "{{status}}",
"refId": "A"
}
],
"yaxes": [
{"format": "reqps"},
{"format": "short"}
]
"fieldConfig": {
"defaults": {
"unit": "reqps",
"custom": {}
}
}
},
{
"id": 4,
"title": "JVM Memory Used",
"type": "graph",
"type": "timeseries",
"gridPos": {"x": 12, "y": 8, "w": 12, "h": 8},
"targets": [
{
"expr": "jvm_memory_used_bytes{application=\"todo\", area=\"heap\"}",
"legendFormat": "Heap"
"legendFormat": "Heap",
"refId": "A"
},
{
"expr": "jvm_memory_used_bytes{application=\"todo\", area=\"nonheap\"}",
"legendFormat": "Non-Heap"
"legendFormat": "Non-Heap",
"refId": "B"
},
{
"expr": "jvm_memory_max_bytes{application=\"todo\", area=\"heap\"}",
"legendFormat": "Heap Max"
"legendFormat": "Heap Max",
"refId": "C"
}
],
"yaxes": [
{"format": "bytes"},
{"format": "short"}
]
"fieldConfig": {
"defaults": {
"unit": "bytes",
"custom": {}
}
}
},
{
"id": 5,
"title": "Database Connection Pool",
"type": "graph",
"type": "timeseries",
"gridPos": {"x": 0, "y": 16, "w": 12, "h": 8},
"targets": [
{
"expr": "hikaricp_connections_active{application=\"todo\"}",
"legendFormat": "Active"
"legendFormat": "Active",
"refId": "A"
},
{
"expr": "hikaricp_connections_idle{application=\"todo\"}",
"legendFormat": "Idle"
"legendFormat": "Idle",
"refId": "B"
},
{
"expr": "hikaricp_connections{application=\"todo\"}",
"legendFormat": "Total"
"legendFormat": "Total",
"refId": "C"
},
{
"expr": "hikaricp_connections_max{application=\"todo\"}",
"legendFormat": "Max"
"legendFormat": "Max",
"refId": "D"
}
],
"yaxes": [
{"format": "short", "label": "Connections"},
{"format": "short"}
]
"fieldConfig": {
"defaults": {
"unit": "short",
"custom": {}
}
}
},
{
"id": 6,
"title": "Database Connection Acquire Time",
"type": "graph",
"type": "timeseries",
"gridPos": {"x": 12, "y": 16, "w": 12, "h": 8},
"targets": [
{
"expr": "rate(hikaricp_connections_acquire_seconds_sum{application=\"todo\"}[1m]) / rate(hikaricp_connections_acquire_seconds_count{application=\"todo\"}[1m])",
"legendFormat": "Avg Acquire Time"
"legendFormat": "Avg Acquire Time",
"refId": "A"
}
],
"yaxes": [
{"format": "s"},
{"format": "short"}
]
"fieldConfig": {
"defaults": {
"unit": "s",
"custom": {}
}
}
},
{
"id": 7,
"title": "JVM Threads",
"type": "graph",
"type": "timeseries",
"gridPos": {"x": 0, "y": 24, "w": 8, "h": 8},
"targets": [
{
"expr": "jvm_threads_live_threads{application=\"todo\"}",
"legendFormat": "Live"
"legendFormat": "Live",
"refId": "A"
},
{
"expr": "jvm_threads_daemon_threads{application=\"todo\"}",
"legendFormat": "Daemon"
"legendFormat": "Daemon",
"refId": "B"
},
{
"expr": "jvm_threads_peak_threads{application=\"todo\"}",
"legendFormat": "Peak"
"legendFormat": "Peak",
"refId": "C"
}
],
"yaxes": [
{"format": "short", "label": "Threads"},
{"format": "short"}
]
"fieldConfig": {
"defaults": {
"unit": "short",
"custom": {}
}
}
},
{
"id": 8,
"title": "GC Pause Time",
"type": "graph",
"type": "timeseries",
"gridPos": {"x": 8, "y": 24, "w": 8, "h": 8},
"targets": [
{
"expr": "rate(jvm_gc_pause_seconds_sum{application=\"todo\"}[1m])",
"legendFormat": "{{action}} - {{cause}}"
"legendFormat": "{{action}} - {{cause}}",
"refId": "A"
}
],
"yaxes": [
{"format": "s", "label": "GC Time"},
{"format": "short"}
]
"fieldConfig": {
"defaults": {
"unit": "s",
"custom": {}
}
}
},
{
"id": 9,
"title": "System CPU Usage",
"type": "graph",
"type": "timeseries",
"gridPos": {"x": 16, "y": 24, "w": 8, "h": 8},
"targets": [
{
"expr": "system_cpu_usage{application=\"todo\"}",
"legendFormat": "System"
"legendFormat": "System",
"refId": "A"
},
{
"expr": "process_cpu_usage{application=\"todo\"}",
"legendFormat": "Process"
"legendFormat": "Process",
"refId": "B"
}
],
"yaxes": [
{"format": "percentunit", "label": "CPU"},
{"format": "short"}
]
"fieldConfig": {
"defaults": {
"unit": "percentunit",
"custom": {}
}
}
}
],
"refresh": "5s",
"time": {
"from": "now-15m",
"to": "now"
}
},
"overwrite": true
}
+96 -50
View File
@@ -1,23 +1,31 @@
{
"dashboard": {
"title": "PostgreSQL & HikariCP Monitoring",
"tags": ["database", "postgres", "hikaricp"],
"timezone": "browser",
"schemaVersion": 16,
"version": 0,
"refresh": "5s",
"panels": [
{
"id": 1,
"title": "Connection Pool Status",
"title": "Connection Pool Status - Active",
"type": "stat",
"gridPos": {"x": 0, "y": 0, "w": 6, "h": 4},
"targets": [
{
"expr": "hikaricp_connections_active{application=\"todo\"}",
"legendFormat": "Active"
"legendFormat": "Active",
"refId": "A"
}
],
"options": {
"colorMode": "value",
"graphMode": "area"
},
"fieldConfig": {
"defaults": {
"unit": "short"
}
}
},
{
@@ -28,12 +36,18 @@
"targets": [
{
"expr": "hikaricp_connections_idle{application=\"todo\"}",
"legendFormat": "Idle"
"legendFormat": "Idle",
"refId": "A"
}
],
"options": {
"colorMode": "value",
"graphMode": "area"
},
"fieldConfig": {
"defaults": {
"unit": "short"
}
}
},
{
@@ -44,12 +58,18 @@
"targets": [
{
"expr": "hikaricp_connections{application=\"todo\"}",
"legendFormat": "Total"
"legendFormat": "Total",
"refId": "A"
}
],
"options": {
"colorMode": "value",
"graphMode": "area"
},
"fieldConfig": {
"defaults": {
"unit": "short"
}
}
},
{
@@ -60,128 +80,154 @@
"targets": [
{
"expr": "hikaricp_connections_pending{application=\"todo\"}",
"legendFormat": "Pending"
"legendFormat": "Pending",
"refId": "A"
}
],
"options": {
"colorMode": "value",
"graphMode": "area"
},
"fieldConfig": {
"defaults": {
"unit": "short"
}
}
},
{
"id": 5,
"title": "Connection Pool Utilization (%)",
"type": "graph",
"type": "timeseries",
"gridPos": {"x": 0, "y": 4, "w": 12, "h": 8},
"targets": [
{
"expr": "(hikaricp_connections_active{application=\"todo\"} / hikaricp_connections_max{application=\"todo\"}) * 100",
"legendFormat": "Active %"
"legendFormat": "Active %",
"refId": "A"
},
{
"expr": "(hikaricp_connections{application=\"todo\"} / hikaricp_connections_max{application=\"todo\"}) * 100",
"legendFormat": "Total %"
"legendFormat": "Total %",
"refId": "B"
}
],
"yaxes": [
{"format": "percent", "label": "Utilization", "min": 0, "max": 100},
{"format": "short"}
]
"fieldConfig": {
"defaults": {
"unit": "percent",
"min": 0,
"max": 100,
"custom": {}
}
}
},
{
"id": 6,
"title": "Connection Acquire Time",
"type": "graph",
"type": "timeseries",
"gridPos": {"x": 12, "y": 4, "w": 12, "h": 8},
"targets": [
{
"expr": "histogram_quantile(0.5, rate(hikaricp_connections_acquire_seconds_bucket{application=\"todo\"}[1m]))",
"legendFormat": "p50"
"legendFormat": "p50",
"refId": "A"
},
{
"expr": "histogram_quantile(0.95, rate(hikaricp_connections_acquire_seconds_bucket{application=\"todo\"}[1m]))",
"legendFormat": "p95"
"legendFormat": "p95",
"refId": "B"
},
{
"expr": "histogram_quantile(0.99, rate(hikaricp_connections_acquire_seconds_bucket{application=\"todo\"}[1m]))",
"legendFormat": "p99"
"legendFormat": "p99",
"refId": "C"
}
],
"yaxes": [
{"format": "s", "label": "Time"},
{"format": "short"}
]
"fieldConfig": {
"defaults": {
"unit": "s",
"custom": {}
}
}
},
{
"id": 7,
"title": "Connection Timeout Count",
"type": "graph",
"type": "timeseries",
"gridPos": {"x": 0, "y": 12, "w": 12, "h": 8},
"targets": [
{
"expr": "rate(hikaricp_connections_timeout_total{application=\"todo\"}[1m])",
"legendFormat": "Timeouts/sec"
"legendFormat": "Timeouts/sec",
"refId": "A"
}
],
"yaxes": [
{"format": "short"},
{"format": "short"}
]
"fieldConfig": {
"defaults": {
"unit": "short",
"custom": {}
}
}
},
{
"id": 8,
"title": "Connection Creation Time",
"type": "graph",
"type": "timeseries",
"gridPos": {"x": 12, "y": 12, "w": 12, "h": 8},
"targets": [
{
"expr": "rate(hikaricp_connections_creation_seconds_sum{application=\"todo\"}[1m]) / rate(hikaricp_connections_creation_seconds_count{application=\"todo\"}[1m])",
"legendFormat": "Avg Creation Time"
"legendFormat": "Avg Creation Time",
"refId": "A"
}
],
"yaxes": [
{"format": "s"},
{"format": "short"}
]
"fieldConfig": {
"defaults": {
"unit": "s",
"custom": {}
}
}
},
{
"id": 9,
"title": "Connection Usage Time",
"type": "graph",
"type": "timeseries",
"gridPos": {"x": 0, "y": 20, "w": 12, "h": 8},
"targets": [
{
"expr": "rate(hikaricp_connections_usage_seconds_sum{application=\"todo\"}[1m]) / rate(hikaricp_connections_usage_seconds_count{application=\"todo\"}[1m])",
"legendFormat": "Avg Usage Time"
"legendFormat": "Avg Usage Time",
"refId": "A"
}
],
"yaxes": [
{"format": "s"},
{"format": "short"}
]
"fieldConfig": {
"defaults": {
"unit": "s",
"custom": {}
}
}
},
{
"id": 10,
"title": "JDBC Queries Rate",
"type": "graph",
"title": "Active Connections Timeline",
"type": "timeseries",
"gridPos": {"x": 12, "y": 20, "w": 12, "h": 8},
"targets": [
{
"expr": "rate(jdbc_connections_active{application=\"todo\"}[1m])",
"legendFormat": "Active JDBC Connections"
"expr": "hikaricp_connections_active{application=\"todo\"}",
"legendFormat": "Active Connections",
"refId": "A"
}
],
"yaxes": [
{"format": "short"},
{"format": "short"}
]
"fieldConfig": {
"defaults": {
"unit": "short",
"custom": {}
}
}
}
],
"refresh": "5s",
"time": {
"from": "now-15m",
"to": "now"
}
},
"overwrite": true
}