Remove unused fetchAlerts method

This commit is contained in:
Tom Ratcliffe
2024-04-29 14:15:48 +01:00
committed by Tom Ratcliffe
parent f397830098
commit cdfc6baea4
@@ -1,15 +1,13 @@
import { lastValueFrom } from 'rxjs';
import { isObject, urlUtil } from '@grafana/data';
import { isObject } from '@grafana/data';
import { getBackendSrv, isFetchError } from '@grafana/runtime';
import {
AlertmanagerAlert,
AlertManagerCortexConfig,
AlertmanagerGroup,
AlertmanagerStatus,
ExternalAlertmanagerConfig,
ExternalAlertmanagersResponse,
Matcher,
Receiver,
TestReceiversAlert,
TestReceiversPayload,
@@ -77,37 +75,6 @@ export async function deleteAlertManagerConfig(alertManagerSourceName: string):
);
}
export async function fetchAlerts(
alertmanagerSourceName: string,
matchers?: Matcher[],
silenced = true,
active = true,
inhibited = true
): Promise<AlertmanagerAlert[]> {
const filters =
urlUtil.toUrlParams({ silenced, active, inhibited }) +
matchers
?.map(
(matcher) =>
`filter=${encodeURIComponent(
`${escapeQuotes(matcher.name)}=${matcher.isRegex ? '~' : ''}"${escapeQuotes(matcher.value)}"`
)}`
)
.join('&') || '';
const result = await lastValueFrom(
getBackendSrv().fetch<AlertmanagerAlert[]>({
url:
`/api/alertmanager/${getDatasourceAPIUid(alertmanagerSourceName)}/api/v2/alerts` +
(filters ? '?' + filters : ''),
showErrorAlert: false,
showSuccessAlert: false,
})
);
return result.data;
}
export async function fetchAlertGroups(alertmanagerSourceName: string): Promise<AlertmanagerGroup[]> {
const result = await lastValueFrom(
getBackendSrv().fetch<AlertmanagerGroup[]>({
@@ -234,7 +201,3 @@ export async function fetchExternalAlertmanagerConfig(): Promise<ExternalAlertma
return result.data;
}
function escapeQuotes(value: string): string {
return value.replace(/"/g, '\\"');
}