National Dashboard Ingest Service

Overview

The objective of national-dashboard-ingest service is listed as below.

  1. To provide a one-stop framework for ingesting data regardless of data-source based on configuration.

  2. To create provision for ingest based on module-wise requirement which directly or indirectly require aggregated data ingestion functionality.

Pre-requisites

  1. Prior Knowledge of Java/J2EE.

  2. Prior Knowledge of SpringBoot.

  3. Prior Knowledge of PostgresSQL.

  4. Prior Knowledge of REST APIs and related concepts like path parameters, headers, JSON etc.

  5. Prior Knowledge of ElasticSearch.

 

Setup And Key Functionalities

Setup:

  1. Step 1: Define the index name for the module as per your requirement in module.index.mapping key present in the configuration here - https://github.com/egovernments/DIGIT-DevOps/blob/master/deploy-as-code/helm/environments/qa.yaml#L364 .

  2. Step 2: Define the allowed metrics for the module as per your requirement in module.fields.mapping key present in the configuration here - https://github.com/egovernments/DIGIT-DevOps/blob/master/deploy-as-code/helm/environments/qa.yaml#L366

  3. Step 3: Define the allowed group-by fields for the module as per your requirement in module.allowed.groupby.fields.mapping key present in the configuration here - https://github.com/egovernments/DIGIT-DevOps/blob/master/deploy-as-code/helm/environments/qa.yaml#L368

  4. Step 4: Define the master data index name as per your requirement in master.data.index key present in the configuration here - https://github.com/egovernments/DIGIT-DevOps/blob/master/deploy-as-code/helm/environments/qa.yaml#L365

  5. Step 5: Define the allowed metrics for master data index as per your requirement in master.module.fields.mapping key present in the configuration here - https://github.com/egovernments/DIGIT-DevOps/blob/master/deploy-as-code/helm/environments/qa.yaml#L367

  6. Step 6: Create kafka connectors for all the modules that have been configured. A sample request for creating trade license national dashboard kafka connector is as follows -

    curl --location --request POST 'http://kafka-connect.kafka-cluster:8083/connectors/' \ --header 'Content-Type: application/json' \ --data-raw '{ "name": "cms-case-es-sink9128", "config": { "connector.class": "io.confluent.connect.elasticsearch.ElasticsearchSinkConnector", "connection.url": "http://elasticsearch-data-v1.es-cluster:9200/", "type.name": "nss", "topics": "tl-national-dashboard", "key.ignore": true, "schemas.enable": false, "schema.ignore": true, "value.converter.schemas.enable": false, "key.converter": "org.apache.kafka.connect.storage.StringConverter", "value.converter": "org.apache.kafka.connect.json.JsonConverter", "batch.size": 10, "max.buffered.records": 500, "flush.timeout.ms": 600000, "retry.backoff.ms": 5000, "read.timout.ms": 10000, "linger.ms": 100, "max.in.flight.requests": 2, "errors.log.enable": true, "errors.deadletterqueue.topic.name": "nss-es-failed", "tasks.max": 1 } }'
  7. Step 7: Run the national-dashboard-ingest application along with national-dashboard-ingest-kafka-pipeline.

Definitions:

  1. Config file - A YAML (xyz.yml) file which contains configuration for running national dashboard ingest.

  2. API - A REST endpoint to post data based on the configuration.

Functionality:

  1. When national dashboard ingest metrics API is hit, all the data payload lookup keys are first checked against the db to determine whether they already exist or not. The db table currently being used for storing lookup keys is nss-ingest-data.

  2. If the record for a given date and area details is not present, the payload is then flattened and pushed to nss-ingest-keydata topic.

  3. National dashboard ingest kafka pipeline consumer listens on nss-ingest-keydata topic and according to the module to which the data belongs to, pushes it to the respective topic defined in the module.index.mapping key.

  4. Once the national dashboard ingest kafka pipeline pushes data to the respective topic, a kafka-connector then takes the flattened records from that topic and ingests to ElasticSearch.

Deployment Details

  1. Add configs for different modules required for National Dashboard Ingest Service and National Dashboard Kafka Pipeline service.

  2. Deploy the latest version of National Dashboard Ingest and National dashboard kafka pipeline service.

  3. Add Role-Action mapping for API’s.

