Skip to content

Commit

Permalink
Set up sql-exporter to monitor db content
Browse files Browse the repository at this point in the history
As a start, monitor the amount of rows on sir-indexed tables.

Includes a dashboard with gauges for every table; I don't see
a reason why it would be useful to have these be line charts since
there's no reason we should expect huge jumps, it's just good
to have a clear idea of which tables are bigger with the numbers.
  • Loading branch information
reosarevok committed Jan 16, 2025
1 parent 22f7bf7 commit cbb90c9
Show file tree
Hide file tree
Showing 6 changed files with 1,314 additions and 24 deletions.
15 changes: 15 additions & 0 deletions compose/monitoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ services:
db:
condition: service_started
restart: unless-stopped
sql-exporter:
image: burningalchemist/sql_exporter
container_name: sql-exporter
expose:
- 9399
command: --config.file=/etc/sql-exporter/sql-exporter.yml
volumes:
- ./default/sql-exporter.yml:/etc/sql-exporter/sql-exporter.yml
depends_on:
prometheus:
condition: service_started
db:
condition: service_started
restart: unless-stopped


volumes:
grafana-storage: {}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"panels": [
{
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"fieldConfig": {
"defaults": {
Expand Down Expand Up @@ -111,7 +111,7 @@
{
"alias": "fetched",
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"dsType": "prometheus",
"editorMode": "code",
Expand Down Expand Up @@ -170,7 +170,7 @@
{
"alias": "fetched",
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"dsType": "prometheus",
"editorMode": "code",
Expand Down Expand Up @@ -229,7 +229,7 @@
{
"alias": "fetched",
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"dsType": "prometheus",
"editorMode": "code",
Expand Down Expand Up @@ -288,7 +288,7 @@
{
"alias": "fetched",
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"dsType": "prometheus",
"editorMode": "code",
Expand Down Expand Up @@ -347,7 +347,7 @@
{
"alias": "fetched",
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"dsType": "prometheus",
"editorMode": "code",
Expand Down Expand Up @@ -409,7 +409,7 @@
},
{
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"fieldConfig": {
"defaults": {
Expand Down Expand Up @@ -475,7 +475,7 @@
"targets": [
{
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"dsType": "prometheus",
"editorMode": "code",
Expand Down Expand Up @@ -638,7 +638,7 @@
},
{
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"fieldConfig": {
"defaults": {
Expand Down Expand Up @@ -722,7 +722,7 @@
{
"alias": "conflicts",
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"dsType": "prometheus",
"expr": "sum(rate(pg_stat_database_deadlocks{datname=~\"$db\",instance=~\"$instance\"}[5m]))",
Expand Down Expand Up @@ -777,7 +777,7 @@
{
"alias": "deadlocks",
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"dsType": "prometheus",
"expr": "sum(rate(pg_stat_database_conflicts{datname=~\"$db\",instance=~\"$instance\"}[5m]))",
Expand Down Expand Up @@ -835,7 +835,7 @@
},
{
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"fieldConfig": {
"defaults": {
Expand Down Expand Up @@ -944,7 +944,7 @@
{
"alias": "Buffers Allocated",
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"dsType": "prometheus",
"editorMode": "code",
Expand Down Expand Up @@ -1001,7 +1001,7 @@
{
"alias": "Buffers Allocated",
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"dsType": "prometheus",
"editorMode": "code",
Expand Down Expand Up @@ -1058,7 +1058,7 @@
{
"alias": "Buffers Allocated",
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"dsType": "prometheus",
"editorMode": "code",
Expand Down Expand Up @@ -1115,7 +1115,7 @@
{
"alias": "Buffers Allocated",
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"dsType": "prometheus",
"editorMode": "code",
Expand Down Expand Up @@ -1172,7 +1172,7 @@
{
"alias": "Buffers Allocated",
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"dsType": "prometheus",
"editorMode": "code",
Expand Down Expand Up @@ -1232,7 +1232,7 @@
},
{
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"fieldConfig": {
"defaults": {
Expand Down Expand Up @@ -1314,7 +1314,7 @@
"targets": [
{
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"editorMode": "code",
"expr": "pg_stat_database_numbackends{datname!~\"template.*\",instance=~\"$instance\"}",
Expand All @@ -1331,7 +1331,7 @@
},
{
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"fieldConfig": {
"defaults": {
Expand Down Expand Up @@ -1413,7 +1413,7 @@
"targets": [
{
"datasource": {
"uid": "$datasource"
"uid": "prometheusdatasource"
},
"editorMode": "code",
"expr": "sum(pg_stat_database_blks_hit{datname=~\"$db\",instance=~\"$instance\"}) / (sum(pg_stat_database_blks_hit{datname=~\"$db\",instance=~\"$instance\"}) + sum(pg_stat_database_blks_read{datname=~\"$db\",instance=~\"$instance\"}))",
Expand Down Expand Up @@ -1443,7 +1443,7 @@
"text": "All",
"value": "$__all"
},
"datasource": "$datasource",
"datasource": "prometheusdatasource",
"definition": "",
"includeAll": true,
"name": "instance",
Expand All @@ -1459,7 +1459,7 @@
"text": "All",
"value": "$__all"
},
"datasource": "$datasource",
"datasource": "prometheusdatasource",
"definition": "label_values(pg_stat_database_tup_fetched{instance=~\"$instance\",datname!~\"template.*|postgres\"},datname)",
"includeAll": true,
"label": "db",
Expand Down Expand Up @@ -1489,7 +1489,7 @@
"text": "postgres",
"value": "postgres"
},
"datasource": "$datasource",
"datasource": "prometheusdatasource",
"definition": "label_values(pg_up, job)",
"includeAll": false,
"label": "job",
Expand Down
Loading

0 comments on commit cbb90c9

Please sign in to comment.