diff --git a/.github/workflows/docker_test.yml b/.github/workflows/docker_test.yml new file mode 100644 index 0000000..4853aaa --- /dev/null +++ b/.github/workflows/docker_test.yml @@ -0,0 +1,17 @@ + +name: Test Dockerd + +on: + push: + branches: + - '**' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: List things + run: | + cd docker_run + docker compose create + dokcer compose run diff --git a/docker_run/docker-compose.yml b/docker_run/docker-compose.yml new file mode 100644 index 0000000..e8dfc04 --- /dev/null +++ b/docker_run/docker-compose.yml @@ -0,0 +1,31 @@ +services: + database: + image: ghcr.io/baosystems/postgis:12-3.3 + ports: + - 127.0.0.1:5432:5432 + environment: + POSTGRES_USER: dhis + POSTGRES_DB: dhis + POSTGRES_PASSWORD: &postgres_password dhis + PGPASSWORD: *postgres_password # needed by psql in healthcheck + healthcheck: + test: ["CMD-SHELL", "psql --no-password --quiet --username $$POSTGRES_USER postgres://127.0.0.1/$$POSTGRES_DB -p 5432 --command \"SELECT 'ok'\" > /dev/null"] + start_period: 120s + interval: 1s + timeout: 3s + retries: 5 + + prometheusdbexporter: + image: simpledotorg/prometheusdbexporter:ademarcq-13779.239 + ports: + - 127.0.0.1:8080:8080 + environment: + TODO: tada + TIDI: tudu + POSTGRES_PASSWORD: &postgres_password dhis + PGPASSWORD: *postgres_password # needed by psql in healthcheck + volumes: + - ./target/tmp:/tmp + - ./sources:/app/rtsl/prom_db_exporter/sources + + diff --git a/docker_run/sources/heartbeat.json b/docker_run/sources/heartbeat.json new file mode 100644 index 0000000..b6ef25e --- /dev/null +++ b/docker_run/sources/heartbeat.json @@ -0,0 +1,13 @@ +{ + "asynch": false, + "type": "sql", + "name": "dbHeartbeat", + "query": "select 1 as value, 'database' as source;", + "metrics": [{ + "metricName": "postgres_heartbeat", + "metricValueKey": "value", + "labelsKeys": { + "source": "source" + } + }] +} diff --git a/docker_run/sources/sessions.json b/docker_run/sources/sessions.json new file mode 100644 index 0000000..28570d2 --- /dev/null +++ b/docker_run/sources/sessions.json @@ -0,0 +1,14 @@ +{ + "asynch": false, + "type": "sql", + "name": "getSessionInfo", + "query": "select application_name, count(*) as value from pg_stat_activity group by application_name", + "metrics": [{ + "metricName": "postgres_sessions_per_application_count", + "metricValueKey": "value", + "labelsKeys": { + "application_name": "application_name" + } + }] +} + diff --git a/docker_run/sources/tracked_entities.json b/docker_run/sources/tracked_entities.json new file mode 100644 index 0000000..85e1948 --- /dev/null +++ b/docker_run/sources/tracked_entities.json @@ -0,0 +1,15 @@ +{ + "asynch": true, + "type": "sql", + "cron": "* * * * *", + "name": "DHIS2_Trackedentityinstance", + "query": "select trackedentityinstance.trackedentitytypeid, trackedentitytype.name, count(*) as value from trackedentityinstance left outer join trackedentitytype on trackedentityinstance.trackedentitytypeid = trackedentitytype.trackedentitytypeid group by trackedentityinstance.trackedentitytypeid, trackedentitytype.name", + "metrics": [{ + "metricName": "dhis2_trackedentityinstance_count", + "metricValueKey": "value", + "labelsKeys": { + "trackedentitytypeid": "trackedentitytypeid", + "name": "name" + } + }] +}