DHIS2 Text Query installation¶
This guide covers the installation of the DHIS2 Text Query service. The DHIS2 Text Query is a backend service and API for conversational analytics and visualization for DHIS2.
The service key is dhis2-text-query. The service port is 8094.
This guide assumes that a dedicated user for running the service called bao-admin exists.
JAR file¶
The service is available as a JAR file. The filename is dhis2-text-query.jar.
The JAR file should be installed in the following location.
Create the directory manually and make bao-admin the owner.
Place the JAR file in the previously created directory and make bao-admin the owner.
Systemd¶
The systemd service manager is used to manage the service process.
The systemd service file should be located in the /etc/systemd/system directory.
Create the system service file with the following content.
[Unit]
Description = DHIS2 Text Query service
[Service]
Environment = "JAVA_HOME=/usr/lib/jvm/java-1.17.0-openjdk-amd64"
Environment="JAVA_OPTS=-Xms512M -Xmx1024M"
ExecStart = /bin/bash -c '${JAVA_HOME}/bin/java ${JAVA_OPTS} -jar /var/lib/dhis2-text-query/dhis2-text-query.jar'
User = bao-admin
[Install]
WantedBy = multi-user.target
To enable the services on boot, invoke the following command.
PostgreSQL¶
The service requires a PostgreSQL database. The minimum PostgreSQL version is 14.
Create user.
Create database.
Configuration¶
The service is configured with a properties file called dhis2-text-query.conf.
The file should reside in the following location.
Create a configuration file with the following content.
# ----------------------------------------------------------------------
# DHIS2 Text Query
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# Database connection
# ----------------------------------------------------------------------
# Database connection URL
connection.url = jdbc:postgresql:dhis2textquery
# Database username
connection.username = dhis2textquery
# Database password (sensitive)
connection.password = mypassword
# ----------------------------------------------------------------------
# DHIS2
# ----------------------------------------------------------------------
# Base URL
dhis2.base_url = https://dhis2.mydomain.org
# ----------------------------------------------------------------------
# Google Gemini
# ----------------------------------------------------------------------
# API key (confidential)
google.gemini.api_key = xxxx
# Model, can be 'default', 'gemini-2.0-flash', 'gemini-2.5-flash'
google.gemini.model = gemini-2.5-flash
# ----------------------------------------------------------------------
# CORS
# ----------------------------------------------------------------------
# Origins from which to allow CORS
cors.allowed_origins = http://localhost,\
http://localhost:3000
Proxy¶
The service provides API endpoints. To make the API endpoints accessible, an HTTP proxy must be set up.
This is typically done by specifying a location block in nginx. In the nginx configuration file for DHIS2, immediately before the location block for DHIS2 itself, specify a location block for the service.
server {
# ..
# DHIS2 text query
location /text-query/ {
proxy_pass http://127.0.0.1:8094/text-query/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
}
}
Logging¶
The service uses the journalctl tool to view logs. To view log output, invoke the following command.
Start¶
The service is started by invoking the following command.
Stop¶
The service is stopped by invoking the following command.
Status¶
The service status is observed by invoking the following command.