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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -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}

View File

@ -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.',