"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[6795],{63805:(b,l,e)=>{e.r(l),e.d(l,{plugin:()=>j});var c=e(54721),h=e(35422),a=e(39953),u=e(17716),d=e(30559),g=e(56921),f=e(9558),v=e(69171),p=e(26286),E=e(98632),y=e(3782),S=e(50820),i=e(47858);const A=[{value:i.sK.mimir,label:"Mimir",description:"https://grafana.com/oss/mimir/. An open source, horizontally scalable, highly available, multi-tenant, long-term storage for Prometheus."},{value:i.sK.cortex,label:"Cortex",description:"https://cortexmetrics.io/"},{value:i.sK.prometheus,label:"Prometheus",description:"https://prometheus.io/. Does not support editing configuration via API, so contact points and notification policies are read-only."}],C=o=>{const{options:t,onOptionsChange:n}=o;return a.createElement(a.Fragment,null,a.createElement("h3",{className:"page-heading"},"Alertmanager"),a.createElement("div",{className:"gf-form-group"},a.createElement("div",{className:"gf-form-inline"},a.createElement("div",{className:"gf-form"},a.createElement(g.c,{width:13},"Implementation"),a.createElement(f.Ph,{width:40,options:A,value:t.jsonData.implementation||i.sK.mimir,onChange:r=>n({...t,jsonData:{...t.jsonData,implementation:r.value}})}))),a.createElement("div",{className:"gf-form-inline"},a.createElement(v._,{label:"Receive Grafana Alerts",tooltip:"When enabled, Grafana-managed alerts are sent to this Alertmanager.",labelWidth:26},a.createElement(p.x,{value:t.jsonData.handleGrafanaManagedAlerts??!1,onChange:r=>{n((0,h.Uy)(t,s=>{s.jsonData.handleGrafanaManagedAlerts=r.currentTarget.checked}))}}))),t.jsonData.handleGrafanaManagedAlerts&&a.createElement(E.x,{variant:"bodySmall",color:"secondary"},"Make sure to enable the alert forwarding on the ",a.createElement(u.Link,{to:"/alerting/admin"},"admin page"),".")),a.createElement(y.E,{defaultUrl:"",dataSourceConfig:t,showAccessOptions:!0,onChange:n,sigV4AuthToggleEnabled:S.config.sigV4AuthEnabled,renderSigV4Editor:a.createElement(d.IW,{...o}),secureSocksDSProxyEnabled:!1}))};var D=e(63302),I=e(31312),m=e(4148),M=e(78313),P=e(57675);class x extends c.MF{constructor(t){super(t),this.instanceSettings=t}query(){return(0,D.of)({data:[]})}_request(t){const n={headers:{},method:"GET",url:this.instanceSettings.url+t};return(this.instanceSettings.basicAuth||this.instanceSettings.withCredentials)&&(this.instanceSettings.withCredentials=!0),this.instanceSettings.basicAuth&&(n.headers.Authorization=this.instanceSettings.basicAuth),(0,I.n)((0,m.i)().fetch(n))}async testDatasource(){let t;const n=this.instanceSettings.url,r=n?await(0,M.SJ)(n):{lazyConfigInit:!1};if(this.instanceSettings.jsonData.implementation===i.sK.prometheus){try{if(t=await this._request("/alertmanager/api/v2/status"),t&&t?.status===200)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{}try{t=await this._request("/api/v2/status")}catch{}}else{try{if(t=await this._request("/api/v2/status"),t&&t?.status===200)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{}try{t=await this._request("/alertmanager/api/v2/status")}catch(s){if((0,m.kW)(s)&&r.lazyConfigInit&&(0,P.kk)(s)?.includes("the Alertmanager is not configured"))return{status:"success",message:"Health check passed.",details:{message:"Mimir Alertmanager without the fallback configuration has been discovered."}}}}return t?.status===200?{status:"success",message:"Health check passed."}:{status:"error",message:"Health check failed."}}}const j=new c.hf(x).setConfigEditor(C)}}]);

//# sourceMappingURL=alertmanagerPlugin.aff8e3d2a0563a514f8a.js.map