Skip to content

Commit 687e60e

Browse files
committed
feat: monitoring with grafana & prometheus
1 parent b8e74aa commit 687e60e

30 files changed

+9837
-193
lines changed

docker-compose-infra.yml renamed to .docker/docker-compose-infra.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ services:
9595
\"upstream_ssl\": false,
9696
\"enforce_ssl\": false,
9797
\"default_max_clients\": 200,
98-
\"default_pool_size\": 15,
98+
\"default_pool_size\": 10,
9999
\"users\": [
100100
{
101101
\"db_user\": \"postgres\",
102102
\"db_password\": \"postgres\",
103103
\"mode_type\": \"transaction\",
104-
\"pool_size\": 15,
105-
\"pool_checkout_timeout\": 100
104+
\"pool_size\": 2,
105+
\"pool_checkout_timeout\": 5000
106106
}
107107
]
108108
}

.docker/docker-compose-monitoring.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
version: '3'
2+
services:
3+
pg_bouncer_exporter:
4+
image: spreaker/prometheus-pgbouncer-exporter
5+
environment:
6+
PGBOUNCER_EXPORTER_HOST: 0.0.0.0
7+
PGBOUNCER_EXPORTER_PORT: 9127
8+
PGBOUNCER_HOST: pg_bouncer
9+
PGBOUNCER_PORT: 6432
10+
PGBOUNCER_USER: postgres
11+
PGBOUNCER_PASS: postgres
12+
depends_on:
13+
- pg_bouncer
14+
ports:
15+
- 9127:9127
16+
17+
postgres_exporter:
18+
image: quay.io/prometheuscommunity/postgres-exporter
19+
ports:
20+
- "9187:9187"
21+
environment:
22+
DATA_SOURCE_NAME: postgres://postgres:postgres@tenant_db:5432/postgres?sslmode=disable
23+
24+
prometheus:
25+
image: prom/prometheus
26+
container_name: prometheus
27+
command:
28+
- '--config.file=/etc/prometheus/prometheus.yml'
29+
ports:
30+
- 9090:9090
31+
restart: unless-stopped
32+
volumes:
33+
- ./monitoring/prometheus:/etc/prometheus
34+
35+
grafana:
36+
image: grafana/grafana
37+
container_name: grafana
38+
ports:
39+
- 3000:3000
40+
restart: unless-stopped
41+
environment:
42+
- GF_SECURITY_ADMIN_USER=admin
43+
- GF_SECURITY_ADMIN_PASSWORD=grafana
44+
volumes:
45+
- ./monitoring/grafana/config:/etc/grafana/provisioning
46+
- ./monitoring/grafana/dashboards:/var/lib/grafana/dashboards

.env.sample

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,13 @@ RESPONSE_S_MAXAGE=0
2424
AUTH_JWT_SECRET=f023d3db-39dc-4ac9-87b2-b2be72e9162b
2525
AUTH_JWT_ALGORITHM=HS256
2626

27-
28-
#######################################
29-
# Single Tenant
30-
#######################################
31-
TENANT_ID=bjhaohmqunupljrqypxz
32-
3327
#######################################
3428
# Multi Tenancy
3529
# uncomment MULTI_TENANT=true to enable multi tenancy
36-
# the [Single Tenant] configurations will be ignored
3730
#######################################
3831
# MULTI_TENANT=true
3932
DATABASE_MULTITENANT_URL=postgresql://postgres:[email protected]:5433/postgres
40-
REQUEST_X_FORWARDED_HOST_REGEXP=
33+
REQUEST_X_FORWARDED_HOST_REGEXP=^([a-z]{20}).local.(?:com|dev)$
4134
SERVER_ADMIN_API_KEYS=apikey
4235
AUTH_ENCRYPTION_KEY=encryptionkey
4336

@@ -85,7 +78,7 @@ STORAGE_BACKEND=s3
8578
#######################################
8679
# S3 Backend
8780
#######################################
88-
STORAGE_S3_BUCKET=name-of-your-s3-bucket
81+
STORAGE_S3_BUCKET=supa-storage-bucket
8982
STORAGE_S3_MAX_SOCKETS=200
9083
STORAGE_S3_ENDPOINT=http://127.0.0.1:9000
9184
STORAGE_S3_FORCE_PATH_STYLE=true

Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ COPY migrations migrations
3131
COPY --from=production-deps /app/node_modules node_modules
3232
# Copy build artifacts from the build stage
3333
COPY --from=build /app/dist dist
34-
COPY ./docker-entrypoint.sh .
35-
36-
RUN node dist/scripts/migration-hash.js
3734

3835
EXPOSE 5000
39-
ENTRYPOINT ["./docker-entrypoint.sh"]
4036
CMD ["node", "dist/server.js"]

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ A scalable, light-weight object storage service.
2323

