Deploying a custom transformer instance
You can deploy a custom transformer for your device events so that the events can be incorporated into the IBM® Maximo® Worker Insights shield engine. A new transformer instance can be deployed in the same organization and space in which your IBM Maximo Worker Insights service is deployed.
The transformer can be deployed in IBM Maximo Worker Insights or as a Cloud Foundry app in IBM® Cloud:
- Deploying a custom transformer instance in IBM Maximo Worker Insights
- Deploying a custom transformer as a Cloud Foundry app in IBM Cloud
Deploying a custom transformer instance in IBM Maximo Worker Insights
The following steps show how a custom transformer can be implemented with Wally devices as an example. The provider polls the Wally endpoint for updates, queries all data, and checks for new events. If new events are found, the provider publishes them.
Prerequisites
Configuration
By default, the transformer does not filter the source device. If you want the provider to work with known devices only, you need to switch the deviceFilter
on in the configuration file before you continue with the deployment.
After enabled, the filter uses device information that is provided by the IBM Maximo Worker Insights API service to determine which device data to use.
The configuration file is in the app/config
directory of the custom transformer.
By default, the config-dev.js
file is used for the configuration. You can copy config-template.js
to config-dev.js
and edit it to suit your needs. If you want to use another file, set the environment variable
APP_ENV
to the file that you want, for example, config-prod.js
.
If deviceFilter
is toggled, then you need to provide the API configuration information which includes the API URL and access token. The example includes a generic adapter to communicate with a REST API.
Installing the custom transformer
On the command line, enter the following commands:
git clone <repository-url> https://github.com/ibm-watson-iot/ioti-custom-transformer
cd iot4i-custom_transformer
npm install
Deploying the custom transformer
Upload the source code to a server and run the following commands:
npm install
npm start
Running the custom transformer
To run the transformer, enter the following command:
npm start
Deploying a custom transformer as a Cloud Foundry app in IBM Cloud
You can deploy a custom transformer instance as a Cloud Foundry app in IBM Cloud in the same organization and space in which your IBM Maximo Worker Insights is deployed.
Prerequisites
Before you begin, first download and install the Cloud Foundry command line interface. You use the Cloud Foundry command line interface to modify and deploy service instances to IBM Watson™ IoT Platform. For more information, see Working with Cloud Foundry (cf commands).
Configuration
-
In the command line interface, change your directory to the directory with sources and deployment descriptor YML file by using the following command:
$ cd directory_name
-
List all apps in IoT for Insurance and make a note of the name of the transformer. The name ends in
transformer
. -
Stop the IBM Maximo Worker Insights transformer as in the following example:
$ cf stop iot4i-dev-transformer
-
List all services included in IBM Maximo Worker Insights and make a note of the names of the Watson™ IoT Platform and Cloudant® NoSQL DB NoSQL DB services. The name of the Watson™ IoT Platform services includes the letters
iotf
in the name. The name of the Cloudant® NoSQL DB NoSQL DB service includescloudant
in the name. -
Using the names that you noted in the previous steps, create a deployment descriptor file that is similar to the following example.
applications: - path: . memory: 1024M instances: 1 name: iot4i-dev-transformer no-route: false disk_quota: 1024M command: node index.js services: - iot4i-iotf-service - iot4i-cloudantNoSQLDB env: ENV: dev APIDOMAIN: iot4insurance-api-v.mybluemix.net NODE_MODULES_CACHE: false
-
Push your transformer into IBM Cloud by using the following command, replacing newtransformer with the name of your deployment descriptor file:
$ cf push -f newtransformer.yml
-
You can check the logs to view deployment messages by using the following command:
$ cf logs iot4i-dev-transformer