Integration

Integration Scope

The national dashboard service is used to push aggregated data present in systems and persisting them onto elasticsearch on top of which dashboards can be built for visualizing and analyzing data.

Integration Benefits

  • Can perform service-specific business logic without impacting the other module.

  • In the future, if we want to expose the application to citizen then it can be done easily.

Steps to Integration

  1. To integrate, host of national-dashboard-ingest-service module should be overwritten in helm chart.

  2. national-dashboard/metric/_ingest should be added as the search endpoint for the config added.

  3. national-dashboard/masterdata/_ingest should be added as the search endpoint for the config added.

API Details

URI: The format of the ingest API to be used to ingest data using national-dashboard-ingest is as follows:  national-dashboard/metric/_ingest

Body: Body consists of 2 parts: RequestInfo and Data. Data is where the aggregated data to be ingested resides. The keys given under metrics object here are metrics provided in module.fields.mapping present in the configuration here - https://github.com/egovernments/DIGIT-DevOps/blob/master/deploy-as-code/helm/environments/qa.yaml#L366

Example Ingest Request Body -

{     "RequestInfo": {         "apiId": "asset-services",         "ver": null,         "ts": null,         "action": null,         "did": null,         "key": null,         "msgId": "search with from and to values",         "authToken": "82c7da0d-da73-4c35-8ea7-5b231369b4cd",         "userInfo": {         "id": 41737,         "uuid": "9a81233f-e212-4035-a831-320b70e93b82",         "userName": "NDSS1",         "name": "National Dashboard Viewer",         "mobileNumber": "7777888813",         "emailId": null,         "locale": null,         "type": "EMPLOYEE",         "roles": [             {                 "name": "Employee",                 "code": "SUPERUSER",                 "tenantId": "pb.amritsar"             },             {                 "name": "National Dashboard Admin",                 "code": "NATADMIN",                 "tenantId": "pb.amritsar"             },             {                 "name": "FSM Employee Dashboard Viewer",                 "code": "FSM_DASHBOARD_VIEWER",                 "tenantId": "pb.amritsar"             },             {                 "name": "National Dashboard Admin",                 "code": "NATADMIN",                 "tenantId": "pb"             }         ],         "active": true,         "tenantId": "pb.amritsar",         "permanentCity": null     }     },     "Data": [         {         "date": "14-01-2017",         "module": "MCOLLECT",         "ward": "GODOWN AREA (BHABAT) - B14-SECTOR-13 - A1",         "ulb": "pb.amritsar",         "region": "Amritsar-MC",         "state": "Punjab",         "metrics": {             "numberOfCategories": 240,             "todaysCollection": [                 {                     "groupBy": "paymentMode",                     "buckets": [                         {                             "name": "UPI",                             "value": 70                         },                         {                             "name": "CASH",                             "value": 45                         },                         {                             "name": "DEBIT_CARD",                             "value": 20                         }                     ]                 },                 {                     "groupBy": "status",                     "buckets": [                         {                             "name": "NEW",                             "value": 70                         },                         {                             "name": "DEPOSITED",                             "value": 20                         },                         {                             "name": "DISHONOURED",                             "value": 45                         }                     ]                 },                 {                     "groupBy": "category",                     "buckets": [                         {                             "name": "COMMON_MASTERS_HOARDING",                             "value": 50                         },                         {                             "name": "COMMON_MASTERS_ROAD_SHOW",                             "value": 20                         },                         {                             "name": "COMMON_MASTERS_UNIPOLLS",                             "value": 5                         },                         {                             "name": "COMMON_MASTERS_AUCTION_FEE",                             "value": 25                         },                         {                             "name": "COMMON_MASTERS_USER_FEES",                             "value": 35                         }                     ]                 }             ],             "numberOfReceipts": [                 {                     "groupBy": "status",                     "buckets": [                         {                             "name": "NEW",                             "value": 70                         },                         {                             "name": "DEPOSITED",                             "value": 105                         },                         {                             "name": "DISHONOURED",                             "value": 50                         }                     ]                 },                 {                     "groupBy": "paymentMode",                     "buckets": [                         {                             "name": "CASH",                             "value": 70                         },                         {                             "name": "CHEQUE",                             "value": 105                         },                         {                             "name": "DEBIT_CARD",                             "value": 35                         },                         {                             "name": "ONLINE",                             "value": 15                         }                     ]                 },                 {                     "groupBy": "category",                     "buckets": [                         {                             "name": "COMMON_MASTERS_HOARDING",                             "value": 50                         },                         {                             "name": "COMMON_MASTERS_ROAD_SHOW",                             "value": 40                         },                         {                             "name": "COMMON_MASTERS_UNIPOLLS",                             "value": 45                         },                         {                             "name": "COMMON_MASTERS_AUCTION_FEE",                             "value": 55                         },                         {                             "name": "COMMON_MASTERS_USER_FEES",                             "value": 35                         }                     ]                 }             ],             "numberOfChallans": [                 {                     "groupBy": "challanStatus",                     "buckets": [                         {                             "name": "PAID",                             "value": 50                         },                         {                             "name": "CANCELLED",                             "value": 105                         },                         {                             "name": "ACTIVE",                             "value": 35                         }                     ]                 },                 {                     "groupBy": "category",                     "buckets": [                         {                             "name": "COMMON_MASTERS_HOARDING",                             "value": 50                         },                         {                             "name": "COMMON_MASTERS_ROAD_SHOW",                             "value": 40                         },                         {                             "name": "COMMON_MASTERS_UNIPOLLS",                             "value": 45                         },                         {                             "name": "COMMON_MASTERS_AUCTION_FEE",                             "value": 20                         },                         {                             "name": "COMMON_MASTERS_USER_FEES",                             "value": 35                         }                     ]                 }             ]         }     }] }

