mirror of https://github.com/grafana/grafana
GOps: Add Grafana SLO steps to IRM configuration tracker (#88098)
parent
a9aba2b42f
commit
d7c33db7db
@ -0,0 +1,35 @@ |
||||
import { SupportedPlugin } from '../types/pluginBridges'; |
||||
|
||||
import { alertingApi } from './alertingApi'; |
||||
|
||||
export interface Label { |
||||
key: string; |
||||
value: string; |
||||
} |
||||
|
||||
export interface SloAlertingMetadata { |
||||
annotations?: Label[]; |
||||
labels?: Label[]; |
||||
} |
||||
|
||||
export interface SloAlerting { |
||||
annotations?: Label[]; |
||||
fastBurn?: SloAlertingMetadata; |
||||
labels?: Label[]; |
||||
slowBurn?: SloAlertingMetadata; |
||||
} |
||||
|
||||
export interface Slo { |
||||
alerting?: SloAlerting; |
||||
} |
||||
|
||||
const SLO_API_PATH = `/api/plugins/${SupportedPlugin.Slo}/resources/v1`; |
||||
|
||||
export const sloApi = alertingApi.injectEndpoints({ |
||||
endpoints: (build) => ({ |
||||
getSlos: build.query<{ slos: Slo[] }, void>({ |
||||
query: () => ({ url: `${SLO_API_PATH}/slo`, showErrorAlert: false }), |
||||
providesTags: ['GrafanaSlo'], |
||||
}), |
||||
}), |
||||
}); |
||||
@ -0,0 +1,20 @@ |
||||
import { sloApi } from 'app/features/alerting/unified/api/sloApi'; |
||||
import { usePluginBridge } from 'app/features/alerting/unified/hooks/usePluginBridge'; |
||||
import { SupportedPlugin } from 'app/features/alerting/unified/types/pluginBridges'; |
||||
|
||||
export function useSloChecks() { |
||||
const { installed: sloPluginInstalled } = usePluginBridge(SupportedPlugin.Slo); |
||||
|
||||
const { data, isLoading } = sloApi.endpoints.getSlos.useQuery(undefined, { |
||||
skip: !sloPluginInstalled, |
||||
refetchOnFocus: true, |
||||
refetchOnReconnect: true, |
||||
refetchOnMountOrArgChange: true, |
||||
}); |
||||
|
||||
return { |
||||
isLoading, |
||||
hasSlo: Boolean(data?.slos.length), |
||||
hasSloWithAlert: Boolean(data?.slos?.some((slo) => slo.alerting)), |
||||
}; |
||||
} |
||||
Loading…
Reference in new issue