OpenCRVS provides rich analytics functionality using Metabase, an open-source business intelligence platform. Metabase enables stakeholders to explore civil registration data through interactive dashboards, charts, tables, and maps.
Captures all actions performed on events (e.g., declarations, validations, registrations) and sends them to countryconfig to be stored in he database below via this endpoint.
2. Analytics Database (PostgreSQL)
The countryconfig analytics pipeline stores processed analytics in the analytics schema, primarily in the event_actions table.
3. Metabase
Connects directly to PostgreSQL to power dashboards and reports.
Configure UI components from database connections in Metabase
Follow the official Metabase documentation to create UI components that satisfy your reporting requirements. Control which events you wish to track in Metabase here.
Persist your changes
When Metabase stops (Ctrl+C), all updates are written to:
Commit the updated file
This ensures the dashboards are version-controlled.
Deploy
The new dashboards appear automatically in all environments.
π§ Other Development Commands
ποΈ Why Analytics Data Is Not Backed Up
Analytics tables are not included in backups for three reasons:
1. Regenerable
The analytics database is derived from event data. If lost, it can be fully rebuilt from the source records. This rebuild occurs on every OpenCRVS deployment via the reindex database migration.
2. Performance
Analytics tables can grow very large (GB β TB). Backing them up would increase:
Backup time
Storage costs
Restore time
3. Separation of concerns
Operational data is the source of truth; analytics is a read-optimised mirror that can be safely rebuilt.
βοΈ Configuration Reference
Database Connection Variables
METABASE_DATABASE_HOST
METABASE_DATABASE_PORT
METABASE_DATABASE_NAME
METABASE_DATABASE_USER
METABASE_DATABASE_PASSWORD
Analytics Schema
Primary table:
Contains:
Processed event data
Action timestamps
Calculated metrics
Non-PII fields only
Maps Configuration (Geographical Dashboards)
OPENCRVS_METABASE_MAP_NAME
OPENCRVS_METABASE_MAP_URL
OPENCRVS_METABASE_MAP_REGION_KEY
OPENCRVS_METABASE_MAP_REGION_NAME
These settings allow Metabase to render geographic dashboards (e.g., registration heatmaps by district).
Updating the map used in geographical visualisations
Several dashboard visualisations rely on regional maps. We provide an example map located at src/api/dashboards/file/map.geojson.
The simplest method to customise this map is by modifying the GeoJSON file's content. In local development environment, you should see the map changing right away in Metabase. To verify this, proceed to the Admin Settings by clicking the cog-icon at the top right corner of Metabase, and then navigate to "Maps". In "Custom maps", click on the map labeled "Full country".
If you are not seeing your updates, click on "Refresh" and try directly navigating to the default address http://localhost:3040/content/map.geojson which should now serve the updated GeoJSON.
Your map geojson file must be a single line, not multi-line file. This command can convert a multi-line json into single line file:
Notice that changing the map name or url will have no effect after you stop and restart the Metabase environment once. For these to be changed, the Metabase development environment needs to be started using the following environment variables
Without the variables, these values will always change back to the default ones.
More information about customising dashboards and creating visualisations can be found from the Metabase documentation.
field: {
id: 'childDetails.firstName',
analytics: true, // Included in analytics pipeline - Do not set on any field containing PII e.g. names, ids, phone numbers, email addresses etc
}