Skip to content

Monitoring

This guide covers monitoring of the BAO Analytics Platform (AP), including metrics, health checks, logs and alerts.

Overview

AP provides the following ways of monitoring the platform.

Type Description
Metrics Prometheus metrics for data loading, JVM, HTTP requests and more
Health check Endpoint which reports whether the service is up
Logs Service logs available through the systemd journal
Email alerts Email notifications sent when a data pipeline or destination fails

Metrics and health checks are provided by the data pipeline service (bao-data-pipeline).

Metrics

The data pipeline service exposes metrics in the Prometheus format, which can be collected by Prometheus and visualized with Grafana.

Endpoints

Metrics and health check endpoints are served on the management port 8184, which is separate from the API port 8084.

Endpoint Description
/actuator/prometheus Metrics in the Prometheus text format
/actuator/health Health status of the service

Retrieve metrics from the server.

curl http://localhost:8184/actuator/prometheus

Restrict access to the management port

The management port does not require authentication. The management port must not be exposed to the public internet and must not be proxied by Nginx. Allow access only from the server itself and from the Prometheus server, for example with a firewall rule.

Example firewall rule with ufw which allows access to the management port from a Prometheus server with IP address 10.0.0.5.

sudo ufw allow from 10.0.0.5 to any port 8184 proto tcp

Prometheus configuration

Example Prometheus scrape configuration in prometheus.yml, where ap.example.org is the host name of the AP server.

scrape_configs:
  - job_name: bao-data-pipeline
    metrics_path: /actuator/prometheus
    static_configs:
      - targets: ["ap.example.org:8184"]

All metrics carry the tag application="bao-data-pipeline".

Data load metrics

The following metrics describe data load jobs, which are data pipeline loads, destination loads and workflows. Metrics are recorded for jobs which run on a schedule, run as part of a workflow and run manually.

Metric Type Description
bao_dataload_job_duration_seconds_count Counter Number of completed data load jobs
bao_dataload_job_duration_seconds_sum Counter Total duration of data load jobs in seconds
bao_dataload_job_duration_seconds_bucket Histogram Duration of data load jobs in buckets
bao_dataload_job_duration_seconds_max Gauge Maximum duration of recent data load jobs
bao_dataload_rows_total Counter Number of rows loaded by data pipeline and destination jobs

The data load metrics carry the following tags.

Tag Description Example values
job_type Type of data load job DATA_PIPELINE_LOAD, DESTINATION_LOAD, WORKFLOW_LOAD
job_subtype Data pipeline or destination type, or none if not applicable DHIS2, POSTGRESQL, KOBO_TOOLBOX
outcome Outcome of the job, for duration metrics only success, failure
exception Exception for failed jobs, none for successful jobs IllegalStateException

Example queries

Number of failed data pipeline jobs per data pipeline type during the last hour.

sum by (job_subtype) (increase(bao_dataload_job_duration_seconds_count{job_type="DATA_PIPELINE_LOAD", outcome="failure"}[1h]))

Number of rows loaded per data pipeline type during the last day.

sum by (job_subtype) (increase(bao_dataload_rows_total{job_type="DATA_PIPELINE_LOAD"}[1d]))

Number of failed destination jobs during the last day.

sum(increase(bao_dataload_job_duration_seconds_count{job_type="DESTINATION_LOAD", outcome="failure"}[1d]))

95th percentile of the duration of data pipeline jobs per data pipeline type during the last day.

histogram_quantile(0.95, sum by (le, job_subtype) (rate(bao_dataload_job_duration_seconds_bucket{job_type="DATA_PIPELINE_LOAD"}[1d])))

Alerting

A useful starting point is to alert on failed data load jobs. Example Prometheus alerting rule.

groups:
  - name: bao-data-pipeline
    rules:
      - alert: DataLoadJobFailed
        expr: increase(bao_dataload_job_duration_seconds_count{outcome="failure"}[15m]) > 0
        labels:
          severity: warning
        annotations:
          summary: "Data load job failed: {{ $labels.job_type }} {{ $labels.job_subtype }}"

System metrics

In addition to data load metrics, the following standard metrics are available.

Metric prefix Description
jvm_ JVM memory, garbage collection, threads and classes
process_, system_ CPU usage, uptime and open files
http_server_ HTTP requests to the API
hikaricp_ Database connection pools
tomcat_ Web server sessions
logback_ Log events by log level
executor_ Task executors and schedulers

Health check

The health check endpoint reports the status of the data pipeline service. A healthy service responds with HTTP status 200.

curl http://localhost:8184/actuator/health
{"status":"UP"}

The health check endpoint can be used by load balancers and uptime monitoring tools.

Logs

The AP services run as systemd services, and logs are available through the systemd journal.

Service Systemd service
API gateway bao-api-gateway.service
Identity bao-identity.service
Data pipeline bao-data-pipeline.service

Follow the log of the data pipeline service.

sudo journalctl -u bao-data-pipeline -f