"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[6795],{69473:(t,e,s)=>{s.r(e),s.d(e,{plugin:()=>g});var a,i,n=s(43215),r=(s(68404),s(69783)),o=s(10331),l=s(45916);const c=[{value:o.sK.mimir,icon:"public/img/alerting/mimir_logo.svg",label:"Mimir",description:"https://grafana.com/oss/mimir/. An open source, horizontally scalable, highly available, multi-tenant, long-term storage for Prometheus."},{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),m=s(90923);class d 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,m.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 Mimir or 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 a Mimir or 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 g=new n.DataSourcePlugin(d).setConfigEditor((t=>{let{options:e,onOptionsChange:s}=t;return(0,l.jsxs)(l.Fragment,{children:[a||(a=(0,l.jsx)("h3",{className:"page-heading",children:"Alertmanager"})),(0,l.jsx)("div",{className:"gf-form-group",children:(0,l.jsx)("div",{className:"gf-form-inline",children:(0,l.jsxs)("div",{className:"gf-form",children:[i||(i=(0,l.jsx)(r.InlineFormLabel,{width:13,children:"Implementation"})),(0,l.jsx)(r.Select,{width:40,options:c,value:e.jsonData.implementation||o.sK.mimir,onChange:t=>s(Object.assign({},e,{jsonData:Object.assign({},e.jsonData,{implementation:t.value})}))})]})})}),(0,l.jsx)(r.DataSourceHttpSettings,{defaultUrl:"",dataSourceConfig:e,showAccessOptions:!0,onChange:s})]})}))}}]); //# sourceMappingURL=alertmanagerPlugin.f2abcf686c9ac0a4bcb1.js.map