check if alertmanager being configured is cortex or vanilla (#34726) (#34813)

(cherry picked from commit 5660bb585f)

Co-authored-by: Domas <domasx2@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2021-05-27 13:11:40 +02:00
committed by GitHub
co-authored by Domas
parent c0d87c9779
commit f37d9bf13a
2 changed files with 12 additions and 2 deletions
@@ -1,5 +1,5 @@
import { DataSourcePluginOptionsEditorProps } from '@grafana/data';
import { DataSourceHttpSettings } from '@grafana/ui';
import { Alert, DataSourceHttpSettings } from '@grafana/ui';
import React from 'react';
export type Props = DataSourcePluginOptionsEditorProps;
@@ -7,6 +7,9 @@ export type Props = DataSourcePluginOptionsEditorProps;
export const ConfigEditor: React.FC<Props> = ({ options, onOptionsChange }) => {
return (
<>
<Alert severity="info" title="Only Cortex alertmanager is supported">
Note that only Cortex implementation of alert manager is supported at this time.
</Alert>
<DataSourceHttpSettings
defaultUrl={''}
dataSourceConfig={options}
@@ -44,12 +44,19 @@ export class AlertManagerDatasource extends DataSourceApi<AlertManagerQuery> {
try {
alertmanagerResponse = await this._request('/api/v2/status');
if (alertmanagerResponse && alertmanagerResponse?.status === 200) {
return {
status: 'error',
message:
'Only Cortex alert manager implementation is supported. A URL to cortex instance should be provided.',
};
}
} catch (e) {}
try {
cortexAlertmanagerResponse = await this._request('/alertmanager/api/v2/status');
} catch (e) {}
return alertmanagerResponse?.status === 200 || cortexAlertmanagerResponse?.status === 200
return cortexAlertmanagerResponse?.status === 200
? {
status: 'success',
message: 'Health check passed.',