Skip to content

Commit

Permalink
Document compose configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
abizjak committed Nov 9, 2023
1 parent a2c60ef commit 5a176ff
Show file tree
Hide file tree
Showing 5 changed files with 268 additions and 101 deletions.
24 changes: 24 additions & 0 deletions kpi-tracker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,27 @@ This docker image can be built using
docker build --build-arg build_image=rust:1.70-buster --build-arg base_image=debian:buster -f ./scripts/Dockerfile ../
```
which produces a debian-buster based image.

## Compose configuration for local development

There is a [compose.yml](./scripts/compose.yml) file that can be used to start
up both a postgres database and grafana loaded with the dashboard to present
KPIs.

To start it use

```console
docker-compose -f ./scripts/compose.yml up
```
from the directory of the README file.

This will start a grafana service listening on port 3000 on the host, and a
postgres database listening on port 5432. The `kpi-tracker` database is created
on startup.

Note that no state is persisted, so when the process terminates all data is
forfeit.

This compose configuration uses the configurations in
[scripts/provisioning](./scripts/provisioning/) to set up the default grafana
dashboard and data source.
22 changes: 22 additions & 0 deletions kpi-tracker/scripts/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: '3'
services:
kpi-tracker-grafana:
image: grafana/grafana-oss
container_name: grafana
ports:
- "3000:3000"
volumes:
- ./provisioning:/etc/grafana/provisioning:Z
- ../grafana:/var/lib/grafana/dashboards:Z
environment:
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: "/var/lib/grafana/dashboards/dashboard.json"
GF_AUTH_ANONYMOUS_ENABLED: true
kpi-tracker-db:
image: postgres
command: -c fsync=off
environment:
POSTGRES_DB: "kpi-tracker"
POSTGRES_PASSWORD: "password"
ports:
- "5432:5432"
shm_size: '4GB'
6 changes: 6 additions & 0 deletions kpi-tracker/scripts/provisioning/dashboards/all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- name: 'default'
org_id: 1
folder: ''
type: 'file'
options:
folder: '/var/lib/grafana/dashboards'
18 changes: 18 additions & 0 deletions kpi-tracker/scripts/provisioning/datasources/all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: 1

datasources:
- name: Postgres
type: postgres
url: kpi-tracker-db:5432
user: postgres
secureJsonData:
password: 'password'
jsonData:
database: "kpi-tracker"
sslmode: 'disable' # disable/require/verify-ca/verify-full
maxOpenConns: 100 # Grafana v5.4+
maxIdleConns: 100 # Grafana v5.4+
maxIdleConnsAuto: true # Grafana v9.5.1+
connMaxLifetime: 14400 # Grafana v5.4+
# postgresVersion: 903 # 903=9.3, 904=9.4, 905=9.5, 906=9.6, 1000=10
timescaledb: false
Loading

0 comments on commit 5a176ff

Please sign in to comment.