* Rename alerts plugin to alerting * Deprecate old config values * Few more renames * Update plugin list * Rename xpack.alerts -> xpack.alerting * Fix some ESLint rules * Fix typecheck * Fix some test failures * Some more renames * Fix ESLint * Fix some test failures * Fix failing jest test * Undo exclusive test * Fix APM deps * Fix docs Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
28 lines
866 B
TypeScript
28 lines
866 B
TypeScript
/*
|
|
* 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 { CoreStart } from 'kibana/public';
|
|
import { Alert } from '../../../alerting/common';
|
|
|
|
const allowedConsumers = ['apm', 'uptime', 'logs', 'infrastructure', 'alerts'];
|
|
|
|
export async function getObservabilityAlerts({ core }: { core: CoreStart }) {
|
|
try {
|
|
const { data = [] }: { data: Alert[] } =
|
|
(await core.http.get('/api/alerts/_find', {
|
|
query: {
|
|
page: 1,
|
|
per_page: 20,
|
|
},
|
|
})) || {};
|
|
|
|
return data.filter(({ consumer }) => allowedConsumers.includes(consumer));
|
|
} catch (e) {
|
|
console.error('Error while fetching alerts', e);
|
|
throw e;
|
|
}
|
|
}
|