{ "uid": "scrobbler-database", "title": "Scrobbled: Database", "description": "Query latency and pool use from the app's side; Postgres health from postgres-exporter.", "tags": [ "scrobbler" ], "timezone": "browser", "editable": true, "graphTooltip": 1, "refresh": "30s", "time": { "from": "now-6h", "to": "now" }, "schemaVersion": 41, "version": 1, "templating": { "list": [] }, "annotations": { "list": [] }, "links": [ { "type": "dashboards", "tags": [ "scrobbler" ], "asDropdown": true, "title": "Scrobbled", "includeVars": false } ], "panels": [ { "type": "row", "title": "From the API", "id": 1, "collapsed": false, "gridPos": { "x": 0, "y": 0, "w": 24, "h": 1 }, "panels": [] }, { "type": "timeseries", "title": "Query latency by operation (p95)", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "histogram_quantile(0.95, sum by (le, operation) (rate(scrobbler_db_query_duration_seconds_bucket[$__rate_interval])))", "legendFormat": "{{operation}}", "refId": "A" } ], "fieldConfig": { "defaults": { "unit": "s", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "spanNulls": true }, "min": 0 }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom", "showLegend": true }, "tooltip": { "mode": "multi", "sort": "desc" } }, "id": 2, "gridPos": { "x": 0, "y": 1, "w": 12, "h": 8 } }, { "type": "timeseries", "title": "Queries / s by operation", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum by (operation) (rate(scrobbler_db_query_duration_seconds_count[$__rate_interval]))", "legendFormat": "{{operation}}", "refId": "A" } ], "fieldConfig": { "defaults": { "unit": "ops", "custom": { "lineWidth": 2, "fillOpacity": 40, "showPoints": "never", "spanNulls": true, "stacking": { "mode": "normal", "group": "A" } }, "min": 0 }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom", "showLegend": true }, "tooltip": { "mode": "multi", "sort": "desc" } }, "id": 3, "gridPos": { "x": 12, "y": 1, "w": 12, "h": 8 } }, { "type": "timeseries", "title": "Connection pool", "description": "Summed across gunicorn workers. In use at or above pool size means requests are running on overflow connections.", "datasource": { "type": "prometheus", "uid": "prometheus" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum(scrobbler_db_pool_connections{state=\"checked_out\"})", "legendFormat": "in use", "refId": "A" }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum(scrobbler_db_pool_connections{state=\"overflow\"})", "legendFormat": "overflow", "refId": "B" }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum(scrobbler_db_pool_connections{state=\"size\"})", "legendFormat": "pool size", "refId": "C" } ], "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "spanNulls": true }, "min": 0 }, "overrides": [ { "matcher": { "id": "byName", "options": "pool size" }, "properties": [ { "id": "custom.lineStyle", "value": { "fill": "dash", "dash": [ 10, 10 ] } }, { "id": "custom.fillOpacity", "value": 0 } ] } ] }, "options": { "legend": { "displayMode": "list", "placement": "bottom", "showLegend": true }, "tooltip": { "mode": "multi", "sort": "desc" } }, "id": 4, "gridPos": { "x": 0, "y": 9, "w": 12, "h": 8 } }, { "type": "timeseries", "title": "Query latency percentiles (all operations)", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "histogram_quantile(0.50, sum by (le) (rate(scrobbler_db_query_duration_seconds_bucket[$__rate_interval])))", "legendFormat": "p50", "refId": "A" }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "histogram_quantile(0.99, sum by (le) (rate(scrobbler_db_query_duration_seconds_bucket[$__rate_interval])))", "legendFormat": "p99", "refId": "B" } ], "fieldConfig": { "defaults": { "unit": "s", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "spanNulls": true }, "min": 0 }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom", "showLegend": true }, "tooltip": { "mode": "multi", "sort": "desc" } }, "id": 5, "gridPos": { "x": 12, "y": 9, "w": 12, "h": 8 } }, { "type": "row", "title": "Postgres", "id": 6, "collapsed": false, "gridPos": { "x": 0, "y": 17, "w": 24, "h": 1 }, "panels": [] }, { "type": "stat", "title": "Postgres", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "pg_up", "legendFormat": "__auto", "refId": "A" } ], "fieldConfig": { "defaults": { "unit": "short", "thresholds": { "mode": "absolute", "steps": [ { "color": "text", "value": null } ] }, "mappings": [ { "type": "value", "options": { "0": { "text": "Down", "color": "red" }, "1": { "text": "Up", "color": "green" } } } ] }, "overrides": [] }, "options": { "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "colorMode": "value", "graphMode": "area", "textMode": "auto", "justifyMode": "auto" }, "id": 7, "gridPos": { "x": 0, "y": 18, "w": 4, "h": 5 } }, { "type": "stat", "title": "Database size", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "pg_database_size_bytes{datname=\"scrobbler\"}", "legendFormat": "__auto", "refId": "A" } ], "fieldConfig": { "defaults": { "unit": "bytes", "thresholds": { "mode": "absolute", "steps": [ { "color": "text", "value": null } ] } }, "overrides": [] }, "options": { "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "colorMode": "value", "graphMode": "area", "textMode": "auto", "justifyMode": "auto" }, "id": 8, "gridPos": { "x": 4, "y": 18, "w": 5, "h": 5 } }, { "type": "stat", "title": "Connections", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum(pg_stat_database_numbackends{datname=\"scrobbler\"})", "legendFormat": "__auto", "refId": "A" } ], "fieldConfig": { "defaults": { "unit": "short", "thresholds": { "mode": "absolute", "steps": [ { "color": "text", "value": null } ] } }, "overrides": [] }, "options": { "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "colorMode": "value", "graphMode": "area", "textMode": "auto", "justifyMode": "auto" }, "id": 9, "gridPos": { "x": 9, "y": 18, "w": 5, "h": 5 } }, { "type": "stat", "title": "Cache hit ratio", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum(rate(pg_stat_database_blks_hit{datname=\"scrobbler\"}[$__rate_interval])) / (sum(rate(pg_stat_database_blks_hit{datname=\"scrobbler\"}[$__rate_interval])) + sum(rate(pg_stat_database_blks_read{datname=\"scrobbler\"}[$__rate_interval])))", "legendFormat": "__auto", "refId": "A" } ], "fieldConfig": { "defaults": { "unit": "percentunit", "decimals": 1, "thresholds": { "mode": "absolute", "steps": [ { "color": "red", "value": null }, { "color": "orange", "value": 0.9 }, { "color": "green", "value": 0.99 } ] } }, "overrides": [] }, "options": { "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "colorMode": "value", "graphMode": "area", "textMode": "auto", "justifyMode": "auto" }, "id": 10, "gridPos": { "x": 14, "y": 18, "w": 5, "h": 5 } }, { "type": "stat", "title": "Deadlocks (range)", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum(increase(pg_stat_database_deadlocks{datname=\"scrobbler\"}[$__range]))", "legendFormat": "__auto", "refId": "A" } ], "fieldConfig": { "defaults": { "unit": "short", "decimals": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 1 } ] } }, "overrides": [] }, "options": { "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "colorMode": "value", "graphMode": "area", "textMode": "auto", "justifyMode": "auto" }, "id": 11, "gridPos": { "x": 19, "y": 18, "w": 5, "h": 5 } }, { "type": "timeseries", "title": "Transactions / s", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum(rate(pg_stat_database_xact_commit{datname=\"scrobbler\"}[$__rate_interval]))", "legendFormat": "commits", "refId": "A" }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum(rate(pg_stat_database_xact_rollback{datname=\"scrobbler\"}[$__rate_interval]))", "legendFormat": "rollbacks", "refId": "B" } ], "fieldConfig": { "defaults": { "unit": "ops", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "spanNulls": true }, "min": 0 }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom", "showLegend": true }, "tooltip": { "mode": "multi", "sort": "desc" } }, "id": 12, "gridPos": { "x": 0, "y": 23, "w": 12, "h": 8 } }, { "type": "timeseries", "title": "Locks by mode", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum by (mode) (pg_locks_count{datname=\"scrobbler\"})", "legendFormat": "{{mode}}", "refId": "A" } ], "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 2, "fillOpacity": 40, "showPoints": "never", "spanNulls": true, "stacking": { "mode": "normal", "group": "A" } }, "min": 0 }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom", "showLegend": true }, "tooltip": { "mode": "multi", "sort": "desc" } }, "id": 13, "gridPos": { "x": 12, "y": 23, "w": 12, "h": 8 } }, { "type": "timeseries", "title": "Database size", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "pg_database_size_bytes{datname=\"scrobbler\"}", "legendFormat": "scrobbler", "refId": "A" } ], "fieldConfig": { "defaults": { "unit": "bytes", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "spanNulls": true } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom", "showLegend": true }, "tooltip": { "mode": "multi", "sort": "desc" } }, "id": 14, "gridPos": { "x": 0, "y": 31, "w": 24, "h": 7 } } ] }