diff --git a/deploy/grafana/obsx-service.json b/deploy/grafana/obsx-service.json new file mode 100644 index 0000000..15adf5a --- /dev/null +++ b/deploy/grafana/obsx-service.json @@ -0,0 +1,1410 @@ +{ + "title": "obsx service", + "uid": "obsx-service", + "description": "Standard dashboard for services instrumented with git.codelab.vc/pkg/obsx.", + "tags": [ + "obsx" + ], + "editable": true, + "schemaVersion": 39, + "time": { + "from": "now-1h", + "to": "now" + }, + "refresh": "30s", + "templating": { + "list": [ + { + "name": "datasource", + "type": "datasource", + "query": "prometheus", + "label": "Datasource" + }, + { + "name": "job", + "type": "query", + "label": "Service", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "query": { + "query": "label_values(service_build_info, job)", + "refId": "job" + }, + "definition": "label_values(service_build_info, job)", + "refresh": 2, + "multi": true, + "includeAll": false, + "sort": 1 + } + ] + }, + "annotations": { + "list": [] + }, + "panels": [ + { + "type": "row", + "title": "Overview", + "id": 1, + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "panels": [] + }, + { + "type": "table", + "id": 2, + "title": "Instances", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 1 + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "service_build_info{job=~\"$job\"}", + "format": "table", + "instant": true, + "refId": "A" + } + ], + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "Value": true, + "__name__": true + }, + "indexByName": { + "service": 0, + "version": 1, + "environment": 2, + "revision": 3, + "go_version": 4, + "instance": 5, + "job": 6 + } + } + } + ] + }, + { + "type": "timeseries", + "id": 3, + "title": "Health checks (1 = ok)", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 7 + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "health_check_status{job=~\"$job\"}", + "legendFormat": "{{instance}} {{kind}}/{{check}}", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "timeseries", + "id": 4, + "title": "Restarts (15m)", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 7 + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "changes(process_start_time_seconds{job=~\"$job\"}[15m])", + "legendFormat": "{{instance}}", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "timeseries", + "id": 5, + "title": "Up", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 7 + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "up{job=~\"$job\"}", + "legendFormat": "{{instance}}", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "row", + "title": "HTTP server", + "id": 6, + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 15 + }, + "panels": [] + }, + { + "type": "timeseries", + "id": 7, + "title": "Requests by route", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 16 + }, + "fieldConfig": { + "defaults": { + "unit": "reqps", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum by (route) (rate(http_server_requests_total{job=~\"$job\"}[$__rate_interval]))", + "legendFormat": "{{route}}", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "timeseries", + "id": 8, + "title": "Error ratio (5xx)", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 16 + }, + "fieldConfig": { + "defaults": { + "unit": "percentunit", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum(rate(http_server_requests_total{job=~\"$job\",code=~\"5..\"}[$__rate_interval])) / sum(rate(http_server_requests_total{job=~\"$job\"}[$__rate_interval]))", + "legendFormat": "5xx", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "timeseries", + "id": 9, + "title": "Latency", + "description": "Exemplars link to traces when the Prometheus datasource has exemplars enabled.", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 16 + }, + "fieldConfig": { + "defaults": { + "unit": "s", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "histogram_quantile(0.50, sum by (le) (rate(http_server_request_duration_seconds_bucket{job=~\"$job\"}[$__rate_interval])))", + "legendFormat": "p50", + "refId": "A", + "exemplar": true + }, + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_seconds_bucket{job=~\"$job\"}[$__rate_interval])))", + "legendFormat": "p95", + "refId": "B", + "exemplar": true + }, + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "histogram_quantile(0.99, sum by (le) (rate(http_server_request_duration_seconds_bucket{job=~\"$job\"}[$__rate_interval])))", + "legendFormat": "p99", + "refId": "C", + "exemplar": true + } + ] + }, + { + "type": "timeseries", + "id": 10, + "title": "Responses by code", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 24 + }, + "fieldConfig": { + "defaults": { + "unit": "reqps", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum by (code) (rate(http_server_requests_total{job=~\"$job\"}[$__rate_interval]))", + "legendFormat": "{{code}}", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "timeseries", + "id": 11, + "title": "p95 latency by route", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 24 + }, + "fieldConfig": { + "defaults": { + "unit": "s", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "histogram_quantile(0.95, sum by (le, route) (rate(http_server_request_duration_seconds_bucket{job=~\"$job\"}[$__rate_interval])))", + "legendFormat": "{{route}}", + "refId": "A", + "exemplar": true + } + ] + }, + { + "type": "timeseries", + "id": 12, + "title": "In-flight requests", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 24 + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum by (instance) (http_server_requests_in_flight{job=~\"$job\"})", + "legendFormat": "{{instance}}", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "row", + "title": "gRPC server", + "id": 13, + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 32 + }, + "panels": [] + }, + { + "type": "timeseries", + "id": 14, + "title": "Calls by method", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 33 + }, + "fieldConfig": { + "defaults": { + "unit": "reqps", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum by (service, method) (rate(grpc_server_requests_total{job=~\"$job\"}[$__rate_interval]))", + "legendFormat": "{{service}}/{{method}}", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "timeseries", + "id": 15, + "title": "Calls by code", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 33 + }, + "fieldConfig": { + "defaults": { + "unit": "reqps", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum by (code) (rate(grpc_server_requests_total{job=~\"$job\"}[$__rate_interval]))", + "legendFormat": "{{code}}", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "timeseries", + "id": 16, + "title": "Latency", + "description": "Exemplars link to traces when the Prometheus datasource has exemplars enabled.", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 33 + }, + "fieldConfig": { + "defaults": { + "unit": "s", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "histogram_quantile(0.50, sum by (le) (rate(grpc_server_request_duration_seconds_bucket{job=~\"$job\"}[$__rate_interval])))", + "legendFormat": "p50", + "refId": "A", + "exemplar": true + }, + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "histogram_quantile(0.95, sum by (le) (rate(grpc_server_request_duration_seconds_bucket{job=~\"$job\"}[$__rate_interval])))", + "legendFormat": "p95", + "refId": "B", + "exemplar": true + }, + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "histogram_quantile(0.99, sum by (le) (rate(grpc_server_request_duration_seconds_bucket{job=~\"$job\"}[$__rate_interval])))", + "legendFormat": "p99", + "refId": "C", + "exemplar": true + } + ] + }, + { + "type": "row", + "title": "Dependencies (outgoing calls)", + "id": 17, + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 41 + }, + "panels": [] + }, + { + "type": "timeseries", + "id": 18, + "title": "HTTP calls by host and code", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 42 + }, + "fieldConfig": { + "defaults": { + "unit": "reqps", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum by (host, code) (rate(http_client_requests_total{job=~\"$job\"}[$__rate_interval]))", + "legendFormat": "{{host}} {{code}}", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "timeseries", + "id": 19, + "title": "HTTP p95 latency by host", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 42 + }, + "fieldConfig": { + "defaults": { + "unit": "s", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "histogram_quantile(0.95, sum by (le, host) (rate(http_client_request_duration_seconds_bucket{job=~\"$job\"}[$__rate_interval])))", + "legendFormat": "{{host}}", + "refId": "A", + "exemplar": true + } + ] + }, + { + "type": "timeseries", + "id": 20, + "title": "gRPC calls by service and code", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 42 + }, + "fieldConfig": { + "defaults": { + "unit": "reqps", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum by (service, code) (rate(grpc_client_requests_total{job=~\"$job\"}[$__rate_interval]))", + "legendFormat": "{{service}} {{code}}", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "row", + "title": "Operations (Observer.Track)", + "id": 21, + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 50 + }, + "panels": [] + }, + { + "type": "timeseries", + "id": 22, + "title": "Rate by operation and status", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 51 + }, + "fieldConfig": { + "defaults": { + "unit": "ops", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum by (operation, status) (rate(operation_duration_seconds_count{job=~\"$job\"}[$__rate_interval]))", + "legendFormat": "{{operation}} {{status}}", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "timeseries", + "id": 23, + "title": "Error ratio by operation", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 51 + }, + "fieldConfig": { + "defaults": { + "unit": "percentunit", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "sum by (operation) (rate(operation_duration_seconds_count{job=~\"$job\",status=\"error\"}[$__rate_interval])) / sum by (operation) (rate(operation_duration_seconds_count{job=~\"$job\"}[$__rate_interval]))", + "legendFormat": "{{operation}}", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "timeseries", + "id": 24, + "title": "p95 latency by operation", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 51 + }, + "fieldConfig": { + "defaults": { + "unit": "s", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "histogram_quantile(0.95, sum by (le, operation) (rate(operation_duration_seconds_bucket{job=~\"$job\"}[$__rate_interval])))", + "legendFormat": "{{operation}}", + "refId": "A", + "exemplar": true + } + ] + }, + { + "type": "row", + "title": "Go runtime", + "id": 25, + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 59 + }, + "panels": [] + }, + { + "type": "timeseries", + "id": 26, + "title": "CPU", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 60 + }, + "fieldConfig": { + "defaults": { + "unit": "percentunit", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "rate(process_cpu_seconds_total{job=~\"$job\"}[$__rate_interval])", + "legendFormat": "{{instance}}", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "timeseries", + "id": 27, + "title": "Memory", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 60 + }, + "fieldConfig": { + "defaults": { + "unit": "bytes", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "process_resident_memory_bytes{job=~\"$job\"}", + "legendFormat": "RSS {{instance}}", + "refId": "A", + "exemplar": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "go_memstats_heap_inuse_bytes{job=~\"$job\"}", + "legendFormat": "heap {{instance}}", + "refId": "B", + "exemplar": false + } + ] + }, + { + "type": "timeseries", + "id": 28, + "title": "Goroutines", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 60 + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "go_goroutines{job=~\"$job\"}", + "legendFormat": "{{instance}}", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "timeseries", + "id": 29, + "title": "GC pause (max)", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 68 + }, + "fieldConfig": { + "defaults": { + "unit": "s", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "max by (instance) (go_gc_duration_seconds{job=~\"$job\",quantile=\"1\"})", + "legendFormat": "{{instance}}", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "timeseries", + "id": 30, + "title": "Open file descriptors", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 68 + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "process_open_fds{job=~\"$job\"}", + "legendFormat": "{{instance}}", + "refId": "A", + "exemplar": false + } + ] + }, + { + "type": "timeseries", + "id": 31, + "title": "DB pool in use (RegisterDBStats)", + "description": "", + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 68 + }, + "fieldConfig": { + "defaults": { + "unit": "short", + "custom": { + "fillOpacity": 10, + "lineWidth": 1 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "go_sql_in_use_connections{job=~\"$job\"}", + "legendFormat": "{{instance}} {{db_name}}", + "refId": "A", + "exemplar": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "expr": "go_sql_idle_connections{job=~\"$job\"}", + "legendFormat": "idle {{instance}} {{db_name}}", + "refId": "B", + "exemplar": false + } + ] + } + ] +} diff --git a/deploy/prometheus/alerts.yml b/deploy/prometheus/alerts.yml new file mode 100644 index 0000000..92b0dd3 --- /dev/null +++ b/deploy/prometheus/alerts.yml @@ -0,0 +1,115 @@ +# Prometheus alerting rules for services instrumented with obsx. +# +# Built-in obsx metrics have identical names in every service, so these rules +# work for all of them; alerts are grouped by the scrape "job" label. +# Thresholds are reasonable defaults: tune them per environment. +# +# Load with Prometheus `rule_files`, or wrap into a PrometheusRule resource +# (spec.groups = the groups below) for the Prometheus Operator. +groups: + - name: obsx-service + rules: + - alert: ServiceRestartingFrequently + expr: changes(process_start_time_seconds{job!=""}[15m]) > 2 + for: 0m + labels: + severity: warning + annotations: + summary: "{{ $labels.job }} ({{ $labels.instance }}) restarted {{ $value }} times in 15m" + + - alert: HealthCheckFailing + expr: health_check_status == 0 + for: 5m + labels: + severity: warning + annotations: + summary: "{{ $labels.job }}: {{ $labels.kind }} check {{ $labels.check }} is failing" + description: "Inspect /readyz or /healthz on the admin port of {{ $labels.instance }}." + + - name: obsx-http + rules: + - alert: HTTPServerHighErrorRate + expr: | + sum by (job) (rate(http_server_requests_total{code=~"5.."}[5m])) + / + sum by (job) (rate(http_server_requests_total[5m])) + > 0.05 + for: 5m + labels: + severity: critical + annotations: + summary: "{{ $labels.job }}: {{ $value | humanizePercentage }} of HTTP requests fail with 5xx" + + - alert: HTTPServerHighLatency + expr: | + histogram_quantile(0.99, + sum by (job, le) (rate(http_server_request_duration_seconds_bucket{route!="unmatched"}[5m])) + ) > 1 + for: 10m + labels: + severity: warning + annotations: + summary: "{{ $labels.job }}: HTTP p99 latency is {{ $value | humanizeDuration }}" + + - alert: HTTPClientHighErrorRate + expr: | + sum by (job, host) (rate(http_client_requests_total{code=~"5..|error"}[5m])) + / + sum by (job, host) (rate(http_client_requests_total[5m])) + > 0.1 + for: 5m + labels: + severity: warning + annotations: + summary: "{{ $labels.job }}: {{ $value | humanizePercentage }} of calls to {{ $labels.host }} fail" + + - name: obsx-grpc + rules: + - alert: GRPCServerHighErrorRate + expr: | + sum by (job) (rate(grpc_server_requests_total{code=~"Unknown|DeadlineExceeded|Unimplemented|Internal|Unavailable|DataLoss"}[5m])) + / + sum by (job) (rate(grpc_server_requests_total[5m])) + > 0.05 + for: 5m + labels: + severity: critical + annotations: + summary: "{{ $labels.job }}: {{ $value | humanizePercentage }} of gRPC calls fail with server errors" + + - alert: GRPCServerHighLatency + expr: | + histogram_quantile(0.99, + sum by (job, le) (rate(grpc_server_request_duration_seconds_bucket[5m])) + ) > 1 + for: 10m + labels: + severity: warning + annotations: + summary: "{{ $labels.job }}: gRPC p99 latency is {{ $value | humanizeDuration }}" + + - alert: GRPCClientHighErrorRate + expr: | + sum by (job, service) (rate(grpc_client_requests_total{code!~"OK|Canceled|InvalidArgument|NotFound|AlreadyExists|PermissionDenied|Unauthenticated|FailedPrecondition|OutOfRange"}[5m])) + / + sum by (job, service) (rate(grpc_client_requests_total[5m])) + > 0.1 + for: 5m + labels: + severity: warning + annotations: + summary: "{{ $labels.job }}: {{ $value | humanizePercentage }} of calls to {{ $labels.service }} fail" + + - name: obsx-operations + rules: + - alert: OperationHighErrorRate + expr: | + sum by (job, operation) (rate(operation_duration_seconds_count{status="error"}[5m])) + / + sum by (job, operation) (rate(operation_duration_seconds_count[5m])) + > 0.1 + for: 10m + labels: + severity: warning + annotations: + summary: "{{ $labels.job }}: operation {{ $labels.operation }} fails {{ $value | humanizePercentage }} of the time"