Set up the reporting stack step-by-step

Overview

Below steps are explaining how to deploy NiFi and Superset services from the local machine, as it’s easier to make any adjustments than using Jenkins at this point. If there are any errors encountered during the deployment take a look at the forum post. Additionally, the more detailed configuration was described in https://openlmis.atlassian.net/wiki/spaces/OP/pages/489455617.

Any changes in the NiFi Flows will require to update the template files in the repository. Section Updating the XML templates explains how to do it.

Preliminaries

Steps to Execute

1. Prepare the Docker certificates

  1. Add your local machine to authorized_hosts (step 2 from this instruction) - in order to be able to execute the scripts

  2. On your local machine create docker-machine (step 3 from this instruction) with generic-IP-address set to the domain name (reporting.openlmis.org) and with the target machine name set instead of name1 (to simplify the instruction we’ll refer to it as name1)

  3. Copy directory ~/.docker/machine/machines/name1 via SSH to the EC2 instance, to the same directory:

    scp -r ~/.docker/machine/machines/name1 ubuntu@reporting.openlmis.org:/home/ubuntu/.docker/machine/machines/name1
  4. Enter the instance via SSH, and edit file /home/ubuntu/.docker/machine/machines/name1/config.json - the paths to docker machines might be different as it was generated in a different environment - it should be adjusted to EC2

2. Deploy the initial Nifi & Superset

  1. Execute the services/deploy_services.sh script (from deployment)

  2. Log in to the NiFi (reporting.openlmis.org/nifi)

  3. Verify if the process groups can be executed properly (Right mouse button → stop & start)

As the initial XML files might contain some variables like URLs or credentials (that are automatically updated/replaced during the redeploy) it’s recommended to export the initially loaded Process Groups once to avoid any confusion. Section Updating the XML templates explains how to do it.

3. Connect OpenLMIS with the Superset

  1. Create an OpenLMIS user (with email and any roles that might be used in the reports) that will be used by the Superset. In the instruction, a superset is used as its username (using a UI for this is a convenient way).

  2. Configure OpenLMIS to create an OAuth Client for superset. Add the following lines in settings.env of OpenLMIS v3 (not reporting stack’s settings.env). PS: client ID should be any value different from the word “superset” and should match what is configured in reporting stack’s settings.env.

    SUPERSET_CLIENT_ID=<ClientID> SUPERSET_CLIENT_SECRET= SUPERSET_REDIRECT_URI=<Superset URL>/oauth-authorized/openlmis

     

  3. Log in to the OpenLMIS as a superset to verify if it’s working. The user should be able to access the Superset reports in the Reports tab.

4. Set up the Jenkins job

  1. Create a job for the deployment of the NiFi & Superset with the following script (might needs some adjustments in directories) to execute:

    cp ./credentials/reporting/settings.env ./distro/reporting/settings.env cd ./deployment/reporting_env/services ./deploy_services.sh ../../../distro

Updating the XML templates

Any changes made on the Flows will be lost when the NiFi is redeployed if the XML templates won’t be updated. Below steps describes the update process:

  1. Create new templates of changed Process Group (Right mouse button -> Create template)

  2. Download the templates and update those XML files in the repository (available in ‘Templates’ option in the main hamburger menu)

OpenLMIS: the global initiative for powerful LMIS software