Common Data Manager for (parking, traffic, noise) atomic services
246
Module responsible for extracting data from the underlying external IoT infrastructures (Orion CBs and historical APIs) and forwarding the information to the Data Storage Cluster.
| Method | Path | Description | Params (URL) | Output |
|---|---|---|---|---|
GET | /api | Information (NGSIv2) of all the parking areas | [Optional] page [Optional] items_per_page [Optional] type | Array of OnStreetParking/OffStreetParking context elements |
GET | /api/<id> | Information of a particular parking area (<id>) | id | Single OnStreetParking/OffStreetParking context element |
GET | /api/subscriptions | Subscriptions information | - | Array of Subscription(s) info |
This module is thought to be deployed as a companion service of a more global approach (e.g. via docker-compose.yml file). Together with this, two different configuration files must be tweaked: auth.js.sample and config.js.sample. For the sake of not sharing private information (e.g. endpoints, passwords, etc.) we do not share actual configuration files (e.g. config.js). Instead, we basically copy the same content onto a sample file (e.g. config.js.sample) and comment and explain every field that is tweakable. To carry out a real deployment of the component, users must rename the sample files (basically, erase the .sample suffix) and complete the real configuration.
| Variable | Value | Description |
|---|---|---|
LISTENING_PORT | 6000 | Service listening port (inside Docker container) |
BASE_PATH | api | Path to call service's method (i.e. resource discovery) # Example: http://myipaddress:6000/BASE_PATH |
SUBSCRIBE_TO_EVENTS | true | Enable/disable subscription to data streams |
SUBSCRIPTIONS_ENDPOINT | <endpoint> (to be changed) | Endpoint to send the data from the subscriptions. NOTE: a suffix "/notify" will be internally appended to match the method Example: http://myipaddress:6000 (being 6000 the actual listening port) |
HISTORICAL_DUMP | true | Enable/disable historical data dump at booting the service |
ELASTIC_SEARCH_HOST | <endpoint> (to be changed) | Elasticsearch location (one of the nodes) Example: http://myipaddress:9200 |
LOG_LEVEL | debug | Logging level Appropriate values are (decreasing importance order): [emerg, alert, crit, error, notice, perf, info, debug] |
The file auth.js.sample shows how this file should look like:
{
data_sources: {
Santander: {
key: "header",
token: "token"
}
}
{
/**
* Data Manager API configuration
*/
api: {
/**
* Server listening port (to configure Express)
*/
port: 3000,
/**
* Root path of the API
* EXAMPLE: http://<api_host>/<root_path>
*/
root_path: 'parkingareas',
},
/**
* Underlying data sources. Information about the underlying IoT Infrastructures where the Data Manager will
* harvest the information from. Supported framworks:
* - FIWARE and Synchronicity
* - Data context brokers: Orion CB (NGSI-v2) - 'ngsiv2'
* - Historical APIs: Synchronicity (~ STH Commet) - 'synchronicity'
*
* NOTE: The compatibility list will grow as long as we gather new opportunities and partnerships
*/
data_sources: [
/**
* Official name of the data source.
*/
{
/**
* ID pattern (i.e. substring) used for the device identification. This will be used when it comes
* to trigger historical data queries. To point to the corresponding historical API endpoint,
* we need to link between ID and endpoint, so we must have a connector.
*
* EXAMPLE: Synchronicity's naming system (in this case, 'santander' will work)
* urn Context entity Site Service Group EntityName
* urn:entity:santander:traffic:TrafficFlowObserved:1001
*/
data_source_auth_id: 'Santander',
/**
*Label through we the data source can be detected (e.g. subscription-manager)
*/
data_source_label: 'Santander-parking',
/**
* Type of data context broker endpoint: Current list of types
* - ngsiv2 --> Orion Context Broker (NGSI-v2 interface)
* ToDo:
* - scorpio --> Scorpio Context Broker (NGSI-LD)
*/
data_type: 'ngsiv2',
/**
* Data Context Broker endpoint
*/
data_endpoint: '<endpoint>',
/**
* Enable/disable subscriptions
*/
subscriptions_enabled: true,
/**
* Enable/disable the delivery of all historic values from all assets to the AI prediction module
* The dump will be sliced in chunks of "batch_size" observations
*/
historical_dump_enabled: true,
/**
* Type of historical data API: Current list of types
* - synchronicity --> Synchronicity (~ STH Commet)
* ToDo:
* - csv --> Dump from a CSV file
*/
historical_api_type: 'synchronicity',
/**
* Historical data API endpoint
*/
historical_api_endpoint: '<endpoint>',
/**
* OAUth2 enabled/disabled
* NOTE: if this value is set to true, the file 'config/auth.js' will be checked in order to set the proper
* headers in the HTTP messages (the search will address the name of the data source)
*/
auth: true,
/**
* (Optional) Data entity types to discover. During the discovery process, we can target a subset of entity
* types in the search query
*/
entity_types: [
'<type_1>',
'<type_2>'
],
/**
* (Optional) Attributes that will be dumped to the persistence system
*
* NOTE: If nothing (empty array or commented variable), the data manager will
* proceed to dump everything to the persistence system
*/
historic_attrs: [{
name: '<hist_attr_1>',
type: 'string/integer/float/double'
},
{
name: '<hist_attr_2>',
type: 'string/integer/float/double'
},
],
/**
* List of attributes that will be saved (if the data aggregation parameters - see below
* are not enabled)
*/
saved_attributes: [{
name: '<saved_attr_1>',
type: 'string/integer/float/double'
},
{
name: '<saved_attr_2>',
type: 'string/integer/float/double'
},
],
/**
* Index of the entities information
*/
elastic_entities_index: 'entities-parking',
/**
* Index of the data
*/
elastic_data_index: 'data-parking',
/**
* Raw dataset transformation before forwarding to the persistence system.
* This is invoked from two different points:
* 1- Historical data query
* 2- Event notification
*
* NOTE: If this field is enabled, the 'saved_attributes' parameter will be overriden
*/
data_aggregation: {
/**
* Flag to enable/disable the aggregation function
*/
enabled: false,
/**
* [Advanced] Callback to the function that will be called to aggregate the data (notification events/historical
* methods)
*/
aggregation_function: callback_function_1
},
/**
* IoT infrastructure specific params.
* Current options:
* - [FIWARE] fiware_service --> Comment/Uncomment in case of need (tenant)
* - [FIWARE] fiware_servicepath --> Comment/Uncomment in case of need (hierarchical scope - NOTE:
* must begin with a slash '/' character)
*/
infrastructure_specific: {
// fiware_service: '',
// fiware_servicepath: ''
}
},
// {
// More data sources (if necessary)
// }
// ...
],
/**
* If data source subscriptions are enabled (see data_source.subscriptions_enabled flag), we must specify the
* an endpoint from which the Data Manager will be listening to forthcoming events
*/
subscriptions: {
/**
* Sink to send the asynchronous publications (from data sources)
*
* NOTE: By default (i.e. set in the code), in 'ngsiv2' mode, we set the endpoint as <endpoint>/notify as the
* notificiation URL in the Subscribe to context request sent to Orion
*/
endpoint: '<subscription_endpoint>',
},
/**
* Parameters related with the historical data dump
* At booting time, if the data source has the historical data dump enabled (see
* data_source.historical_dump_enabled flag), the Data Manager will proceed to harvest
* and dump all the devices' history
*/
history: {
/**
* Number of observations that will be sent in a single batch (the operation will be repeated till
* the query to the historical API returns an empty resultset)
*/
batch_size: 10000,
},
/**
* Datastore and search engine for the context element information and historical data
*
* NOTE: The use of Elastic clusters may force us to revamp this configuration
*/
elasticsearch: {
/**
* Elasticsearch endpoint
*
* EXAMPLE: 'http://127.0.0.1:9200'
*/
endpoint: '<elasticsearch_endpoint>',
},
/**
* Data Manager Logging handler
*/
logging: {
/**
* Configures the log level. Appropriate values are:
* levels: {
* emerg: 0,
* alert: 1,
* crit: 2,
* error: 3,
* warning: 4,
* notice: 5,
* perf: 6,
* info: 7,
* debug: 8
* },
*/
logLevel: 'debug',
/**
* Name of the module to be include in the different log files
* (they will start by the %DATE% - see utils/log.js for more info)
*/
moduleName: 'DATA-MANAGER',
}
};
/**
* (Advanced) Functions that will be responsible for shaping the output data, that is, the datasets that will feed the
* persistence system
*/
function callback_function_1() {
//Aggregation function code goes here
};
To run the service, it is only needed to run the following Docker command:
docker run -p HOST_PORT:6000 -v "$(pwd)/config":/usr/src/app/config synchronicityiot/estimator-data-manager
Where <host-port> is the listening port at the host (default 6000). Besides, as hinted above, users must include all configuration files (config.js and auth.js) within the config folder. This is the part set after the -v option, where users have to specify the path to the auth.js file in their host machines. NOTE: Besides, environment variables are deemed necessary too.
The support for this baseline services can be request via the issue tracker here.
This baseline service is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Please refer to GNU licenses for more information.
The software is released as it is and we discharge any liability.
Content type
Image
Digest
Size
167.1 MB
Last updated
over 6 years ago
docker pull synchronicityiot/estimator-data-manager:2.1