-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ResponseOps] Add telemetry for the es query rule types (#176451)
Resolves #176237 ## Summary Adds new telemetry fields to track the ES Query rule search types. ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios ### To verify - Create a couple of ES Query rules with the different search types - Create a rule that is not an ES Query rule - Change alerting telemetry task [schedule](https://github.com/doakalexi/kibana/blob/main/x-pack/plugins/alerting/server/usage/task.ts#L28) interval 1 min - Run [Telemetry usage payload API](https://docs.elastic.dev/telemetry/collection/snapshot-telemetry#telemetry-usage-payload-api) in your browser console to verify the new telemetry data under `count_by_type` and `count_active_by_type`
- Loading branch information
Showing
5 changed files
with
178 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
x-pack/plugins/alerting/server/usage/lib/group_rules_by_search_type.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { groupRulesBySearchType } from './group_rules_by_search_type'; | ||
|
||
describe('groupRulesBySearchType', () => { | ||
test('should correctly group search types', () => { | ||
expect( | ||
groupRulesBySearchType({ | ||
esQuery: 1, | ||
searchSource: 2, | ||
esqlQuery: 3, | ||
foo: 5, | ||
}) | ||
).toEqual({ | ||
'__es-query_es_query': 1, | ||
'__es-query_search_source': 2, | ||
'__es-query_esql_query': 3, | ||
}); | ||
}); | ||
|
||
test('should fallback to 0 if any of the expected search types are absent', () => { | ||
expect(groupRulesBySearchType({ unknown: 100, bar: 300 })).toEqual({ | ||
'__es-query_es_query': 0, | ||
'__es-query_search_source': 0, | ||
'__es-query_esql_query': 0, | ||
}); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
x-pack/plugins/alerting/server/usage/lib/group_rules_by_search_type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { AlertingUsage } from '../types'; | ||
|
||
export function groupRulesBySearchType( | ||
rulesBySearchType: Record<string, number> | ||
): AlertingUsage['count_by_type'] { | ||
return { | ||
'__es-query_es_query': rulesBySearchType.esQuery ?? 0, | ||
'__es-query_search_source': rulesBySearchType.searchSource ?? 0, | ||
'__es-query_esql_query': rulesBySearchType.esqlQuery ?? 0, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters