Skip to content

Commit b4bec7e

Browse files
[Response Ops][Alerting] Grouping ad hoc run metrics under alerting metrics (#233875)
Towards elastic/response-ops-team#297 ## Summary Updates the grouping for task manager per task type metrics to categorize `ad_hoc_run-backfill` task types under the `alerting` grouping. ## To Verify 1. Start ES and Kibana 2. Create a detection rule 3. Manually schedule a backfill for the detection rule 4. Navigate to the task manager metrics endpoint(https://localhost:5601/api/task_manager/metrics?reset=false) and verify that the success counter for `alerting` (under `metrics.task_run.value.by_type.alerting`) is incremented, as well as the success counter for `ad_hoc_run-backfill` (under `metrics.task_run.value.by_type.ad_hoc_run-backfill`). (The counters reset every 30 seconds so you will have to look at this endpoint quickly after scheduling the backfill). Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent ac6082d commit b4bec7e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

x-pack/platform/plugins/shared/task_manager/server/metrics/lib/get_task_type_group.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ describe('getTaskTypeGroup', () => {
1313
expect(getTaskTypeGroup('actions:def')).toEqual('actions');
1414
});
1515

16+
test('should correctly group ad hoc runs under alerting', () => {
17+
expect(getTaskTypeGroup('ad_hoc_run-backfill')).toEqual('alerting');
18+
});
19+
1620
test('should return undefined if no match', () => {
1721
expect(getTaskTypeGroup('alerting-abc')).toBeUndefined();
1822
expect(getTaskTypeGroup('fooalertingbar')).toBeUndefined();

x-pack/platform/plugins/shared/task_manager/server/metrics/lib/get_task_type_group.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@
55
* 2.0.
66
*/
77

8-
const taskTypeGrouping = new Set<string>(['alerting:', 'actions:']);
8+
const ALERT_GROUP = 'alerting';
9+
const ACTIONS_GROUP = 'actions';
10+
const taskTypeGrouping = new Set<string>([`${ALERT_GROUP}:`, `${ACTIONS_GROUP}:`]);
911

1012
export function getTaskTypeGroup(taskType: string): string | undefined {
13+
// we want to group ad hoc runs under alerting
14+
if (taskType === 'ad_hoc_run-backfill') {
15+
return ALERT_GROUP;
16+
}
17+
1118
for (const group of taskTypeGrouping) {
1219
if (taskType.startsWith(group)) {
1320
return group.replace(':', '');

0 commit comments

Comments
 (0)