Skip to content

Commit

Permalink
[Alerting] Telemetry fix for min/max number of actions a rule has ass…
Browse files Browse the repository at this point in the history
…ociated with (elastic#115496) (elastic#116032)

* [Alerting] Telemetry for max number of actions a rule has and max alerts created on execution

* -

* Update rules_client.ts

* fixed task data

* added unit test

* fixed by adding runtime field

* fixed task data

* fixed test

* fixed telemetry for throttle and interval

* fixed task data

* fixed task data

* fixed test

* fixed due to comments

* fixed typecheck

* fixed test

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
YulNaumenko and kibanamachine authored Oct 22, 2021
1 parent 028bac1 commit 280c71d
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 229 deletions.
33 changes: 16 additions & 17 deletions x-pack/plugins/alerting/server/usage/alerts_telemetry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Object {
`);
});

test('getTotalCountAggregations should return aggregations for throttle, interval and associated actions', async () => {
test('getTotalCountAggregations should return min/max connectors in use', async () => {
const mockEsClient = elasticsearchClientMock.createClusterClient().asScoped().asInternalUser;
mockEsClient.search.mockReturnValue(
// @ts-expect-error @elastic/elasticsearch Aggregate only allows unknown values
Expand All @@ -65,18 +65,17 @@ Object {
'logs.alert.document.count': 1,
'document.test.': 1,
},
namespaces: {
default: 1,
},
},
},
throttleTime: { value: { min: 0, max: 10, totalCount: 10, totalSum: 20 } },
intervalTime: { value: { min: 0, max: 2, totalCount: 2, totalSum: 5 } },
connectorsAgg: {
connectors: {
value: { min: 0, max: 5, totalActionsCount: 10, totalAlertsCount: 2 },
},
},
max_throttle_time: { value: 60 },
min_throttle_time: { value: 0 },
avg_throttle_time: { value: 30 },
max_interval_time: { value: 10 },
min_interval_time: { value: 1 },
avg_interval_time: { value: 4.5 },
max_actions_count: { value: 4 },
min_actions_count: { value: 0 },
avg_actions_count: { value: 2.5 },
},
hits: {
hits: [],
Expand All @@ -92,7 +91,7 @@ Object {
Object {
"connectors_per_alert": Object {
"avg": 2.5,
"max": 5,
"max": 4,
"min": 0,
},
"count_by_type": Object {
Expand All @@ -103,13 +102,13 @@ Object {
"count_rules_namespaces": 0,
"count_total": 4,
"schedule_time": Object {
"avg": 2.5,
"max": 2,
"min": 0,
"avg": 4.5,
"max": 10,
"min": 1,
},
"throttle_time": Object {
"avg": 2,
"max": 10,
"avg": 30,
"max": 60,
"min": 0,
},
}
Expand Down
Loading

0 comments on commit 280c71d

Please sign in to comment.