mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
check if alertmanager being configured is cortex or vanilla (#34726)
This commit is contained in:
@@ -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}
|
||||||
|
|||||||
@@ -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.',
|
||||||
|
|||||||
Reference in New Issue
Block a user