Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Telemetry Rules

sushilraje edited this page Jan 23, 2019 · 1 revision

Get list of rules

  • Visibility: public
  • Authentication: requires Viewer|Admin

Request:

GET /v1/rules?order={order}&skip={count}&limit={count}&groupId={groupId}

Query parameters:

Name Type Example Description
order string desc Whether to sort the result from the oldest (asc) or the most recent (desc)
skip int 0 How many records to skip, used to paginate through the global list of rules
limit int 50 How many records to return, used to paginate through the global list of rules
groupId string elevators groupId for a specific group of devices the rule applies to

Response:

200 OK
Content-Type: application/json; charset=utf-8
{
    "Items": [
        {
            "Id": "f55e5a88-420c-4f07-8393-4bed95a489b4",
            "Name": "Engine Temperature",
            "DateCreated": "2018-04-29T22:26:32+00:00",
            "DateModified": "2018-04-29T22:26:32+00:00",
            "Enabled": true,
            "Description": "",
            "GroupId": "Engine",
            "Severity": "Warning",
            "Calculation": "Average",
            "TimePeriod": "60000",
            "Conditions": [
                {
                    "Field": "temperature",
                    "Operator": "GreaterThan",
                    "Value": "120"
                }
            ],
            "ETag": "\"00004200-0000-0000-0000-5ae646980000\"",
            "$metadata": {
                "$type": "Rule;v1",
                "$uri": "/v1/rules/f55e5a88-420c-4f07-8393-4bed95a489b4"
            }
        },
        {
            "Id": "f9888141-4668-491d-992d-a4078d1bb0a0",
            "Name": "Elevator vibration",
            "DateCreated": "2018-04-30T00:42:51+00:00",
            "DateModified": "2018-04-30T00:42:51+00:00",
            "Enabled": true,
            "Description": "",
            "GroupId": "elevator",
            "Severity": "Warning",
            "Calculation": "Instant",
            "TimePeriod": "0",
            "Conditions": [
                {
                    "Field": "vibration",
                    "Operator": "GreaterThan",
                    "Value": "120"
                }
            ],
            "ETag": "\"00004c00-0000-0000-0000-5ae6668c0000\"",
            "$metadata": {
                "$type": "Rule;v1",
                "$uri": "/v1/rules/f9888141-4668-491d-992d-a4078d1bb0a0"
            }
        }
    ],
    "$metadata": {
        "$type": "RuleList;v1",
        "$uri": "/v1/rules"
    }
}

Get single rule by id

  • Visibility: public
  • Authentication: requires Viewer|Admin

Request:

GET /v1/rules/{id}

Response:

200 OK
Content-Type: application/json; charset=utf-8
{
    "Id": "27cabdce-9898-44f8-983b-435116ec3adc",
    "Name": "All deviecs check",
    "DateCreated": "2018-05-01T20:29:32+00:00",
    "DateModified": "2018-05-01T20:29:32+00:00",
    "Enabled": true,
    "Description": "",
    "GroupId": "default_AllDevices",
    "Severity": "Warning",
    "Calculation": "Average",
    "TimePeriod": "300000",
    "Conditions": [
        {
            "Field": "temperature",
            "Operator": "Equals",
            "Value": "120"
        }
    ],
    "ETag": "\"00000700-0000-0000-0000-5ae8ce2d0000\"",
    "$metadata": {
        "$type": "Rule;v1",
        "$uri": "/v1/rules/27cabdce-9898-44f8-983b-435116ec3adc"
    }
}```

Create Rule
=================

* Visibility: public
* Authentication: requires Admin

Request:

POST /v1/rules/

Request Body:
```json
{
	"Name":"chiller temperature",
	"Description":"chiller temperature too low",
	"GroupId":"chiller",
	"Severity":"warning",
	"Enabled":true,
	"Calculation":"average",
	"TimePeriod":"300000",
	"Conditions":[
		{
			"Field":"temperature",
			"Operator":"lessthan",
			"Value":"120"
			
		}]
}

Required Request Body parameters:

Name Type Example Description
Id string 293712 unique id
Name string temp-too-high Display name for the rule
Enabled bool false (Optional) Enable the rule on creation, default is true
Description string Temperature is above 90 Deg F A description of the rule being set
GroupId string building 5 elevators the groupId for the devices the rule applies to
Severity String critical [critical, warning, info]
Calculation String instant [instant,average]
TimePeriod String 60000 [60000, 300000, 600000] represented in milliseconds
Field string temp Field to be monitored
Operator string GreaterThan [GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, Equals]
Value string 20 Specifies the value that triggers the alert.

