Skip to content

Event Analytics Client for Java

Introduction

The Event Analytics Java client allows you to analyze event data. It 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.

Hint

Placeholders in the following samples are indicated by angular brackets < >.

Event Operations

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

Client name: EventOperationsClient

Find Top Events

This section shows two options for finding the N most frequently occurring events and returning 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
// Construct the EventOperationsClient object
EventOperationsClient event_operations_client = EventOperationsClient.builder()
                                                  .mindsphereCredentials(<credentials>)
                                                  .restClientConfig(<config>)
                                                  .build();

// Create the EventsInputModelEventsMetadata object
EventsInputModelEventsMetadata events_metadata = new EventsInputModelEventsMetadata();
events_metadata.setEventTextPropertyName("text");

// Create a list of events to be analyzed
Event first_event = new Event();
first_event.setText("INTRODUCING FUEL");
first_event.setTextQc(0);
first_event.setTime("2017-10-01T12:00:00.001Z");

Event second_event = new Event();
second_event.setText("Status@Flame On");
second_event.setTextQc(0);
second_event.setTime("2017-10-01T12:02:01.001Z");

List<Event> events_list = new ArrayList<>();
events_list.add(first_event);
events_list.add(second_event);

// Create the TopEventsInputDataModel object that will be analyzed
TopEventsInputDataModel input_data_model = new TopEventsInputDataModel();
input_data_model.setNumberOfTopPositionsRequired(5);
input_data_model.setEventsMetadata(events_metadata);
input_data_model.setEvents(events_list);

TopEventOutput top_events_response = null;
try {
    top_events_response = event_operations_client.topEvents(input_data_model);
} catch (MindsphereException e) {
    // Exception handling
}

Alternatively, use the TopEventsRequest model.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
// Create the EventOperationsClient object as shown above

TopEventsRequest request_object = new TopEventsRequest();
request_object.setData(<input_data>);

TopEventOutput top_events_response = null;
try {
    top_events_response = event_operations_client.topEvents(request_object);
} catch (MindsphereException e) {
    // Exception handling
}

Filter Events

This section shows two options for simplifying the dataset by applying user defined filters.

 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
// Create the EventOperationsClient object as shown above

// Create the EventsInputModelEventsMetadata object
EventsInputModelEventsMetadata events_metadata = new EventsInputModelEventsMetadata();
events_metadata.setEventTextPropertyName("text");

// Create a list of events to be analyzed
Event first_event = new Event();
first_event.setText("INTRODUCING FUEL");
first_event.setTextQc(0);
first_event.setTime("2017-10-01T12:00:00.001Z");

Event second_event = new Event();
second_event.setText("Status@Flame On");
second_event.setTextQc(0);
second_event.setTime("2017-10-01T12:02:01.001Z");

List<Event> events_list = new ArrayList<>();
events_list.add(first_event);
events_list.add(second_event);

// Create a list of filter criteria
List<String> filter_list = new ArrayList<>();
filter_list.add("Introduction fuel");

// Create the EventSearchInputDataModel object that will be analyzed
EventSearchInputDataModel input_data_model = new EventSearchInputDataModel();
input_data_model.setEvents(events_list);
input_data_model.setEventsMetadata(events_metadata);
input_data_model.setFilterList(filter_list);

EventArrayOutput filter_events_response = null;
try {
    filter_events_response = event_operations_client.filterEvents(input_data_model);
} catch (MindsphereException e) {
    // Exception handling
}

Alternatively, use the FilterEventsRequest model.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
// Create the EventSearchInputDataModel object as shown above
FilterEventsRequest request_object = new FilterEventsRequest();
request_object.setData(input_data_model);

EventArrayOutput filter_events_response = null;
try {
    filter_events_response = event_operations_client.filterEvents(request_object);
} catch (MindsphereException e) {
    // Exception handling
}

Count Events

This section shows two options for determining 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
32
// Create the EventOperationsClient object as shown above
// Create the EventInputEventsMetadata object
EventInputEventsMetadata events_metadata = new EventInputEventsMetadata();
events_metadata.setEventTextPropertyName("text");
events_metadata.setSplitInterval(500);

// Create a list of events to be analyzed
Event first_event = new Event();
first_event.setText("INTRODUCING FUEL");
first_event.setTextQc(0);
first_event.setTime("2017-10-01T12:00:00.001Z");

Event second_event = new Event();
second_event.setText("Status@Flame On");
second_event.setTextQc(0);
second_event.setTime("2017-10-01T12:02:01.001Z");

List<Event> events_list = new ArrayList<>();
events_list.add(first_event);
events_list.add(second_event);

// Create the EventInput object that will be analyzed
EventInput event_input = new EventInput();
event_input.setEvents(events_list);
event_input.setEventsMetadata(events_metadata);

EventCountOutput count_events_response = null;
try {
    count_events_response = event_operations_client.countEvents(event_input);
} catch (MindsphereException e) {
    // Exception handling
}

Alternatively, use the CountEventsRequest model.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
// Create the EventInput object as shown above
CountEventsRequest request_object = new CountEventsRequest();
request_object.setData(event_input);

EventCountOutput count_events_response = null;
try {
    count_events_response = event_operations_client.countEvents(request_object);
} catch (MindsphereException e) {
    // Exception handling
}

Remove Duplicate Events

