Add NATS exporter to Docker Compose for enhanced observability, update Prometheus and Grafana configurations to integrate new metrics, and enhance documentation to reflect changes in the development stack.

This commit is contained in:
windyboy
2025-11-15 15:27:53 +08:00
parent 629c1e9138
commit c3f98e9c7c
8 changed files with 686 additions and 16 deletions
@@ -82,7 +82,7 @@
"targets": [
{
"refId": "A",
"expr": "sum(nats_varz_total_connections)"
"expr": "sum(gnatsd_varz_connections{job=\"nats-exporter\"})"
}
]
},
@@ -136,7 +136,7 @@
"targets": [
{
"refId": "A",
"expr": "sum(nats_varz_slow_consumers)"
"expr": "sum(gnatsd_varz_slow_consumers{job=\"nats-exporter\"})"
}
]
},
@@ -202,7 +202,7 @@
"targets": [
{
"refId": "A",
"expr": "max(nats_varz_jetstream)"
"expr": "max(gnatsd_varz_jetstream_stats_accounts{job=\"nats-exporter\"})"
}
]
},
@@ -255,12 +255,12 @@
"targets": [
{
"refId": "A",
"expr": "sum(rate(nats_varz_in_msgs[1m]))",
"expr": "sum(rate(gnatsd_varz_in_msgs{job=\"nats-exporter\"}[1m]))",
"legendFormat": "in"
},
{
"refId": "B",
"expr": "sum(rate(nats_varz_out_msgs[1m]))",
"expr": "sum(rate(gnatsd_varz_out_msgs{job=\"nats-exporter\"}[1m]))",
"legendFormat": "out"
}
]
@@ -315,12 +315,12 @@
"targets": [
{
"refId": "A",
"expr": "sum(rate(nats_varz_in_bytes[1m]))",
"expr": "sum(rate(gnatsd_varz_in_bytes{job=\"nats-exporter\"}[1m]))",
"legendFormat": "in"
},
{
"refId": "B",
"expr": "sum(rate(nats_varz_out_bytes[1m]))",
"expr": "sum(rate(gnatsd_varz_out_bytes{job=\"nats-exporter\"}[1m]))",
"legendFormat": "out"
}
]
@@ -379,7 +379,193 @@
"targets": [
{
"refId": "A",
"expr": "sum(nats_varz_jetstream_bytes)"
"expr": "sum(gnatsd_varz_jetstream_stats_storage{job=\"nats-exporter\"})"
}
]
},
{
"id": 7,
"type": "stat",
"title": "Total Subscriptions",
"datasource": {
"type": "prometheus",
"uid": "prometheus-dev"
},
"fieldConfig": {
"defaults": {
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 1000
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 6,
"x": 0,
"y": 20
},
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"targets": [
{
"refId": "A",
"expr": "sum(gnatsd_varz_subscriptions{job=\"nats-exporter\"})"
}
]
},
{
"id": 8,
"type": "timeseries",
"title": "JetStream API Calls / Errors",
"datasource": {
"type": "prometheus",
"uid": "prometheus-dev"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 0
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 6,
"y": 20
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"refId": "A",
"expr": "sum(rate(gnatsd_varz_jetstream_stats_api_total{job=\"nats-exporter\"}[1m]))",
"legendFormat": "api total"
},
{
"refId": "B",
"expr": "sum(rate(gnatsd_varz_jetstream_stats_api_errors{job=\"nats-exporter\"}[1m]))",
"legendFormat": "api errors"
}
]
},
{
"id": 9,
"type": "timeseries",
"title": "Server CPU / Memory",
"datasource": {
"type": "prometheus",
"uid": "prometheus-dev"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 0
}
]
},
"unit": "none"
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Memory (bytes)"
},
"properties": [
{
"id": "unit",
"value": "bytes"
}
]
}
]
},
"gridPos": {
"h": 8,
"w": 12,
"x": 18,
"y": 20
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"refId": "A",
"expr": "avg(gnatsd_varz_cpu{job=\"nats-exporter\"})",
"legendFormat": "CPU (%)"
},
{
"refId": "B",
"expr": "sum(gnatsd_varz_mem{job=\"nats-exporter\"})",
"legendFormat": "Memory (bytes)"
}
]
}
@@ -317,6 +317,397 @@
"expr": "rate(process_cpu_seconds_total{job=\"otel-collector\"}[5m])"
}
]
},
{
"id": 6,
"type": "timeseries",
"title": "Messages Processed Rate",
"datasource": {
"type": "prometheus",
"uid": "prometheus-dev"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 0
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 12
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"refId": "A",
"expr": "sum by (message_status) (rate(caatsm_messages_processed_total[1m]))",
"legendFormat": "{{message_status}}"
}
]
},
{
"id": 7,
"type": "timeseries",
"title": "Publish Failures Rate",
"datasource": {
"type": "prometheus",
"uid": "prometheus-dev"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "orange",
"value": 100
},
{
"color": "red",
"value": 500
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 12
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"refId": "A",
"expr": "sum(rate(caatsm_publish_failures_total[1m]))",
"legendFormat": "failures/s"
}
]
},
{
"id": 8,
"type": "timeseries",
"title": "Exporter Queue Size vs Capacity",
"datasource": {
"type": "prometheus",
"uid": "prometheus-dev"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 0
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 20
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"refId": "A",
"expr": "avg(otelcol_exporter_queue_size{job=\"otel-collector\",exporter=\"otlp/jaeger\"})",
"legendFormat": "queue size"
},
{
"refId": "B",
"expr": "avg(otelcol_exporter_queue_capacity{job=\"otel-collector\",exporter=\"otlp/jaeger\"})",
"legendFormat": "capacity"
}
]
},
{
"id": 9,
"type": "timeseries",
"title": "Parse Duration (P95 / P50)",
"datasource": {
"type": "prometheus",
"uid": "prometheus-dev"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 0
}
]
},
"unit": "ms"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 20
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.95, sum(rate(caatsm_parse_duration_ms_bucket[5m])) by (le))",
"legendFormat": "p95"
},
{
"refId": "B",
"expr": "histogram_quantile(0.50, sum(rate(caatsm_parse_duration_ms_bucket[5m])) by (le))",
"legendFormat": "p50"
}
]
},
{
"id": 10,
"type": "timeseries",
"title": "Metrics Export Rate (logging)",
"datasource": {
"type": "prometheus",
"uid": "prometheus-dev"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 0
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 28
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"refId": "A",
"expr": "sum(rate(otelcol_exporter_sent_metrics{job=\"otel-collector\",exporter=\"logging\"}[1m]))",
"legendFormat": "sent metrics/s"
},
{
"refId": "B",
"expr": "sum(rate(otelcol_exporter_failed_metrics{job=\"otel-collector\",exporter=\"logging\"}[1m]))",
"legendFormat": "failed metrics/s"
}
]
},
{
"id": 11,
"type": "stat",
"title": "Collector Uptime (s)",
"datasource": {
"type": "prometheus",
"uid": "prometheus-dev"
},
"fieldConfig": {
"defaults": {
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "s"
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 6,
"x": 12,
"y": 28
},
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"targets": [
{
"refId": "A",
"expr": "otelcol_process_uptime{job=\"otel-collector\"}"
}
]
},
{
"id": 12,
"type": "timeseries",
"title": "Process Heap / Sys Memory",
"datasource": {
"type": "prometheus",
"uid": "prometheus-dev"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "bytes"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 18,
"y": 28
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"targets": [
{
"refId": "A",
"expr": "sum(otelcol_process_runtime_heap_alloc_bytes{job=\"otel-collector\"})",
"legendFormat": "heap alloc"
},
{
"refId": "B",
"expr": "sum(otelcol_process_runtime_total_sys_memory_bytes{job=\"otel-collector\"})",
"legendFormat": "sys memory"
}
]
}
]
}
+2 -4
View File
@@ -7,10 +7,8 @@ scrape_configs:
static_configs:
- targets:
- "otel-collector:8888"
- job_name: "nats"
metrics_path: /varz
scheme: http
- job_name: "nats-exporter"
static_configs:
- targets:
- "nats:8222"
- "nats-exporter:7777"