Response:

200 OK
Content-Type: application/json; charset=utf-8
{
	"Id": "86d93a31-7af2-4259-9718-19116e694f3e",
        "Name":"chiller temperature",
        "DateCreated": "2017-08-08T11:29:03.604-07:00",
        "DateModified": "2017-08-08T11:29:03.604-07:00",
	"Description":"chiller temperature too low",
	"GroupId":"chiller",
	"Severity":"warning",
	"Enabled":true,
	"Calculation":"average",
	"TimePeriod":"300000",
	"Conditions":[
		{
			"Field":"temperature",
			"Operator":"lessthan",
			"Value":"120"
			
		}],
         "$metadata": {
        "$type": "Rule;v1",
        "$uri": "/v1/rules/86d93a31-7af2-4259-9718-19116e694f3e"
    },
    "ETag": "\"b6008780-0000-0000-0000-598a02ee0000\""
}

Create rules from template

Request: Header: content-type = application/json

POST /v1/rules/?template=<template_name>

The project comes with a template called "default" in the config folder as default.json.

You can specify any template you would like, but it must be created in the config folder as <template_name>.json and follow the following format:

{
    "Rules": [
    {
      "Id": "default_Chiller_Pressure_High",
      "Name": "Chiller pressure too high",
      "Enabled": true,
      "Description": "Pressure > 250",
      "GroupId": "default_Chillers",
      "Severity": "Critical",
      "Calculation": "Instant",
      "TimePeriod": "0",
      "Conditions": [
        {
          "Field": "pressure",
          "Operator": "GreaterThan",
          "Value": "298"
        }
      ]
    },
    {
      "Id": "default_Prototyping_Temperature_High",
      "Name": "Prototyping device temp too high",
      "Enabled": true,
      "Description": "Temperature > 80 degrees",
      "GroupId": "default_PrototypingDevices",
      "Severity": "Critical",
      "Calculation": "Average",
      "TimePeriod": "60000",
      "Conditions": [
        {
          "Field": "temperature",
          "Operator": "GreaterThan",
          "Value": "80"
        }
      ]
    }
  ]
}

Modify Rule

  • Visibility: public
  • Authentication: requires Admin

Request:

PUT /v1/rules/{id}

To update an existing rule, modify the desired fields and include the updated rule in the body. If the ETags don't match the service will return 404 Not Found will an empty body.

Request Body:

{
        "Id": "86d93a31-7af2-4259-9718-19116e694f3e",
	"Name":"chiller temperature",
	"Description":"chiller temperature too low",
	"GroupId":"chiller",
	"Severity":"warning",
	"Enabled":true,
	"Calculation":"average",
	"TimePeriod":"300000",
	"Conditions":[
		{
			"Field":"temperature",
			"Operator":"lessthan",
			"Value":"120"
			
		}]
        "$metadata": {
        "$type": "Rule;v1",
        "$uri": "/v1/rules/86d93a31-7af2-4259-9718-19116e694f3e"
    },
    "ETag": "\"b6008780-0000-0000-0000-598a02ee0000\""
}

Response:

200 OK
Content-Type: application/json; charset=utf-8

404 NOT FOUND

```json
{
	"Id": "86d93a31-7af2-4259-9718-19116e694f3e",
        "Name":"chiller temperature",
        "DateCreated": "2017-08-08T11:29:03.604-07:00",
        "DateModified": "2017-08-08T11:29:03.604-07:00",
	"Description":"chiller temperature too low",
	"GroupId":"chiller",
	"Severity":"warning",
	"Enabled":true,
	"Calculation":"average",
	"TimePeriod":"300000",
	"Conditions":[
		{
			"Field":"temperature",
			"Operator":"lessthan",
			"Value":"120"
			
		}],
         "$metadata": {
        "$type": "Rule;v1",
        "$uri": "/v1/rules/86d93a31-7af2-4259-9718-19116e694f3e"
    },
    "ETag": "\"b6008780-0000-0000-0000-598a02ee0000\""
}

Enable/Disable Rule

To enable or disable a rule, make a PUT request with the rule object to alter and change only the "enabled" field. (see 'modify rule' above)

Delete Rule

  • Visibility: public
  • Authentication: requires Admin

Request:

DELETE /v1/rules/{id}

Response:

200 OK
Content-Type: application/json; charset=utf-8