"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[6795],{"./public/app/plugins/datasource/alertmanager/module.ts":(e,t,s)=>{s.r(t),s.d(t,{plugin:()=>m});var a,n,i=s("./packages/grafana-data/src/index.ts"),r=s("./packages/grafana-ui/src/index.ts"),o=(s("./node_modules/react/index.js"),s("./public/app/plugins/datasource/alertmanager/types.ts")),c=s("./node_modules/react/jsx-runtime.js");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("./node_modules/rxjs/dist/esm5/internal/observable/of.js"),d=s("./node_modules/rxjs/dist/esm5/internal/lastValueFrom.js"),h=s("./packages/grafana-runtime/src/index.ts");class p extends i.DataSourceApi{constructor(e){super(e),this.instanceSettings=e}query(){return(0,u.of)({data:[]})}_request(e){const t={headers:{},method:"GET",url:this.instanceSettings.url+e};return(this.instanceSettings.basicAuth||this.instanceSettings.withCredentials)&&(this.instanceSettings.withCredentials=!0),this.instanceSettings.basicAuth&&(t.headers.Authorization=this.instanceSettings.basicAuth),(0,d.n)((0,h.getBackendSrv)().fetch(t))}async testDatasource(){var e;let t;if(this.instanceSettings.jsonData.implementation===o.sK.prometheus){try{var s;if(t=await this._request("/alertmanager/api/v2/status"),t&&200===(null===(s=t)||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(e){}try{t=await this._request("/api/v2/status")}catch(e){}}else{try{var a;if(t=await this._request("/api/v2/status"),t&&200===(null===(a=t)||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(e){}try{t=await this._request("/alertmanager/api/v2/status")}catch(e){}}return 200===(null===(e=t)||void 0===e?void 0:e.status)?{status:"success",message:"Health check passed."}:{status:"error",message:"Health check failed."}}}const m=new i.DataSourcePlugin(p).setConfigEditor((({options:e,onOptionsChange:t})=>(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:[n||(n=(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:s=>t(Object.assign({},e,{jsonData:Object.assign({},e.jsonData,{implementation:s.value})}))})]})})}),(0,c.jsx)(r.DataSourceHttpSettings,{defaultUrl:"",dataSourceConfig:e,showAccessOptions:!0,onChange:t})]})))}}]);
//# sourceMappingURL=alertmanagerPlugin.8128b05ac04b15cbf98d.js.map