System Log Monitoring Setup Guide (Docker Compose Services Only)
- 1.1 Overview
- 2 Prerequisites On the Monitoring Server
- 3 Setup Instructions
- 3.1 1. Prepare the Monitoring Server
- 3.2 2. Install Grafana & Loki
- 3.2.1 About the Reverse Proxy
- 3.3 4. Install a Log Exporter on the OpenMRS Server
- 3.4 5. Configure Loki as a Data Source in Grafana
- 3.5 6. Validate the Setup
- 3.5.1 A. Check Promtail Logs
- 3.5.2 B. Check Loki Status
- 3.5.3 C. Query Logs in Grafana
- 4 Conclusion
Overview
System log monitoring involves collecting, aggregating, and analyzing the logs produced by your running services. Unlike system metrics monitoring, which tracks CPU or memory usage, log monitoring focuses purely on application and container logs.
This guide describes how to enable log-only monitoring for an OpenMRS server running Docker Compose, using:
Grafana (visualization & querying)
Loki (log storage)
Promtail (log exporter for Docker logs)
No node-level or system-level metrics exporters (e.g., Node Exporter) are required.
Prerequisites On the Monitoring Server
Use a dedicated machine separate from the OpenMRS application server. Ensure the following are installed:
Docker
Docker Swarm (optional depending on your stack)
Loki (for log storage)
Grafana (for dashboards and log viewing)
On the OpenMRS Docker Server
Install a log exporter that can read Docker logs and send them to Loki:
Promtail – recommended for Docker log collection
Promtail reads OpenMRS container logs and forwards them to the monitoring server.
Setup Instructions
1. Prepare the Monitoring Server
Set up a dedicated monitoring server that will run:
Loki (log index + storage)
Grafana (log visualization)
A reverse proxy (optional)
Do not run these services on the same machine as the OpenMRS Docker Compose deployment.
2. Install Grafana & Loki
Grafana provides log-querying and visualization, while Loki stores all incoming logs.
For a quick setup, clone the DIGI monitoring repository:
git clone
GitHub - DIGI-UW/digi-monitoring
The repository includes configuration for:
Reverse proxy
Grafana
Loki
Start the Monitoring Stack
Inside the repository directory, run:
./mk.sh
This script deploys:
Reverse proxy
Grafana
Loki
About the Reverse Proxy
It provides:
Secure access to Grafana and Loki endpoints
Hidden internal ports and services
Central authentication if configured
4. Install a Log Exporter on the OpenMRS Server
To collect logs from the OpenMRS Docker Compose environment, install Promtail.
Recommended: Promtail (for Docker logs)
On the OpenMRS server, create a promtail-config.yamll file:
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /var/log/promtail-positions.yaml
clients:
url: http://<MONITORING_SERVER_IP>:3100/loki/api/v1/push
scrape_configs:
job_name: "docker-logs"
static_configs:
targets:
localhost
labels:
host: "<OPENMRS_SERVER_NAME>"
__path__: /var/lib/docker/containers/*/*.log
Add Promtail to your OpenMRS Docker Compose deployment:
promtail:
image: grafana/promtail:latest
container_name: promtail
restart: unless-stopped
volumes:
/var/lib/docker/containers:/var/lib/docker/containers:ro
/var/log:/var/log:ro
./promtail-config.yaml:/etc/promtail/config.yml
command: -config.file=/etc/promtail/config.yml
Start Promtail using the command:
docker compose up -d promtail Promtail will now forward all container logs (OpenMRS, MySQL, etc.) to the monitoring server.
5. Configure Loki as a Data Source in Grafana
On the monitoring server, access Grafana:
http://<MONITORING_SERVER_IP>:3000
Default login: admin / admin
Steps:
Go to Configuration → Data Sources
Click Add data source
Select Loki
Set the URL: http://loki:3100
Save & test.
Grafana is now connected to your log store.
6. Validate the Setup
A. Check Promtail Logs
On the OpenMRS server: docker logs promtail
Look for messages indicating successful pushes to Loki.
B. Check Loki Status
Visit:http://<MONITORING_SERVER_IP>:3100/ready
Should respond with ready.
C. Query Logs in Grafana
iOpen: http://<MONITORING_SERVER_IP>:3000/explore
Choose Loki as the data source.
Run a basic query:
{job="docker-logs"}
You should now see logs from all OpenMRS-related containers.
Conclusion
After completing the setup, your monitoring environment will:
Collect Docker logs from the OpenMRS server
Store logs efficiently using Loki
Enable real-time log viewing and search in Grafana
Support log filtering by service, container, or log level
Provide historical logs for debugging and analysis
This log-only monitoring setup ensures that you have clear visibility into container behavior without collecting system metrics.