"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[6795],{69473:(t,e,s)=>{s.r(e),s.d(e,{plugin:()=>m});var a,i,n=s(43215),r=(s(68404),s(69783)),o=s(10331),c=s(45916);const l=[{value:o.sK.cortex,label:"Cortex",description:"https://cortexmetrics.io/"},{value:o.sK.prometheus,label:"Prometheus",description:"https://prometheus.io/. Does not support editing configuration via API, so contact points and notification policies are read-only."}];var u=s(2937),h=s(58788),d=s(90923);class p extends n.DataSourceApi{constructor(t){super(t),this.instanceSettings=t}query(){return(0,u.of)({data:[]})}_request(t){const e={headers:{},method:"GET",url:this.instanceSettings.url+t};return(this.instanceSettings.basicAuth||this.instanceSettings.withCredentials)&&(this.instanceSettings.withCredentials=!0),this.instanceSettings.basicAuth&&(e.headers.Authorization=this.instanceSettings.basicAuth),(0,h.n)((0,d.getBackendSrv)().fetch(e))}async testDatasource(){var t;let e;if(this.instanceSettings.jsonData.implementation===o.sK.prometheus){try{var s;if(e=await this._request("/alertmanager/api/v2/status"),e&&200===(null===(s=e)||void 0===s?void 0:s.status))return{status:"error",message:"It looks like you have chosen Prometheus implementation, but detected a Cortex endpoint. Please update implementation selection and try again."}}catch(t){}try{e=await this._request("/api/v2/status")}catch(t){}}else{try{var a;if(e=await this._request("/api/v2/status"),e&&200===(null===(a=e)||void 0===a?void 0:a.status))return{status:"error",message:"It looks like you have chosen Cortex implementation, but detected a Prometheus endpoint. Please update implementation selection and try again."}}catch(t){}try{e=await this._request("/alertmanager/api/v2/status")}catch(t){}}return 200===(null===(t=e)||void 0===t?void 0:t.status)?{status:"success",message:"Health check passed."}:{status:"error",message:"Health check failed."}}}const m=new n.DataSourcePlugin(p).setConfigEditor((t=>{let{options:e,onOptionsChange:s}=t;return(0,c.jsxs)(c.Fragment,{children:[a||(a=(0,c.jsx)("h3",{className:"page-heading",children:"Alertmanager"})),(0,c.jsx)("div",{className:"gf-form-group",children:(0,c.jsx)("div",{className:"gf-form-inline",children:(0,c.jsxs)("div",{className:"gf-form",children:[i||(i=(0,c.jsx)(r.InlineFormLabel,{width:13,children:"Implementation"})),(0,c.jsx)(r.Select,{width:40,options:l,value:e.jsonData.implementation||o.sK.cortex,onChange:t=>s(Object.assign({},e,{jsonData:Object.assign({},e.jsonData,{implementation:t.value})}))})]})})}),(0,c.jsx)(r.DataSourceHttpSettings,{defaultUrl:"",dataSourceConfig:e,showAccessOptions:!0,onChange:s})]})}))}}]);
//# sourceMappingURL=alertmanagerPlugin.317a4e33517cb2aa5e4d.js.map