### Start PostgreSQL Service Source: https://github.com/dhis2/dhis2-docs/blob/master/src/sysadmin/how-to/PostgreSQL-setup.md Ensures the PostgreSQL service is running after installation. ```bash sudo systemctl start postgresql ``` -------------------------------- ### Example: Get Subscribers for a Visualization Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/metadata.md Example of retrieving subscribers for a specific visualization object using its UID. ```http /api/visualizations/DkPKc1EUmC2/subscribers ``` -------------------------------- ### Enable and Start Prometheus Service Source: https://github.com/dhis2/dhis2-docs/blob/master/src/sysadmin/reference/monitoring.md Enable the Prometheus service to start on boot and then start it immediately. Verify its status to ensure it's running. ```bash systemctl enable prometheus systemctl start prometheus ``` -------------------------------- ### Install Nginx Source: https://github.com/dhis2/dhis2-docs/blob/master/src/sysadmin/reference/reverse_proxy_nginx.md Installs the Nginx web server using apt-get. This is a prerequisite for setting up Nginx as a reverse proxy. ```bash sudo apt-get install -y nginx ``` -------------------------------- ### Install Nginx Source: https://github.com/dhis2/dhis2-docs/blob/master/src/sysadmin/reference/monitoring.md Install the Nginx web server if it is not already present on the system. ```bash apt update apt-get install nginx ``` -------------------------------- ### Ansible Playbook for PostgreSQL Installation Source: https://github.com/dhis2/dhis2-docs/blob/master/src/sysadmin/how-to/PostgreSQL-setup.md Automates the setup of PostgreSQL on a Debian-based system. It updates the system, adds the PostgreSQL repository, installs the specified version along with PostGIS, and ensures the service is running. ```yaml - hosts: 127.0.0.1 become: true gather_facts: true vars: postgresql_version: 16 tasks: - name: "Update and upgrade database" ansible.builtin.apt: upgrade: true update_cache: true cache_valid_time: 86400 # Adding postgresql signing key - name: "Adding postgresql repo signing key" ansible.builtin.get_url: url: "https://www.postgresql.org/media/keys/ACCC4CF8.asc" dest: /etc/apt/trusted.gpg.d/postgresql.asc owner: root group: root mode: '0600' # adding apt signing key - name: "Adding postgres apt repository to sources list" ansible.builtin.apt_repository: repo: "deb [arch={{ guest_os_arch|default('amd64') }} signed-by=/etc/apt/trusted.gpg.d/postgresql.asc] https://apt.postgresql.org/pub/repos/apt {{ hostvars[inventory_hostname]['ansible_facts']['distribution_release'] }}-pgdg main" update_cache: true filename: apt_postgresql_org state: present # Install postgresql and python module for Postgres - name: "Installing postgres version {{ postgresql_version }}" ansible.builtin.apt: name: - ca-certificates - postgresql-{{ postgresql_version }} - postgresql-client-{{ postgresql_version }} - postgresql-{{ postgresql_version }}-postgis-{{ '2.5' if guest_os == '20.04' else '3' }} - python3-psycopg2 - libdbd-pg-perl # sometimes postgres is installed but not started - name: "Ensure postgresql is running" become: true ansible.builtin.service: name: postgresql state: started enabled: true ``` -------------------------------- ### Get Database Locales Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/i18n.md Example request to get database locales for a specific country and language. Uses GET request. ```bash /api/locales/dbLocales?country=US&language=en ``` -------------------------------- ### Job Queue Details Example Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/scheduling.md Example JSON response showing the details of a job queue named 'myQ'. ```json { "name": "myQ", "cronExpression": "0 0 1 ? * *", "sequence": ["FgAxa6eRSzQ", "BeclVERfWbg" ] } ``` -------------------------------- ### Get Details of a Specific Running Job (Example) Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/scheduling.md Example of retrieving the status of a running ANALYTICS_TABLE job. ```bash GET /api/scheduling/running/ANALYTICS_TABLE ``` -------------------------------- ### Analytics Explain Endpoint Example Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/analytics.md This example shows a GET request to the analytics explain endpoint. It includes various parameters to specify dimensions, filters, and metadata details for analyzing query performance. ```http GET /api/analytics/explain?displayProperty=NAME &dimension=dx:Uvn6LCg7dVU;sB79w2hiLp8,ou:USER_ORGUNIT &filter=pe:THIS_YEAR&includeNumDen=false&skipMeta=false &skipData=true&includeMetadataDetails=true ``` -------------------------------- ### Get Details of a Specific Completed Job (Example) Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/scheduling.md Example of retrieving details for a completed ANALYTICS_TABLE job. ```bash GET /api/scheduling/completed/ANALYTICS_TABLE ``` -------------------------------- ### Start and Enable PostgreSQL Service Source: https://github.com/dhis2/dhis2-docs/blob/master/src/sysadmin/getting-started/linux-manual-install.md Ensures the PostgreSQL service is running and configured to start automatically on system boot. ```sh sudo systemctl start postgresql sudo systemctl enable postgresql ``` -------------------------------- ### List of Job Queue Names Example Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/scheduling.md Example JSON response showing a list of job queue names. ```json ["queue_a", "queue_b"] ``` -------------------------------- ### Enable and Start Redis Service Source: https://github.com/dhis2/dhis2-docs/blob/master/src/sysadmin/how-to/installing_redis.md Ensure the Redis server service is enabled to start automatically on boot and start the service immediately. ```bash sudo systemctl enable redis-server sudo systemctl start redis-server ``` -------------------------------- ### Start DHIS2 Instance Source: https://github.com/dhis2/dhis2-docs/blob/master/src/sysadmin/getting-started/linux-manual-install.md Starts the DHIS2 instance by executing the Tomcat startup script as the 'dhis' user. ```bash sudo -u dhis /home/dhis/tomcat-dhis/bin/startup.sh ``` -------------------------------- ### Install Perl Source: https://github.com/dhis2/dhis2-docs/blob/master/src/tutorials/analysing-postgresql-logs-using-pgbadger.md Ensure Perl is installed on your system, as it is a prerequisite for pgBadger. ```bash sudo apt install perl ``` -------------------------------- ### Install pgBadger Source: https://github.com/dhis2/dhis2-docs/blob/master/src/tutorials/analysing-postgresql-logs-using-pgbadger.md Download, extract, and install the pgBadger tool. Adjust the version number in the commands to match the downloaded release. ```bash tar xvf pgbadger-13.1.tar.gz cd pgbadger-13.1 perl Makefile.PL make && sudo make install ``` -------------------------------- ### Example User Lookup Query Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/users.md An example request to the user lookup endpoint with a query string to find users. ```HTTP /api/userLookup?query=John ``` -------------------------------- ### Install GoAccess on Ubuntu Source: https://github.com/dhis2/dhis2-docs/blob/master/src/tutorials/analysing-nginx-logs-using-goaccess.md Installs the latest GoAccess version by adding its official repository and using apt-get. Ensure you have wget and gpg installed. ```bash wget -O - https://deb.goaccess.io/gnugpg.key | gpg --dearmor | sudo tee /usr/share/keyrings/goaccess.gpg >/dev/null echo "deb [signed-by=/usr/share/keyrings/goaccess.gpg] https://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/goaccess.list sudo apt-get update sudo apt-get install goaccess ``` -------------------------------- ### Example User Retrieval by Identifier Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/users.md An example of how to request a user's full details using their specific identifier. ```HTTP /api/users/OYLGMiazHtW ``` -------------------------------- ### Example JSON response for enrollments Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/tracker.md This is an example of the JSON structure returned when querying the enrollments endpoint. ```JSON { "pager": { "page": 1, "pageSize": 1 }, "enrollments": [ { "enrollment": "TRE0GT7eh7Q", "createdAt": "2019-08-21T13:28:00.056", "createdAtClient": "2018-11-13T15:06:49.009", "updatedAt": "2019-08-21T13:29:44.942", "updatedAtClient": "2019-08-21T13:29:44.942", "trackedEntity": "s4NfKOuayqG", "program": "M3xtLkYBlKI", "status": "COMPLETED", "orgUnit": "DiszpKrYNg8", "enrolledAt": "2023-11-13T00:00:00.000", "occurredAt": "2023-11-13T00:00:00.000", "followUp": false, "deleted": false, "notes": [] } ] } ``` -------------------------------- ### Get Organisation Unit Profile Data Example Request Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/organisation-unit-profile.md Example of a GET request to retrieve profile data for a specific organisation unit and period. The 'period' parameter is optional. ```http GET /api/organisationUnitProfile/DiszpKrYNg8/data?period=2021 ``` -------------------------------- ### Install an App Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/apps.md Install a DHIS2 app by uploading a zip file using a POST request. Ensure the 'file' part is correctly formatted. ```bash curl -X POST -u user:pass -F file=@app.zip "http://server.com/api/33/apps" ``` -------------------------------- ### Tracked Entity Single Object Example Request Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/tracker.md This is an example GET request to retrieve a specific tracked entity using its UID. ```http GET /api/tracker/trackedEntities/PQfMcpmXeFE ``` -------------------------------- ### Install Glowroot and Set Permissions Source: https://github.com/dhis2/dhis2-docs/blob/master/src/tutorials/glowroot.md Steps to download, unpack, and set ownership for Glowroot. Ensure the DHIS2 service user has write access to the installation directory. ```bash mkdir -p /opt/glowroot cd /opt/glowroot wget https://github.com/glowroot/glowroot/releases/download/v0.13.6/glowroot-0.13.6-dist.zip unzip glowroot-0.13.6-dist.zip chown -R dhis: /opt/glowroot ``` -------------------------------- ### Request Example for Tracker Job Status Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/tracker.md An example of a GET request to retrieve the status of a tracker import job using its UID. ```http GET /tracker/jobs/PQK63sMwjQp ``` -------------------------------- ### Run DHIS2 Installation Script Source: https://github.com/dhis2/dhis2-docs/blob/master/src/sysadmin/getting-started/linux-automated-install.md Navigate to the deploy directory, copy the host template, and execute the main deployment script to install DHIS2 and its components. ```bash cd dhis2-server-tools/deploy cp inventory/hosts.template inventory/hosts sudo ./deploy.sh ``` -------------------------------- ### Install Redis Server Source: https://github.com/dhis2/dhis2-docs/blob/master/src/sysadmin/how-to/installing_redis.md Install the Redis server package using APT after updating your package list and adding the necessary repository. ```bash sudo apt install redis-server ``` -------------------------------- ### Request Example for Tracker Import Report Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/tracker.md An example of a GET request to retrieve the report for a tracker import job, specifying the job UID and report mode. ```http GET /tracker/jobs/mEfEaFSCKCC/report ``` -------------------------------- ### Example Event Aggregate Query with Filters Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/analytics.md An example query to get aggregate event counts for a program, filtering by specific data elements ('Gender', 'Age') and date range. ```HTTP /api/analytics/events/aggregate/eBAyeGv0exc?startDate=2016-01-01&endDate=2016-10-31 &dimension=ou:O6uvpzGd5pu&dimension=oZg33kd9taw:EQ:Female&dimension=qrur9Dvnyt5:GT:50 ``` -------------------------------- ### Request to Get a Single Event by UID Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/tracker.md This is an example of a GET request to retrieve a single event using its unique identifier (UID). The `fields` parameter can be used to specify which sub-objects to include in the response. ```http GET /api/tracker/events/rgWr86qs0sI ``` -------------------------------- ### Get All System Settings Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/settings-and-configuration.md Retrieves all available system settings. ```APIDOC ## GET /api/33/systemSettings ### Description Retrieves all system settings. ### Method GET ### Endpoint /api/33/systemSettings ### Response #### Success Response (200) - **(application/json)** - A JSON object containing all system settings as key-value pairs. #### Response Example ```json { "keyUiLocale": "en", "applicationTitle": "DHIS2", ... } ``` ``` -------------------------------- ### GET /api/apps - List Installed Apps Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/apps.md Retrieves a list of all installed DHIS2 apps. The response includes an 'key' property for each app. This endpoint can be filtered by app type and name using query parameters. ```APIDOC ## GET /api/apps ### Description Lists all installed DHIS2 applications. The response contains a 'key' property for each app. Filtering by app type and name is supported. ### Method GET ### Endpoint `/api/{version}/apps` ### Query Parameters - **filter** (string) - Optional - Allows filtering the list of apps. Supported formats include `appType:eq:DASHBOARD_APP` and `name:ilike:youtube`. - `appType` supports `eq` operator. - `name` supports `eq` and `ilike` operators. ### Request Example ```bash curl -u user:pass -H "Accept: application/json" "http://server.com/api/33/apps" ``` ### Response #### Success Response (200) - **apps** (array) - A list of installed app objects, each containing a 'key' property. #### Response Example ```json [ { "key": "my-app-key", "name": "My App", "description": "An example app." } ] ``` ``` -------------------------------- ### POST /api/apps - Install an App Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/apps.md Installs a new app by uploading a ZIP archive. The request must be a POST request with the file part containing the app's ZIP file. ```APIDOC ## POST /api/apps ### Description Installs a DHIS2 application by uploading a ZIP archive. ### Method POST ### Endpoint `/api/{version}/apps` ### Request Body - **file** (file) - Required - The ZIP archive of the app to be installed. ### Request Example ```bash curl -X POST -u user:pass -F file=@app.zip "http://server.com/api/33/apps" ``` ``` -------------------------------- ### Get id and name from data elements and associated data sets Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/metadata.md To retrieve fields from nested objects, use bracket notation. This example gets the `id` and `name` from data elements and their associated data sets. ```HTTP /api/dataElements?fields=id,name,dataSets[id,name] ``` -------------------------------- ### Example Enrollment Query with Program Indicator and Relationship Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/analytics.md Example of a query to retrieve enrollments for a specific program and date range, displaying counts of linked entities via a specified relationship type and program indicator. ```HTTP /api/analytics/enrollments/query/WSGAb5XwJ3Y.json?dimension=mxZDvSZYxlw.nFICjJluo74 &startDate=2019-01-01&endDate=2019-01-31 ``` -------------------------------- ### Create DHIS2 Instance Configuration File Source: https://github.com/dhis2/dhis2-docs/blob/master/src/sysadmin/getting-started/linux-automated-install.md Create a configuration file for a DHIS2 instance by copying the template provided in `dhis2-server-tools/deploy/inventory/host_vars/`. This allows for instance-specific variable definitions. ```bash cp dhis2-server-tools/deploy/inventory/host_vars/dhis.template dhis2-server-tools/deploy/inventory/host_vars/dhis ``` -------------------------------- ### GET /api/dataItems - Pagination Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/visualizations.md Details on how pagination is handled for the /api/dataItems endpoint, including how to disable it and an example of a paginated response. ```APIDOC ## GET /api/dataItems - Pagination ### Description Pagination is enabled by default for the `/api/dataItems` endpoint. You can disable it by setting the `paging` query parameter to `false`. ### Method GET ### Endpoint /api/dataItems ### Parameters #### Query Parameters - **paging** (boolean) - Optional - Set to `false` to disable pagination. Defaults to `true`. ### Request Example (Disabling Pagination) ``` GET /api/dataItems?filter=dimensionItemType:in:[INDICATOR]&paging=false ``` ### Response Example (Paginated Response) ```json { "pager": { "page": 1, "pageCount": 20, "total": 969, "pageSize": 50 }, "dataItems": [...] } ``` ### Notes - For elements associated with a Program, the program name is prefixed to the element name, except for `Program Indicators`. - The endpoint returns only aggregatable data items. Valid aggregatable types include: `TEXT, LONG_TEXT, LETTER, BOOLEAN, TRUE_ONLY, NUMBER, UNIT_INTERVAL, PERCENTAGE, INTEGER, INTEGER_POSITIVE, INTEGER_NEGATIVE, INTEGER_ZERO_OR_POSITIVE, COORDINATE`. - Filtering is supported for the following attributes: `displayName`, `name`, `valueType`, `id`, `dimensionItemType`, `programId`. - Ordering might be considered invalid if conflicting filters are applied (e.g., ordering by `name` while filtering by `displayName`). ``` -------------------------------- ### Manage Nginx Service Source: https://github.com/dhis2/dhis2-docs/blob/master/src/sysadmin/reference/reverse_proxy_nginx.md Commands to start, reload, and stop the Nginx service. Use these to manage the Nginx process after installation or configuration changes. ```bash sudo /etc/init.d/nginx start ``` ```bash sudo /etc/init.d/nginx reload ``` ```bash sudo /etc/init.d/nginx stop ``` -------------------------------- ### Example Wildcard Route Usage Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/route.md Demonstrates how to run a wildcard route with sub-paths. The specified sub-paths are appended to the base wildcard URL for the upstream request. ```bash GET /api/routes/{id}/run/get GET /api/routes/postman-wildcard/run/get POST /api/routes/{id}/run/post POST /api/routes/postman-wildcard/run/post ``` -------------------------------- ### Search for Job Execution Errors Including Input Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/scheduling.md Example of a GET request to search for job execution errors, including the input payload of the job run. ```http GET /api/jobConfigurations/errors?includeInput=true ``` -------------------------------- ### Retrieve List of Configured Gateways Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/sms.md Use this GET endpoint to retrieve a list of all configured SMS gateways. No specific setup is required beyond having gateways configured. ```bash GET /api/33/gateways ``` -------------------------------- ### Basic Enrollment Query Example Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/analytics.md Retrieve enrollments from a specific program with dimensions and filters for data elements and attributes. Filters can include operators like 'eq' for equality. ```HTTP /api/analytics/enrollments/query/WSGAb5XwJ3Y.json ?dimension=ou:ImspTQPwCqd &dimension=w75KJ2mc4zz &dimension=WZbXY0S00lP.de0FEHSIoxh:eq:1 &dimension=w75KJ2mc4zz &dimension=WZbXY0S00lP.sWoqcoByYmD &dimension=edqlbukwRfQ.vANAXwtLwcT &startDate=2019-01-01&endDate=2019-01-31 ``` -------------------------------- ### Check User Authority Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/overview.md Check whether the currently authenticated user has a specific authority by making a GET request to the /api/me/authorization/{authority} endpoint. For example, to check for 'F_CONSTANT_ADD'. ```HTTP GET /api/me/authorization/F_CONSTANT_ADD ``` -------------------------------- ### Search for Job Execution Errors with Specific Criteria Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/scheduling.md Example of a GET request to search for job execution errors, filtering by job type, error code, and date range. ```http GET /api/jobConfigurations/errors?type=TRACKER_IMPORT_JOB&code=E1002&from=2024-01-01&to=2024-01-02 ``` -------------------------------- ### SQL View API Request with Filtering (Not Like Operator) Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/visualizations.md Example of excluding organization units whose names start with 'Bo' using the '!like' operator in SQL view filtering. ```http /api/sqlViews/w3UxFykyHFy/data.json?filter=orgunit_name:!like:Bo ``` -------------------------------- ### Create SQL Views Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/maintenance.md Recreates all SQL views in the database. Use POST or PUT method. ```bash POST PUT /api/maintenance/sqlViewsCreate ``` -------------------------------- ### Example of using 'size' and 'rename' transformers Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/metadata-gist.md Demonstrates how to use the 'size' transformer to get the count of children and 'rename' to change the field name. This is useful for optimizing responses by only fetching necessary data. ```api /api/organisationUnits/gist?fields=*,children::size~rename(child-count) ``` -------------------------------- ### List Ansible Connection Plugins Source: https://github.com/dhis2/dhis2-docs/blob/master/src/sysadmin/getting-started/dhis2-tools.md Use this command to list all available Ansible connection plugins. This is useful for understanding the different ways Ansible can connect to target hosts. ```bash ansible-doc -t connection --list ``` -------------------------------- ### Example: Check if orgunit code starts with WB_ Source: https://github.com/dhis2/dhis2-docs/blob/master/src/user/configure-programs-in-the-maintenance-app.md Uses the `d2:left` function to extract the first three characters of the `orgunit_code` and compares them to a prefix. This is useful for filtering based on organizational unit hierarchy or naming conventions. ```text d2:left(V{orgunit_code},3) == 'WB_' ``` -------------------------------- ### Install Recommended JRE Source: https://github.com/dhis2/dhis2-docs/blob/master/src/sysadmin/getting-started/linux-manual-install.md Installs the recommended Java Runtime Environment (JRE) for a specific DHIS2 version. Replace with the appropriate version number from the documentation table. ```sh sudo apt-get install -y openjdk--jre-headless ``` -------------------------------- ### Verify Java Installation Source: https://github.com/dhis2/dhis2-docs/blob/master/src/sysadmin/getting-started/linux-manual-install.md Checks the installed Java version to confirm the installation was successful. ```sh java -version ``` -------------------------------- ### Retrieve Multiple Data Values with Date Range and Children - cURL Source: https://github.com/dhis2/dhis2-docs/blob/master/src/developer/web-api/data.md This cURL example demonstrates fetching a larger bulk of data values using start and end dates, multiple data sets, multiple organisation units, and including child organisation units. The 'period' parameter takes precedence over 'startDate' and 'endDate' if both are provided. ```bash curl "https://play.dhis2.org/demo/api/dataValueSets?dataSet=pBOMPrpg1QX&dataSet=BfMAe6Itzgt &startDate=2013-01-01&endDate=2013-01-31&orgUnit=YuQRtpLP10I&orgUnit=vWbkYPRmKyS&children=true" -H "Accept:application/xml" -u admin:district ```