Setup Centralised Logging (docker)
Bahmni supports centralised logging which helps to visualise logs from different containers at a unified UI. Centralised logging has been configured with PLG (Promtail, Loki, Grafana) stack.
1. Install Loki Logging Driver
Loki stack uses Loki Docker Driver Client for getting logs of container and pushing to Loki. Run the following command to install the driver or take a look here.
docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
2. Update Logging Method in docker-compose.yml
The default configuration of docker-compose ships with default logging that is configured in docker daemon.
To enable loki logging for the services, in the docker-compose file under bahmni-lite or bahmni-standard folder, find the x-log-config
section and update the value from *default
to *loki
3. Start Loki stack services
Navigate to the bahmni-docker/bahmni-lite or bahmni-docker/bahmni-standard directory.
Add logging
profile to the .env file in the current folder.
Example: COMPOSE_PROFILES=bahmni-lite,logging
Now loki stack services can be started by running,
docker compose -f docker-compose.yml -f ../logging/docker-compose.yml up -d
4. Viewing Logs
Now navigate to
https://localhost/grafana
and login withadmin
as username and password and reset your password.Next click on Explore Icon in the Grafana Left Panel.
Use the log browser to choose label as
compose_service
and value with the container needed, then Click onRun Query
on the top right of the screen. This will show the current logs.You can also click on
Live
on the top right to see the live stream of the logs.
5. Loki Configuration
Loki supports different configuration in the form of YAML file. These configurations can be added in loki-config.yaml file.
i. Log Retention
The centralised logging stack is configured with a default retention period of 24 hours. But this can be configured as per requirements. To do so find the retention_period
config in the loki-config.yaml and change the value (minimum: 24h) as per requirement.
Example:
limits_config:
retention_period: 48h
After updating the configuration file, restart loki container by running docker compose -f docker-compose.yml -f docker-compose-monitoring.yml restart loki
Running Bahmni On Docker
The Bahmni documentation is licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)