Skip to content

Event Analytics Client for Node.js

Introduction

The Event Analytics Service is used for analyzing event data. The service identifies significant dependencies and helps to get a better understanding of the system's internal processes using statistical analysis. Refer to Event Analytics for more information about the service.

Event Operations services

The event operations client analyzes event data statistically to identify the most frequent events.

Client name: EventOperationsClient

Find Top Events

This method finds the N most frequently occurring events and returns them sorted by the number of occurrences in descending order.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Require AppCredentials and ClientConfig from mindsphere-sdk-node-core module
let AppCredentials = require('mindsphere-sdk-node-core').AppCredentials;
let ClientConfig = require('mindsphere-sdk-node-core').ClientConfig;

// Require EventOperationsClient from eventanalytics-sdk module
const EventOperationsClient = require('eventanalytics-sdk').EventOperationsClient;

// Construct the ClientConfig and AppCredentials objects
let config = new ClientConfig();
let credentials = new AppCredentials();

// Construct the EventOperationsClient object
let event_operations_client = new EventOperationsClient(config, credentials);

let events_data = {
  "numberOfTopPositionsRequired": 5,
  "eventsMetadata": {
    "eventTextPropertyName": "text"
  },
  "events": [
    {
      "_time": "2017-10-01T12:00:00.001Z",
      "text": "INTRODUCING FUEL",
      "text_qc": 0
    },
    {
      "_time": "2017-10-01T12:00:01.001Z",
      "text": "Status@Flame On",
      "text_qc": 0
    },
    {
      "_time": "2017-10-01T12:00:02.001Z",
      "text": "Status@Flame On",
      "text_qc": 0
    }
  ]
};

try {
  let response = await event_operations_client.topEvents({ data : events_data });
} catch (ex) {
    // Exception handling
}

Filter Events

This method applies user defined filters to simplify the dataset based on the event text.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Construct the EventOperationsClient object as shown above

let events_data = {
  "eventsMetadata": {
    "eventTextPropertyName": "text"
  },
  "events": [
    {
      "_time": "2017-10-01T12:00:00.001Z",
      "text": "INTRODUCING FUEL",
      "text_qc": 0
    },
    {
      "_time": "2017-10-01T12:00:01.001Z",
      "text": "Status@Flame On",
      "text_qc": 0
    },
    {
      "_time": "2017-10-01T12:00:02.001Z",
      "text": "Status@Flame Off",
      "text_qc": 0
    },
    {
      "_time": "2017-10-01T12:00:03.001Z",
      "text": "Error code: 340",
      "text_qc": 0
    }
  ],
  "filterList": [
    "INTRODUCING FUEL",
    "MEANINGLESS ALARM",
    "Status@Flame On"
  ]
};

try {
  let response = await event_operations_client.filterEvents({ data : events_data });
} catch (ex) {
    // Exception handling
}

Count Events

Determines the number of events per time interval for a user defined interval length.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Construct the EventOperationsClient object as shown above

let events_data = {
  "eventsMetadata": {
    "eventTextPropertyName": "text",
    "splitInterval": 5000
  },
  "events": [
    {
      "_time": "2017-10-01T12:00:06.001Z",
      "text": "INTRODUCING FUEL",
      "text_qc": 0
    },
    {
      "_time": "2017-10-01T12:00:08.001Z",
      "text": "Status@Flame On",
      "text_qc": 0
    },
    {
      "_time": "2017-10-01T12:00:09.001Z",
      "text": "Status@Flame Off",
      "text_qc": 0
    }
  ]
};

try {
  let response = await event_operations_client.countEvents({ data : events_data });
} catch (ex) {
    // Exception handling
}

Remove Duplicate Events

This method removes duplicate events. It detects duplicate events within sliding window of user defined width (example 5,000 ms) and reduces the data set by aggregating duplicate events.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Construct the EventOperationsClient object as shown above

let events_data = {
  "eventsMetadata": {
    "eventTextPropertyName": "text",
    "splitInterval": 5000
  },
  "events": [
    {
      "_time": "2017-10-01T12:00:00.001Z",
      "text": "INTRODUCING FUEL",
      "text_qc": 0
    },
    {
      "_time": "2017-10-01T12:00:01.001Z",
      "text": "Status@Flame On",
      "text_qc": 0
    },
    {
      "_time": "2017-10-01T12:00:02.001Z",
      "text": "Status@Flame Off",
      "text_qc": 0
    }
  ]
}

try {
  let response = await event_operations_client.removeDuplicateEvents({ data : events_data });
} catch (ex) {
    // Exception handling
}

Pattern Operations Services

The Pattern Operations client analyzes the event data statistically to detect event patterns.

Client name: PatternOperationsClient

Find Event Patterns

Searches for user defined patterns in a list of events and detects all events matching the specified pattern(s).

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Require AppCredentials and ClientConfig from mindsphere-sdk-node-core module
let AppCredentials = require('mindsphere-sdk-node-core').AppCredentials;
let ClientConfig = require('mindsphere-sdk-node-core').ClientConfig;

// Require PatternOperationsClient from eventanalytics-sdk module
const PatternOperationsClient = require('eventanalytics-sdk').PatternOperationsClient;


// Construct the ClientConfig and AppCredentials objects
let config = new ClientConfig();
let credentials = new AppCredentials();

// Construct the PatternOperationsClient object
let pattern_operations_client = new PatternOperationsClient(config, credentials);

let event_pattern_input = {
  "maxPatternInterval": 200000,
  "patternsList": [
    {
      "pattern": [
        {
          "eventText": "INTRODUCING FUEL",
          "minRepetitions": 1,
          "maxRepetitions": 2
        },
        {
          "eventText": "Status@Flame On",
          "minRepetitions": 0,
          "maxRepetitions": 1
        }
      ]
    },
    {
      "pattern": [
        {
          "eventText": "Downloading the module database causes module .. restart",
          "minRepetitions": 1,
          "maxRepetitions": 1
        },
        {
          "eventText": "The SIMATIC mode was selected for time-of-day synchronization of the module with Id: ..",
          "minRepetitions": 1,
          "maxRepetitions": 1
        }
      ]
    }
  ],
  "nonEvents": [
    "Error 2.. occurred",
    "STOPPING ENGINE"
  ],
  "eventsInput": {
    "eventsMetadata": {
      "eventTextPropertyName": "text"
    },
    "events": [
      {
        "_time": "2017-10-01T12:00:00.001Z",
        "text": "Downloading the module database causes module 11 restart",
        "text_qc": 0
      },
      {
        "_time": "2017-10-01T12:00:01.001Z",
        "text": "The direction for forwarding the time of day is recognized automatically by the module",
        "text_qc": 0
      }
    ]
  }
};

try {
  let response = await pattern_operations_client.matchPatternsOverEvents({ data : event_pattern_input });
} catch (ex) {
    // Exception handling
}

Any questions left?

Ask the community


Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.