mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Prevent showing "Permissions denied" alert when not accurate (#74887)
* Change way of obtaining external datasources info * Remove unneeded import * Create function to getExternalDsAlertManagers in datasource srv * Remove unused import
This commit is contained in:
parent
44bf663942
commit
db2295bea2
@ -1,7 +1,6 @@
|
|||||||
import { AlertmanagerChoice } from '../../../../../../plugins/datasource/alertmanager/types';
|
import { AlertmanagerChoice } from '../../../../../../plugins/datasource/alertmanager/types';
|
||||||
import { alertmanagerApi } from '../../../api/alertmanagerApi';
|
import { alertmanagerApi } from '../../../api/alertmanagerApi';
|
||||||
import { useExternalDataSourceAlertmanagers } from '../../../hooks/useExternalAmSelector';
|
import { getExternalDsAlertManagers, GRAFANA_RULES_SOURCE_NAME } from '../../../utils/datasource';
|
||||||
import { GRAFANA_RULES_SOURCE_NAME } from '../../../utils/datasource';
|
|
||||||
|
|
||||||
export interface AlertManagerNameWithImage {
|
export interface AlertManagerNameWithImage {
|
||||||
name: string;
|
name: string;
|
||||||
@ -12,10 +11,11 @@ export const useGetAlertManagersSourceNamesAndImage = () => {
|
|||||||
//get current alerting config
|
//get current alerting config
|
||||||
const { currentData: amConfigStatus } = alertmanagerApi.useGetAlertmanagerChoiceStatusQuery(undefined);
|
const { currentData: amConfigStatus } = alertmanagerApi.useGetAlertmanagerChoiceStatusQuery(undefined);
|
||||||
|
|
||||||
const externalDsAlertManagers: AlertManagerNameWithImage[] = useExternalDataSourceAlertmanagers().map((ds) => ({
|
const externalDsAlertManagers = getExternalDsAlertManagers().map((ds) => ({
|
||||||
name: ds.dataSource.name,
|
name: ds.name,
|
||||||
img: ds.dataSource.meta.info.logos.small,
|
img: ds.meta.info.logos.small,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const alertmanagerChoice = amConfigStatus?.alertmanagersChoice;
|
const alertmanagerChoice = amConfigStatus?.alertmanagersChoice;
|
||||||
const alertManagerSourceNamesWithImage: AlertManagerNameWithImage[] =
|
const alertManagerSourceNamesWithImage: AlertManagerNameWithImage[] =
|
||||||
alertmanagerChoice === AlertmanagerChoice.Internal
|
alertmanagerChoice === AlertmanagerChoice.Internal
|
||||||
|
@ -47,6 +47,10 @@ export function getAlertManagerDataSources() {
|
|||||||
.sort((a, b) => a.name.localeCompare(b.name));
|
.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getExternalDsAlertManagers() {
|
||||||
|
return getAlertManagerDataSources().filter((ds) => ds.jsonData.handleGrafanaManagedAlerts);
|
||||||
|
}
|
||||||
|
|
||||||
const grafanaAlertManagerDataSource: AlertManagerDataSource = {
|
const grafanaAlertManagerDataSource: AlertManagerDataSource = {
|
||||||
name: GRAFANA_RULES_SOURCE_NAME,
|
name: GRAFANA_RULES_SOURCE_NAME,
|
||||||
imgUrl: 'public/img/grafana_icon.svg',
|
imgUrl: 'public/img/grafana_icon.svg',
|
||||||
|
Loading…
Reference in New Issue
Block a user