This section shows two options for removing duplicate events. The methods detect duplicate events within a sliding window of user defined width (example 5,000 ms) and reduce 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
32
33
34
35
36
// Create the EventOperationsClient object as shown above
// Create the EventInputEventsMetadata object
EventInputEventsMetadata events_metadata = new EventInputEventsMetadata();
events_metadata.setEventTextPropertyName("text");
events_metadata.setSplitInterval(500);

// Create a list of events to be analyzed
Event first_event = new Event();
first_event.setText("INTRODUCING FUEL");
first_event.setTextQc(0);
first_event.setTime("2017-10-01T12:00:00.001Z");

Event second_event = new Event();
second_event.setText("Status@Flame On");
second_event.setTextQc(0);
second_event.setTime("2017-10-01T12:02:01.001Z");

List<Event> eventsList = new ArrayList<>();
eventsList.add(first_event);
eventsList.add(second_event);

// Create a list of filter criteria
List<String> filter_list = new ArrayList<>();
filter_list.add("Introduction fuel");

// Create the EventInput object that will be analyzed
EventInput event_input = new EventInput();
event_input.setEvents(eventsList);
event_input.setEventsMetadata(events_metadata);

DuplicateEventArrayOutput remove_duplicate_response = null;
try {
    remove_duplicate_response = event_operations_client.removeDuplicateEvents(event_input);
} catch (MindsphereException e) {
    // Exception handling
}

Alternatively, use the RemoveDuplicateEventsRequest model.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
// Create the EventInput object as shown above
RemoveDuplicateEventsRequest request_object = new RemoveDuplicateEventsRequest();
request_object.setData(event_input);

DuplicateEventArrayOutput remove_duplicate_response = null;
try {
    remove_duplicate_response = event_operations_client.removeDuplicateEvents(request_object);
} catch (MindsphereException e) {
    // Exception handling
}

Pattern Operations

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

Client name: PatternOperationsClient

Find Event Patterns

This section shows two options for searching for user defined patterns in a list of events. The response lists all events which match 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
// Construct the PatternOperationsClient object
PatternOperationsClient pattern_operations_client = PatternOperationsClient.builder()
                                                      .mindsphereCredentials(credentials)
                                                      .restClientConfig(config)
                                                      .build();

// Construct the EventsInputModelEventsMetadata object
EventsInputModelEventsMetadata events_metadata = new EventsInputModelEventsMetadata();
events_metadata.setEventTextPropertyName("text");

// Create a list of events to be analyzed
Event first_event = new Event();
first_event.setText("INTRODUCING FUEL");
first_event.setTextQc(0);
first_event.setTime("2017-10-01T12:00:00.001Z");

Event second_event = new Event();
second_event.setText("Status@Flame On");
second_event.setTextQc(0);
second_event.setTime("2017-10-01T12:02:01.001Z");

List<Event> events_list = new ArrayList<>();
events_list.add(first_event);
events_list.add(second_event);

// Construct the EventsInputModel object
EventsInputModel events_input = new EventsInputModel();
events_input.setEvents(events);
events_input.setEventsMetadata(events_metadata);

// Construct MatchingPattern object
MatchingPattern matching_pattern_1 = new MatchingPattern();
matching_pattern_1.setEventText("INTRODUCING FUEL");
matching_pattern_1.setMaxRepetitions(2);
matching_pattern_1.setMinRepetitions(1);

MatchingPattern matching_pattern_2 = new MatchingPattern();
matching_pattern_2.setEventText("Status@Flame On");
matching_pattern_2.setMaxRepetitions(1);
matching_pattern_2.setMinRepetitions(0);

// Create a list of matching patterns
List<MatchingPattern> pattern = new ArrayList<>();
pattern.add(matching_pattern_1);
pattern.add(matching_pattern_2);

// Construct PatternDefinition object
PatternDefinition pattern_definition = new PatternDefinition();
pattern_definition.setPattern(pattern);

// Create a list of pattern definitions
List<PatternDefinition> pattern_definition_list = new ArrayList<>();
pattern_definition_list.add(pattern_definition);

// Create a list of non event strings
List<String> non_events = new ArrayList<>();
non_events.add("Error 2.. occurred");
non_events.add("STOPPING ENGINE");

// Construct the PatternMatchingInputDataModel object that will be analyzed
PatternMatchingInputDataModel input_data_model = new PatternMatchingInputDataModel();
input_data_model.setEventsInput(events_input);
input_data_model.setNonEvents(non_events);
input_data_model.setPatternsList(pattern_definition_list);
input_data_model.setMaxPatternInterval(200000);

PatternMatchingOutput match_pattern_response = null;
try {
    match_pattern_response = pattern_operations_client.matchPatternsOverEvents(input_data_model);
} catch (MindsphereException e) {
    // Exception handling
}

Alternatively, use the MatchPatternsOverEventsRequest model.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
// Construct the PatternMatchingInputDataModel object as shown above

MatchPatternsOverEventsRequest request_object = new MatchPatternsOverEventsRequest();
request_object.setData(input_data_model);

PatternMatchingOutput match_pattern_response = null;
try {
    match_pattern_response = pattern_operations_client.matchPatternsOverEvents(request_object);
} catch (MindsphereException e) {
    // Exception handling
}

Any questions left?

Ask the community


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