Analytics Framework

Introduction

The analytics framework enables application developers to integrate analytic engines into Predix Edge. This includes the ability to lifecycle manage analytic templates and instances running in remote edge devices from Predix Edge Manager.

Application developers need to expose the analytics engine capability (Predix.Edge.AnalyticEngine), which requires implementation of the following content.
  • Commands:
    • startAnalyticsTemplate( templateId )
    • stopAnalyticstemplate( templateId )
    • deleteAnalyticsTemplate( templateId )
    • Deploy
      • Analytic template
      • Analytic datamap (component_descriptor) [optional]
      • Status

Implementing Commands

Refer to Implementing Commands.

The following are sample commands for each of the required AnalyticEngine commands.
Start Analytic
{
            "command": "startAnalyticsTemplate",
            "handler":"Analytics",
            "responseTopic":"edgeAgent/<AppID>/response/<task_id>",
            "params": {
                        "templateId": "1001"                        
            }
}
Stop Analytic
{
            "command": "stopAnalyticsTemplate",
            "handler":"Analytics",
            "responseTopic":"edgeAgent/<AppID>/response/<task_id>",
            "params": {
                        "templateId": "1001"                           
            }
}
Delete Analytic
{
            "command": "deleteAnalyticsTemplate",
            "handler":"Analytics",
            "responseTopic":"edgeAgent/<AppID>/response/<task_id>",
            "params": {
                        "templateId": "1001"                           
            }
}
Deploy Analytic Template

{
            "type": "analytics_template",
            "package": "/shared/downloads/filename",
            "responseTopic":"edgeAgent/<AppID>/response/<task_id>",
            "handler":"foghornML|forhornCEP|CSense",
            "params": {
                  "name": "test-wx-analytics",
                "description": "",
                "id": "13454",
                "version": "1.0.0",
                "parentId": ""
                }
}
Deploy Analytic Data Map
{
            "type": "analytics_data_map",
            "package": "/shared/downloads/filename",
            "responseTopic":"edgeAgent/<AppID>/response/<task_id>",
            "handler":"foghornML|forhornCEP|CSense",
            "params": {
                 "name": "test-wx-analytics-data-map",
                "description": "",
                "id": "13455",
                "version": "1.0.0",
                "parentId": "13454"
            }
}

Sending Status

Refer to Exposing Status Information.

Status for the analytic engine contains:
{
  "component_status_list":
    "status":[
    {
      "id": "{template_id_from_deployment}",
      "state": "EDGE_ANALYTICS_COMPONENT_STATE_UNKNOWN|EDGE_ANALYTICS_COMPONENT_STATE_ACTIVE|EDGE_ANALYTICS_COMPONENT_STATE_INACTIVE",
      "state_message": "<string>"
    },
    //..
  ],
 
  "timestamp": "<timestamp>",
  "attributes": {
    "<string>": {
      "value": "<string>",
      "data_type": "[STRING|BINARY|BOOLEAN|FLOAT|DOUBLE|INT|LONG|TIMESTAMP]"
    },
 
    //…
  }
}

The status message format for the Predix.Edge.AnalyticEngine (1.0.0) capability must follow the schema defined below.

{

	"$schema": "http://json-schema.org/draft-07/schema#",
	"type": "object",
	"required": [
		"component_status_list",
		"timestamp",
		"attributes"
    ],
    "properties": {
            "component_status_list":
            {
                "$ref": "#/definitions/component_status_list"
            },
            "timestamp":
            {
                "$ref": "#/definitions/timestamp"
            },
            "attributes":
            {
                "$ref": "#/definitions/attributes"
            }
    },
    "definitions": {
        "component_status_list": {
			"$id": "#/definitions/component_status_list",
			"type": "object",
			"required": [
				"status"
			],
			"properties": {
				"status": {
                    "type":"array",
                    "items":{
                        "$ref":"#/definitions/status_element"
                    }
                }
			}
        },
        "status_element": {
            "type": "object",
            "required": [
                "id",
                "state",
                "state_message"
            ],
            "properties": {
                "id": {
                    "type": "string",
                    "pattern": "^[0-9]+$"
                },
                "state": {
                    "type": "string",
                    "enum":["EDGE_ANALYTICS_COMPONENT_STATE_ACTIVE", "EDGE_ANALYTICS_COMPONENT_STATE_INACTIVE", "EDGE_ANALYTICS_COMPONENT_STATE_UNKNOWN"]
                },
                "state_message": {
                    "type": "string",
                    "examples": [
                        "Running"
                    ],
                    "pattern": "^.+$"
                }
            }
        },
		"timestamp": {
			"$id": "#/definitions/timestamp",
			"type": "string",
			"examples": [
				"2018-12-11T17:58:53.171Z"
			],
			"pattern": "^.+$"
		},
		"attributes": {
			"$id": "#/definitions/attributes",
			"type": "object",
            "^(.+)/([^/]+)$": {
                "$ref":"#/definitions/attributes_element"
            }
        },
        "attributes_element":{
            "$id": "#/definitions/attributes_element",
            "type":"object",
            "required": [
                "value"
            ],
            "properties": {
                "value": {
                    "type": "string"
                },
                "dataType": {
                    "type": "string",
                    "enum":["DATATYPE_STRING", "DATATYPE_BINARY", "DATATYPE_BOOLEAN","DATATYPE_FLOAT","DATATYPE_DOUBLE", "DATATYPE_INT","DATATYPE_LONG","DATATYPE_TIMESTAMP"]
                }
            }
        }
	}
}

Creating the Application Manifest

The application manifest is a file used to provide metadata to Predix Edge about the application. To enable the analytics framework the application manifest must expose that the application exposes the AnalyticEngine (Predix.Edge.AnalyticEngine) capability.

The sample manifest below includes a sample where the AnalyticEngine capability is exposed. In a production manifest there will also be a files section, which is automatically added by GE when performing application signing and is not the responsibility of the application developer.
{
  "manifest": {
    "capabilities": [
      {
        "name": "Predix.Edge.AnalyticEngine",
        "version": "1.0.0"
      },
      ...
    ],
  }
}