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wC,OAAb,QAApB,EAAAL,SAAA,eAAsBG,QACzB,CACEA,OAAQ,UACRC,QAAS,wBAEX,CACED,OAAQ,QACRC,QAAS,yBC3EZ,MAAME,EAAS,IAAIC,EAAAA,iBAAiB3B,GAAwB4B,iBFqBtB,IAAkC,IAAjC,QAAElB,EAAF,gBAAWmB,GAAsB,EAC7E,OACE,uCACE,eAAIC,UAAU,eAAd,4BACA,gBAAKA,UAAU,gBAAf,UACE,gBAAKA,UAAU,iBAAf,UACE,iBAAKA,UAAU,UAAf,iBACE,SAAC,EAAAC,gBAAD,CAAiBC,MAAO,GAAxB,8BACA,SAAC,EAAAC,OAAD,CACED,MAAO,GACPtB,QAAShB,EACTC,MAAOe,EAAQW,SAASC,gBAAkB1B,EAAAA,GAAAA,MAC1CsC,SAAWvC,GACTkC,EAAgB,OAAD,UACVnB,EADU,CAEbW,SAAU,OAAF,UACHX,EAAQW,SADL,CAENC,eAAgB3B,EAAMA,qBAQpC,SAAC,EAAAwC,uBAAD,CACEC,WAAY,GACZC,iBAAkB3B,EAClB4B,mBAAmB,EACnBJ,SAAUL","sources":["webpack://grafana/./public/app/plugins/datasource/alertmanager/ConfigEditor.tsx","webpack://grafana/./public/app/plugins/datasource/alertmanager/DataSource.ts","webpack://grafana/./public/app/plugins/datasource/alertmanager/module.ts"],"sourcesContent":["import React from 'react';\n\nimport { DataSourcePluginOptionsEditorProps, SelectableValue } from '@grafana/data';\nimport { DataSourceHttpSettings, InlineFormLabel, Select } from '@grafana/ui';\n\nimport { AlertManagerDataSourceJsonData, AlertManagerImplementation } from './types';\n\nexport type Props = DataSourcePluginOptionsEditorProps;\n\nconst IMPL_OPTIONS: SelectableValue[] = [\n {\n value: AlertManagerImplementation.mimir,\n icon: 'public/img/alerting/mimir_logo.svg',\n label: 'Mimir',\n description: `https://grafana.com/oss/mimir/. An open source, horizontally scalable, highly available, multi-tenant, long-term storage for Prometheus.`,\n },\n {\n value: AlertManagerImplementation.cortex,\n label: 'Cortex',\n description: `https://cortexmetrics.io/`,\n },\n {\n value: AlertManagerImplementation.prometheus,\n label: 'Prometheus',\n description:\n 'https://prometheus.io/. Does not support editing configuration via API, so contact points and notification policies are read-only.',\n },\n];\n\nexport const ConfigEditor: React.FC = ({ options, onOptionsChange }) => {\n return (\n <>\n

Alertmanager

\n
\n
\n
\n Implementation\n \n onOptionsChange({\n ...options,\n jsonData: {\n ...options.jsonData,\n implementation: value.value as AlertManagerImplementation,\n },\n })\n }\n />\n
\n
\n
\n \n \n );\n};\n","import { lastValueFrom, Observable, of } from 'rxjs';\n\nimport { DataQuery, DataQueryResponse, DataSourceApi, DataSourceInstanceSettings } from '@grafana/data';\nimport { BackendSrvRequest, getBackendSrv } from '@grafana/runtime';\n\nimport { AlertManagerDataSourceJsonData, AlertManagerImplementation } from './types';\n\nexport type AlertManagerQuery = {\n query: string;\n} & DataQuery;\n\nexport class AlertManagerDatasource extends DataSourceApi {\n constructor(public instanceSettings: DataSourceInstanceSettings) {\n super(instanceSettings);\n }\n\n // `query()` has to be implemented but we actually don't use it, just need this\n // data source to proxy requests.\n // @ts-ignore\n query(): Observable {\n return of({\n data: [],\n });\n }\n\n _request(url: string) {\n const options: BackendSrvRequest = {\n headers: {},\n method: 'GET',\n url: this.instanceSettings.url + url,\n };\n\n if (this.instanceSettings.basicAuth || this.instanceSettings.withCredentials) {\n this.instanceSettings.withCredentials = true;\n }\n\n if (this.instanceSettings.basicAuth) {\n options.headers!.Authorization = this.instanceSettings.basicAuth;\n }\n\n return lastValueFrom(getBackendSrv().fetch(options));\n }\n\n async testDatasource() {\n let alertmanagerResponse;\n\n if (this.instanceSettings.jsonData.implementation === AlertManagerImplementation.prometheus) {\n try {\n alertmanagerResponse = await this._request('/alertmanager/api/v2/status');\n if (alertmanagerResponse && alertmanagerResponse?.status === 200) {\n return {\n status: 'error',\n message:\n 'It looks like you have chosen Prometheus implementation, but detected a Mimir or Cortex endpoint. Please update implementation selection and try again.',\n };\n }\n } catch (e) {}\n try {\n alertmanagerResponse = await this._request('/api/v2/status');\n } catch (e) {}\n } else {\n try {\n alertmanagerResponse = await this._request('/api/v2/status');\n if (alertmanagerResponse && alertmanagerResponse?.status === 200) {\n return {\n status: 'error',\n message:\n 'It looks like you have chosen a Mimir or Cortex implementation, but detected a Prometheus endpoint. Please update implementation selection and try again.',\n };\n }\n } catch (e) {}\n try {\n alertmanagerResponse = await this._request('/alertmanager/api/v2/status');\n } catch (e) {}\n }\n\n return alertmanagerResponse?.status === 200\n ? {\n status: 'success',\n message: 'Health check passed.',\n }\n : {\n status: 'error',\n message: 'Health check failed.',\n };\n }\n}\n","import { DataSourcePlugin } from '@grafana/data';\n\nimport { ConfigEditor } from './ConfigEditor';\nimport { AlertManagerDatasource } from './DataSource';\n\n// This is not actually a data source but since 7.1,\n// it is required to specify query types. Which we don't have.\n// @ts-ignore\nexport const plugin = new DataSourcePlugin(AlertManagerDatasource).setConfigEditor(ConfigEditor);\n"],"names":["IMPL_OPTIONS","value","AlertManagerImplementation","icon","label","description","AlertManagerDatasource","DataSourceApi","constructor","instanceSettings","super","query","of","data","_request","url","options","headers","method","this","basicAuth","withCredentials","Authorization","lastValueFrom","getBackendSrv","fetch","alertmanagerResponse","jsonData","implementation","status","message","e","plugin","DataSourcePlugin","setConfigEditor","onOptionsChange","className","InlineFormLabel","width","Select","onChange","DataSourceHttpSettings","defaultUrl","dataSourceConfig","showAccessOptions"],"sourceRoot":""}