2424
- Copy `.env.sample` to `.env` file.
2525
- Copy `.env.test.sample` to `.env.test`.
26-
- Change `GLOBAL_S3_BUCKET` and `REGION` to the name and region of a S3 bucket.
27-
- If you just want to run the tests and not develop locally, you can skip this step because S3 calls are mocked in our tests.
28-
- [Set up your AWS credentials](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html). Your user must have permissions to `s3:PutObject, s3:GetObject, s3:DeleteObject` in the bucket you have chosen.
26+
27+
```bash
28+
cp .env.sample .env && cp .env.test.sample .env.test
29+
````
2930

3031
**Your root directory should now have both `.env` and `.env.test` files.**
3132

docker-compose-multi-tenant.yml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,51 +51,71 @@ services:
5151
IMGPROXY_URL: http://imgproxy:8080
5252
IMGPROXY_REQUEST_TIMEOUT: 15
5353

54+
PG_QUEUE_ENABLE: "true"
55+
DEBUG: "knex:tx"
56+
5457
tenant_db:
5558
extends:
5659
service: tenant_db
57-
file: docker-compose-infra.yml
60+
file: ./.docker/docker-compose-infra.yml
5861

5962
multitenant_db:
6063
extends:
6164
service: multitenant_db
62-
file: docker-compose-infra.yml
65+
file: ./.docker/docker-compose-infra.yml
6366

6467
supavisor:
6568
extends:
6669
service: supavisor
67-
file: docker-compose-infra.yml
70+
file: ./.docker/docker-compose-infra.yml
6871

6972
supavisor_setup:
7073
depends_on:
7174
supavisor:
7275
condition: service_healthy
7376
extends:
7477
service: supavisor_setup
75-
file: docker-compose-infra.yml
78+
file: ./.docker/docker-compose-infra.yml
7679

7780
minio:
7881
extends:
7982
service: minio
80-
file: docker-compose-infra.yml
83+
file: ./.docker/docker-compose-infra.yml
8184

8285
minio_setup:
8386
extends:
8487
service: minio_setup
85-
file: docker-compose-infra.yml
88+
file: ./.docker/docker-compose-infra.yml
8689
depends_on:
8790
- minio
8891

8992
imgproxy:
9093
extends:
9194
service: imgproxy
92-
file: docker-compose-infra.yml
95+
file: ./.docker/docker-compose-infra.yml
9396

9497
# Optional for rate-limiting
9598
# redis:
9699
# extends:
97100
# service: redis
98-
# file: docker-compose-infra.yml
101+
# file: ./.docker/docker-compose-infra.yml
102+
103+
# Optional for monitoring:
104+
# grafana:
105+
# extends:
106+
# service: grafana
107+
# file: ./.docker/docker-compose-monitoring.yml
108+
#
109+
# prometheus:
110+
# extends:
111+
# service: prometheus
112+
# file: ./.docker/docker-compose-monitoring.yml
113+
#
114+
# postgres_exporter:
115+
# extends:
116+
# service: postgres_exporter
117+
# file: ./.docker/docker-compose-monitoring.yml
118+
99119

100120
configs:
101121
init.sql:

docker-compose.yml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
version: '3'
44
services:
55
storage:
6-
image: supabase/storage-api:latest
6+
# image: supabase/storage-api:latest
7+
build:
8+
context: .
79
ports:
810
- '5000:5000'
911
- '5001:5001'
@@ -47,33 +49,54 @@ services:
4749
tenant_db:
4850
extends:
4951
service: tenant_db
50-
file: docker-compose-infra.yml
52+
file: ./.docker/docker-compose-infra.yml
5153

5254
pg_bouncer:
5355
extends:
5456
service: pg_bouncer
55-
file: docker-compose-infra.yml
57+
file: ./.docker/docker-compose-infra.yml
5658

5759
minio:
5860
extends:
5961
service: minio
60-
file: docker-compose-infra.yml
62+
file: ./.docker/docker-compose-infra.yml
6163

6264
minio_setup:
6365
extends:
6466
service: minio_setup
65-
file: docker-compose-infra.yml
67+
file: ./.docker/docker-compose-infra.yml
6668
depends_on:
6769
minio:
6870
condition: service_healthy
6971

7072
imgproxy:
7173
extends:
7274
service: imgproxy
73-
file: docker-compose-infra.yml
75+
file: ./.docker/docker-compose-infra.yml
7476

7577
# Optional for rate-limiting
7678
# redis:
7779
# extends:
7880
# service: redis
79-
# file: docker-compose-infra.yml
81+
# file: ./.docker/docker-compose-infra.yml
82+
83+
# Optional for monitoring
84+
# pg_bouncer_exporter:
85+
# extends:
86+
# service: pg_bouncer_exporter
87+
# file: ./.docker/docker-compose-monitoring.yml
88+
89+
# postgres_exporter:
90+
# extends:
91+
# service: postgres_exporter
92+
# file: ./.docker/docker-compose-monitoring.yml
93+
#
94+
# grafana:
95+
# extends:
96+
# service: grafana
97+
# file: ./.docker/docker-compose-monitoring.yml
98+
#
99+
# prometheus:
100+
# extends:
101+
# service: prometheus
102+
# file: ./.docker/docker-compose-monitoring.yml

docker-entrypoint.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: 1
2+
3+
providers:
4+
# <string> an unique provider name. Required
5+
- name: 'Default Dashboard'
6+
# <string> name of the dashboard folder.
7+
folder: 'Storage'
8+
type: file
9+
disableDeletion: false
10+
# <int> how often Grafana will scan for changed dashboards
11+
updateIntervalSeconds: 10
12+
allowUiUpdates: false
13+
options:
14+
# <string, required> path to dashboard files on disk. Required when using the 'file' type
15+
path: /var/lib/grafana/dashboards
16+
foldersFromFilesStructure: true
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: 1
2+
3+
datasources:
4+
- name: Prometheus
5+
type: prometheus
6+
url: http://prometheus:9090
7+
isDefault: true
8+
access: proxy
9+
editable: true
10+
uid: local_prometheus

0 commit comments

Comments
 (0)