Rules structure

Data forming rules provide the user with three types of actions:

Data forming rules work with two data arrays:

  • current, the currently displayed data in the table;

  • new, the newly arrived data.

Structure of rule entry

Each rule consists of conditions under which actions are applied to the data.

The field actions is required and must contain at least one action.

With the absence of the field conditions, the specified actions will be performed each time the server receives data.

The structure of a single rule entry:

[
  {
    "conditions": [...],
    "actions": [...]
  }
]

The structure of several rules entry:

[
  {
    "conditions": [...],
    "actions": [...]
  },
  {
    "conditions": [...],
    "actions": [...]
  },
...
]

Structure of conditions entry

Conditions are recorded with the following structure:

    "conditions": [{
      "_field": {
        "name": "...",
        "value": {...}
      }
    }],

where

  • _field is the headline of the particular condition,

  • name is the metric name from the Data table, which value must be tested.

    It is obligatory to use a pointer together with a name, which allows to determine the tested value:

    • current (assigned to the metric before),

    • new (just received).

  • value is the metric value, which the current value is compared with, and a comparison operator.

The format of the value field:

"Operator": "Value"

The feasible operators:

Operator

Transcript

_eq

Equal to

_neq

Not equal to

_lt

Less than

_lte

Less than or equal to

_gt

Greater than

_gte

Greater than or equal to

_ct

Contains

_nct

Not contains

_m

Matches with

Condition example (if the current value of the metric packetLossPercentile is less than ten):

    "conditions": [
      {
        "_field": {
          "name": "current.packetLossPercentile",
          "value": {
            "_lt": "10"
          }
        }
      }
    ],

It is possible to use a block with several conditions instead of one condition. In this case the actions will be executed only when all of the conditions in the block are triggered.

    "conditions": [
      {
        "_field": {
          "name": "...",
          "value": {...}
        }
      },
      {
        "_field": {
          "name": "...",
          "value": {...}
        }
      }
    ],
 "actions": [...
]

Structure of actions entry

The field actions contains the types of actions and additional fields that are relevant for particular type of action.

The structure of entry of a rule with a single action:

[
  {
    "conditions": [...],
    "actions": [
      {
        "type": "extend"
      }
    ]
  }
]

Rules can be combined. In this case, they are executed in the order of the sequence:

[
  {
    "conditions": [...],
    "actions": [
      {
        "type": "extend"
      },
      {
        "type": "drop"
      }
    ]
  }
]

In the absence of conditions, actions can be combined in two equivalent ways:

[
  {
    "actions": [
      {
        "type": "extend"
      },
      {
        "type": "drop"
      }
    ]
  }
]
[
  {
    "actions": [
      {
        "type": "extend"
      }
    ]
  },
  {
    "actions": [
      {
        "type": "drop"
      }
    ]
  }
]

Actions types

All of the actions with triggered conditions will be executed in order of their recording in the editor. If few actions work with the same metric, the last action will have the priority.

It is recommended to extend the data table with all of the metrics with the first action while using the SET or DROP rules. Otherwise the metrics which are not specified in the rules, will not be updated in the data table:

[
  {
    "actions": [
      {
        "type": "extend"
      }
    ]
  }
...
]

SET - create a new metric or redefine an existing one

This action has two required fields:

  • Field is the name of the metric which the value should be written into (if there is no metric with the specified name, the metric will be added to the Data table);

  • Value is the value which is to be written into the metric.

As value can be used:

  • numeric values, for example, 10;

  • text data, for example, "text";

  • values of other metrics from the data table with the pointers current and new, for example, "{{new.temperature}}";

  • formulas using metrics from the data table with the pointers current and new, for example, "{{current.temperature}} - {{new.temperature}}".

The structure of the SET rule entry:

[
  {
    "actions": [
      {
        "type": "extend"
      }
      {
        "type": "set",
        "field": "metric_name",
        "value": "metric_value"
      }
    ]
  }
]

EXTEND - extension of the table with new metrics

This action complements the data table by new metrics. Metrics that are already present in the data table will not be deleted.

The action EXTEND has two optional mutually exclusive fields:

  • Include, the names of the metrics that must be added to existing ones;

  • Exclude, the names of the metrics that must be ignored when adding.

Example 1. Extension of the data table by all new metrics.

[
  {
    "actions": [
      {
        "type": "extend"
      }
    ]
  }
...
]

Example 2. Extension of the data table only by the specified new metrics.

[
  {
    "actions": [
      {
        "type": "extend",
        "include": ["metric_name_1", "metric_name_2", ...]
      }
    ]
  }
...
]

Example 3. Extension of the data table by all new metrics, except those specified.

[
  {
    "actions": [
      {
        "type": "extend",
        "exclude": ["metric_name_3", "metric_name_4", ...]
      }
    ]
  }
]

DROP - metrics deletion

This action drops metrics from the data table.

The DROP action has 2 optional mutually exclusive fields:

  • Include, the names of the metrics that must be dropped;

  • Exclude, the names of the metrics that must be left. Example 1. Drop all metrics.

[
  {
    "actions": [
      {
        "type": "drop"
      }
    ]
  }
]

Example 2. Drop the specified metrics.

[
  {
    "actions": [
      {
        "type": "extend"
      }
      {
        "type": "drop",
        "include": ["metric_name_1", "metric_name_2", ...]
      }
    ]
  }
]

Example 3. Drop all metrics except those specified.

[
  {
    "actions": [
      {
        "type": "extend"
      }
      {
        "type": "drop",
        "exclude": ["metric_name_3", "metric_name_4", ...]
      }
    ]
  }
]