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

This commit is contained in:
Domas
2021-05-27 13:47:55 +03:00
committed by GitHub
parent 871e476e41
commit 5660bb585f
2 changed files with 12 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
import { DataSourcePluginOptionsEditorProps } from '@grafana/data'; import { DataSourcePluginOptionsEditorProps } from '@grafana/data';
import { DataSourceHttpSettings } from '@grafana/ui'; import { Alert, DataSourceHttpSettings } from '@grafana/ui';
import React from 'react'; import React from 'react';
export type Props = DataSourcePluginOptionsEditorProps; export type Props = DataSourcePluginOptionsEditorProps;
@@ -7,6 +7,9 @@ export type Props = DataSourcePluginOptionsEditorProps;
export const ConfigEditor: React.FC<Props> = ({ options, onOptionsChange }) => { export const ConfigEditor: React.FC<Props> = ({ options, onOptionsChange }) => {
return ( 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 <DataSourceHttpSettings
defaultUrl={''} defaultUrl={''}
dataSourceConfig={options} dataSourceConfig={options}

View File

@@ -44,12 +44,19 @@ export class AlertManagerDatasource extends DataSourceApi<AlertManagerQuery> {
try { try {
alertmanagerResponse = await this._request('/api/v2/status'); 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) {} } catch (e) {}
try { try {
cortexAlertmanagerResponse = await this._request('/alertmanager/api/v2/status'); cortexAlertmanagerResponse = await this._request('/alertmanager/api/v2/status');
} catch (e) {} } catch (e) {}
return alertmanagerResponse?.status === 200 || cortexAlertmanagerResponse?.status === 200 return cortexAlertmanagerResponse?.status === 200
? { ? {
status: 'success', status: 'success',
message: 'Health check passed.', message: 'Health check passed.',