Skip to content

Commit

Permalink
Add "docker run" files
Browse files Browse the repository at this point in the history
  • Loading branch information
igbanam committed Oct 24, 2024
1 parent fcdb8ca commit d69bd67
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Webapps/PrometheusDatabaseExporterWar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ For now, only two types exist: **sql** and **file**. File is implemented as the

## Examples

There's an example docker compose file at `docker/docker-compose.yml`.

### Heartbeat (synchronous)

The simplest descriptor possible is that one:
Expand Down Expand Up @@ -165,5 +167,3 @@ The configuration can be done through a properties file containing the following
| config.parallel.thread.pool.size | int | 10 | number of maximum concurrent threads |
| config.root.folder | String | | path to the folder containing the json descriptors|
| cache.folder | String | | Path to the folder that will be used as a local cache for asynch metrics. |

## Docker Image
32 changes: 32 additions & 0 deletions Webapps/PrometheusDatabaseExporterWar/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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:
build:
context: ..
args:
PROJECT_VERSION: 0.0.0
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
Original file line number Diff line number Diff line change
@@ -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"
}
}]
}
13 changes: 13 additions & 0 deletions Webapps/PrometheusDatabaseExporterWar/docker/sources/sessions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"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"
}
}]
}
Original file line number Diff line number Diff line change
@@ -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"
}
}]
}

0 comments on commit d69bd67

Please sign in to comment.