# 4.2.5.2 Configuring Metabase Dashboards

{% embed url="https://www.youtube.com/watch?v=nu0obCCmZak" %}

OpenCRVS includes a self-hosted, pre-configured Dashboards service, built on Metabase. In deployed environments, these dashboards can be found in the `metabase.<your domain>` address.

The recommended way of customising OpenCRVS dashboards is in a local development environment, during the development phase of the project. It is also possible to customise the dashboards through the Metabase UI once the environment has been deployed but to keep environments consistent and all configuration in version control, we do not recommend this. All changes to production OpenCRVS environments should always be implemented by a developer, committed to version control, thoroughly tested, and only then deployed to production.

To begin customising the dashboards, first initiate your local dashboards instance by navigating to `packages/dashboards` and executing `yarn start`. In development environments, the dashboard service is not automatically started because it consumes significant memory and is not essential for most local development tasks.\
After running the command, the dashboards can be accessed using the URL `http://localhost:4444/`.

```bash
cd packages/dashboards
yarn start
```

Note that for the following steps to work, you must also have the OpenCRVS development environment running on your machine.

<figure><img src="https://3067259618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fesn2q91OsFQf7ZqR8thb%2Fuploads%2Fgit-blob-8d2f90e0101a1cb36793e6c4117cf30ba5a5d490%2Fimage%20(56).png?alt=media" alt=""><figcaption><p>Metabase login page</p></figcaption></figure>

In local development environments, you can use the following credentials to log into metabase:

* Username: user@opencrvs.org
* Password: m3tabase

**Note: You must configure the username and password for the production environment via** [**environment variables**](../../3.3-set-up-a-server-hosted-environment/4.3.4-create-a-github-environment/4.3.4.1-environment-secrets-and-variables-explained) **otherwise** **the deployment will fail as they are required.**

### Updating the map used in geographical visualisations

Several dashboard visualisations rely on regional maps. The country configuration starter project ([`opencrvs-countryconfig`](https://github.com/opencrvs/opencrvs-countryconfig)) provides an example map located at `src/api/dashboards/file/map.geojson`.

<figure><img src="https://3067259618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fesn2q91OsFQf7ZqR8thb%2Fuploads%2Fgit-blob-a2f86fc14b68460c5a65941f3649a1e41f146fac%2Fimage%20(55).png?alt=media" alt=""><figcaption></figcaption></figure>

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".

<figure><img src="https://3067259618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fesn2q91OsFQf7ZqR8thb%2Fuploads%2Fgit-blob-d29f58c0e24feaf4c489a15fa23efba42d3bfd87%2Fimage%20(54).png?alt=media" alt=""><figcaption></figcaption></figure>

If you are not seeing your updates, click on "Refresh" and try directly navigating to the default address [http://localhost:3040/content/map.geojson](http://localhost:3040/content/map.geojson) which should now serve the updated GeoJSON.

{% hint style="danger" %}
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:

<pre><code><strong>echo `cat src/api/dashboards/file/&#x3C;your multiline geojson input file>.geojson` > src/api/dashboards/file/&#x3C;your single line geojson output file>.geojson
</strong></code></pre>
{% endhint %}

{% hint style="info" %}
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
{% endhint %}

```bash
export OPENCRVS_METABASE_MAP_URL=http://localhost:3040/content/map.geojson
export OPENCRVS_METABASE_MAP_NAME="Full country"
yarn start
```

Without the variables, these values will always change back to the default ones.

<figure><img src="https://3067259618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fesn2q91OsFQf7ZqR8thb%2Fuploads%2Fgit-blob-d1c7940fcee1539f99b0258457db7e0da4aae514%2Fimage%20(58).png?alt=media" alt=""><figcaption></figcaption></figure>

More information about customising dashboards and creating visualisations can be found from [the Metabase documentation](https://www.metabase.com/docs/latest/).

After customising the dashboards to suit your country's requirements, return to the terminal window where `yarn start` was executed. Press `Ctrl + C` to indicate that you are ready to save the configuration changes you've made. Following this action, you should observe a modification in the file `dashboards/metabase.init.db.sql`.

```bash
❯ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   dashboards/metabase.init.db.sql

no changes added to commit (use "git add" and/or "git commit -a")
```

This file should then be placed in the path `infrastructure/metabase/metabase.init.db.sql` within your country configuration repository. **It is important not to commit these file changes to opencrvs-core!** You should see your updated dashboards after you deploy the changed file.