Module-wise Index Properties and Ingest Curls

The steps required for creation of index and adding the index mapping for the same can be found here - https://digit-discuss.atlassian.net/wiki/spaces/EPE/pages/2093482015 .

The following section contains module-wise index name, index mapping and ingest curls for ingesting data to national dashboard indexes.

1. Property Tax -

a. Index - pt-national-dashboard

b. Index mapping -

"properties" : { "assessedPropertiesForUsageCategory" : { "type" : "long" }, "assessments" : { "type" : "long" }, "cessForUsageCategory" : { "type" : "long" }, "createdBy" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "createdTime" : { "type" : "long" }, "date" : { "type" : "date", "format" : "dd-MM-yyyy HH:mm:ss||dd-MM-yyyy||epoch_millis||dd-MM-yyyy'T'HH:mm:ss.SSSZ" }, "financialYear" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "interestForUsageCategory" : { "type" : "long" }, "lastModifiedBy" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "lastModifiedTime" : { "type" : "long" }, "module" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "penaltyForUsageCategory" : { "type" : "long" }, "propertiesRegisteredForFinancialYear" : { "type" : "long" }, "propertyTaxForUsageCategory" : { "type" : "long" }, "rebateForUsageCategory" : { "type" : "long" }, "region" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "state" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "todaysClosedApplications" : { "type" : "long" }, "noOfPropertiesPaidToday" : { "type" : "long" }, "todaysCollectionForUsageCategory" : { "type" : "long" }, "todaysTotalApplications" : { "type" : "long" }, "transactionsForUsageCategory" : { "type" : "long" }, "ulb" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "usageCategory" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "ward" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } } }

c. Ingest curl -

 

2. Water and Sewerage -

a. Index name - ws-national-dashboard

b. Index mapping -

c. Ingest curl -

3. FireNOC -

a. Index name - firenoc-national-dashboard

b. Index mapping -

c. Ingest curl -

4. Public Grievance Redressal -

a. Index name - pgr-national-dashboard

b. Index mapping -

c. Ingest curl -

5. Trade License -

a. Index name - tl-national-dashboard

b. Index mapping -

c. Ingest curl -

6. MCollect -

a. Index name - mcollect-national-dashboard

b. Index mapping -

c. Ingest curl -

7. Online Building Permission System -

a. Index name - obps-national-dashboard

b. Index mapping -

c. Ingest curl -

8. Common -

a. Index name - common-national-dashboard

b. Index mapping -

c. Ingest curl -

Note: ulb, ward and region are not applicable as common-nation-dashboard data is ingested at state level. These three field values will be dummy and can be same across. The Dashboard queries does not use ward, ulb or region in Landing Page Metrics