"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[6489],{26423:(I,f,e)=>{e.d(f,{Pc:()=>s,WG:()=>h,uz:()=>A});var o=e(17172),m=e(37534),t=e(99494),n=e(49962);const s="grafana_alerting_v2",E=l=>`/api/plugin-proxy/${t.W.OnCall}${l}`,h=n.H.injectEndpoints({endpoints:l=>({grafanaOnCallIntegrations:l.query({query:()=>({url:E("/api/internal/v1/alert_receive_channels/"),params:{filters:!0,integration:[m.FI,"legacy_grafana_alerting"],skip_pagination:!0},showErrorAlert:!1}),transformResponse:_=>v(_)?_.results:_,providesTags:["OnCallIntegrations"]}),validateIntegrationName:l.query({query:_=>({url:E("/api/internal/v1/alert_receive_channels/validate_name/"),params:{verbal_name:_},showErrorAlert:!1})}),createIntegration:l.mutation({query:_=>({url:E("/api/internal/v1/alert_receive_channels/"),data:_,method:"POST",showErrorAlert:!0}),invalidatesTags:["OnCallIntegrations"]}),features:l.query({query:()=>({url:E("/api/internal/v1/features/"),showErrorAlert:!1})})})});function v(l){return"results"in l&&Array.isArray(l.results)}const{useGrafanaOnCallIntegrationsQuery:M}=h;function A(l){return(0,o.NF)(l)&&"detail"in l.data}},64853:(I,f,e)=>{e.d(f,{_:()=>s});var o=e(2543),m=e.n(o),t=e(96540),n=e(19073);const s=({actions:l,children:_})=>{const O=(0,o.filter)(l,M),p=(0,o.filter)(l,A);return O.length?t.createElement(E,{actions:O},_):p.length?t.createElement(h,{actions:p},_):null},E=({actions:l,children:_})=>{const O=(0,n.iI)();return v(O,l)?t.createElement(t.Fragment,null,_):null},h=({actions:l,children:_})=>{const O=(0,n.e2)();return v(O,l)?t.createElement(t.Fragment,null,_):null};function v(l,_){return(0,o.chain)(l).pick(_).values().value().some(([O,p])=>p===!0)}function M(l){return Object.values(n.QI).includes(l)}function A(l){return Object.values(n.RY).includes(l)}},64047:(I,f,e)=>{e.d(f,{e:()=>t});var o=e(96540),m=e(55852);const t=({isCollapsed:n,onToggle:s,idControlled:E,className:h,text:v,size:M="xl",...A})=>o.createElement(m.$n,{type:"button",fill:"text",variant:"secondary","aria-expanded":!n,"aria-controls":E,className:h,icon:n?"angle-right":"angle-down",onClick:()=>s(!n),...A},v)},23896:(I,f,e)=>{e.d(f,{A:()=>t});var o=e(96540);function m({children:n,shouldWrap:s,wrap:E},h){return s?o.cloneElement(E(n)):n}const t=(0,o.forwardRef)(m)},57895:(I,f,e)=>{e.d(f,{M:()=>v});var o=e(32196),m=e(96540),t=e(40845),n=e(42418),s=e(60021),E=e(82843),h=e(57220);function v({currentAlertmanager:A}){const l=(0,t.of)(M),_=A===h.hY,{currentData:O}=E.m.endpoints.getAlertmanagerChoiceStatus.useQuery(void 0,{skip:!_});if(!(O?.alertmanagersChoice&&[s.nA.External,s.nA.All].includes(O?.alertmanagersChoice))||!_)return null;const R=O.numExternalAlertmanagers>0;return O.alertmanagersChoice===s.nA.External?m.createElement(n.F,{title:"Grafana alerts are not delivered to Grafana Alertmanager"},"Grafana is configured to send alerts to external Alertmanagers only. Changing Grafana Alertmanager configuration will not affect delivery of your alerts.",m.createElement("div",{className:l.adminHint},"To change your Alertmanager setup, go to the Alerting Admin page. If you do not have access, contact your Administrator.")):O.alertmanagersChoice===s.nA.All&&R?m.createElement(n.F,{title:"You have additional Alertmanagers to configure",severity:"warning"},"Ensure you make configuration changes in the correct Alertmanagers; both internal and external. Changing one will not affect the others.",m.createElement("div",{className:l.adminHint},"To change your Alertmanager setup, go to the Alerting Admin page. If you do not have access, contact your Administrator.")):null}const M=A=>({adminHint:(0,o.css)`
    font-size: ${A.typography.bodySmall.fontSize};
    font-weight: ${A.typography.bodySmall.fontWeight};
  `})},94855:(I,f,e)=>{e.d(f,{O:()=>t});var o=e(96540),m=e(40845);const t=({children:n})=>{const s=(0,m.$j)();return o.createElement("strong",{style:{color:s.colors.text.primary}},n)}},16293:(I,f,e)=>{e.d(f,{J:()=>O});var o=e(32196),m=e(4213),t=e.n(m),n=e(96540),s=e(70713),E=e(40845),h=e(32372),v=e(55852),M=e(10534),A=e(72109),l=e(42418),_=e(84029);function O({format:y,textDefinition:a,downloadFileName:r,onClose:c}){const i=(0,E.of)(p),g=_.sl[y],d=(0,n.useCallback)(()=>{const u=new Blob([a],{type:`application/${y};charset=utf-8`});t()(u,`${r}.${y}`)},[a,r,y]),P=(0,n.useMemo)(()=>g.formatter?g.formatter(a):a,[g,a]);return n.createElement("div",{className:i.container},n.createElement(R,{exportProvider:g}),n.createElement("div",{className:i.content},n.createElement(s.Ay,{disableWidth:!0},({height:u})=>n.createElement(h.B,{width:"100%",height:u,language:y,value:P,monacoOptions:{minimap:{enabled:!1},scrollBeyondLastLine:!1,lineNumbers:"on",readOnly:!0}}))),n.createElement("div",{className:i.actions},n.createElement(v.$n,{variant:"secondary",onClick:c},"Cancel"),n.createElement(M.b,{icon:"copy",getText:()=>a},"Copy code"),n.createElement(v.$n,{icon:"download-alt",onClick:d},"Download")))}const p=y=>({container:(0,o.css)`
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: ${y.spacing(2)};
  `,content:(0,o.css)`
    flex: 1 1 100%;
  `,actions:(0,o.css)`
    flex: 0;
    justify-content: flex-end;
    display: flex;
    gap: ${y.spacing(1)};
  `});function R({exportProvider:y}){const{name:a,type:r}=y,c={file:{title:"File-provisioning format",component:n.createElement(n.Fragment,null,a," format is only valid for File Provisioning."," ",n.createElement(A.Y,{href:"https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/file-provisioning/",external:!0},"Read more in the docs."))},api:{title:"API-provisioning format",component:n.createElement(n.Fragment,null,a," format is only valid for API Provisioning."," ",n.createElement(A.Y,{href:"https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/http-api-provisioning/",external:!0},"Read more in the docs."))},terraform:{title:"Terraform-provisioning format",component:n.createElement(n.Fragment,null,a," format is only valid for Terraform Provisioning."," ",n.createElement(A.Y,{href:"https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/terraform-provisioning/",external:!0},"Read more in the docs."))}},{title:i,component:g}=c[r];return n.createElement(l.F,{title:i,severity:"info",bottomSpacing:0,topSpacing:0},g)}},76648:(I,f,e)=>{e.d(f,{m:()=>n});var o=e(96540),m=e(87978),t=e(73716);function n({activeTab:s,onTabChange:E,children:h,onClose:v,formatProviders:M,title:A="Export"}){const l=Object.values(M).map(_=>({label:_.name,value:_.exportFormat}));return o.createElement(m._,{title:A,subtitle:"Select the format and download the file or copy the contents to clipboard",tabs:o.createElement(t.sb,{tabs:l,setActiveTab:E,activeTab:s}),onClose:v,size:"md"},h)}},84029:(I,f,e)=>{e.d(f,{sl:()=>n});const o={name:"JSON",exportFormat:"json",type:"file",formatter:E=>{try{return JSON.stringify(JSON.parse(E),null,4)}catch{return E}}},m={name:"YAML",exportFormat:"yaml",type:"file"},t={name:"Terraform (HCL)",exportFormat:"hcl",type:"terraform"},n={[o.exportFormat]:o,[m.exportFormat]:m,[t.exportFormat]:t},s=[o,m]},37534:(I,f,e)=>{e.d(f,{FI:()=>o,J4:()=>m,p8:()=>n});const o="grafana_alerting";var m=(s=>(s.OnCall="oncall",s))(m||{});const t=(s,E)=>E.includes(s),n=(s,E)=>{if(!s.grafana_managed_receiver_configs)return!1;const h=s.grafana_managed_receiver_configs.length===1,v=t(s.grafana_managed_receiver_configs[0]?.settings?.url??"",E.map(M=>M.integration_url));return h&&v}},73716:(I,f,e)=>{e.d(f,{G_:()=>a,sb:()=>r});var o=e(32196),m=e(20382),t=e(96540),n=e(49785),s=e(70713),E=e(40845),h=e(87978),v=e(63021),M=e(40675),A=e(55852),l=e(56034),_=e(14578),O=e(32372),p=e(63066),R=e(23662);const y=[{label:"Yaml",value:"yaml"}],a=({onClose:u})=>{const[D,C]=(0,t.useState)("yaml"),{setValue:T}=(0,n.xW)(),L=(0,E.of)(P),U=B=>{for(const W in B)T(W,B[W]);u()};return t.createElement(h._,{title:"Inspect Alert rule",subtitle:t.createElement("div",{className:L.subtitle},t.createElement(r,{tabs:y,setActiveTab:C,activeTab:D})),onClose:u},D==="yaml"&&t.createElement(c,{onSubmit:U}))};function r({tabs:u,activeTab:D,setActiveTab:C}){return t.createElement(v.U,null,u.map((T,L)=>t.createElement(M.o,{key:`${T.value}-${L}`,label:T.label,value:T.value,onChangeTab:()=>C(T.value),active:D===T.value})))}const c=({onSubmit:u})=>{const D=(0,E.of)(d),{getValues:C}=(0,n.xW)(),T=(0,p.l1)(C()),[L,U]=(0,t.useState)((0,m.Bh)(T)),B=()=>{const W=(0,m.Hh)(L),K=C(),x=g(W);u({...K,...x})};return t.createElement(t.Fragment,null,t.createElement("div",{className:D.applyButton},t.createElement(A.$n,{type:"button",onClick:B},"Apply"),t.createElement(l.m,{content:t.createElement(i,null),theme:"info",placement:"left-start",interactive:!0},t.createElement(_.I,{name:"exclamation-triangle",size:"xl"}))),t.createElement("div",{className:D.content},t.createElement(s.Ay,{disableWidth:!0},({height:W})=>t.createElement(O.B,{width:"100%",height:W,language:"yaml",value:L,onBlur:U,monacoOptions:{minimap:{enabled:!1}}}))))};function i(){return t.createElement("div",null,"The YAML content in the editor only contains alert rule configuration ",t.createElement("br",null),"To configure Prometheus, you need to provide the rest of the"," ",t.createElement("a",{href:"https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/",target:"_blank",rel:"noreferrer"},"configuration file content."))}function g(u){return(0,R.$y)(u)?(0,p.Qk)(u):(0,R.i7)(u)?(0,p.XI)(u):{}}const d=u=>({content:(0,o.css)`
    flex-grow: 1;
    height: 100%;
    padding-bottom: 16px;
    margin-bottom: ${u.spacing(2)};
  `,applyButton:(0,o.css)`
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-grow: 0;
    margin-bottom: ${u.spacing(2)};
  `}),P=()=>({subtitle:(0,o.css)`
    display: flex;
    align-items: center;
    justify-content: space-between;
  `})},19645:(I,f,e)=>{e.d(f,{M:()=>o});const o={discord:"discord",email:"envelope",googlechat:"google-hangouts-alt",hipchat:"hipchat",line:"line",pagerduty:"pagerduty",slack:"slack",teams:"microsoft",telegram:"telegram-alt",webhook:"link",sns:"amazon"}},79581:(I,f,e)=>{e.d(f,{W$:()=>_,_I:()=>O,rJ:()=>M});var o=e(2543),m=e.n(o),t=e(60021),n=e(32642);const s=["receiver","group_by","group_wait","group_interval","repeat_interval"];function E(a,r){const c=h(a,r),i=new Map(r.map(g=>[g,{match:!1,matcher:null}]));return a.forEach(g=>{const d=r.find(P=>y(g,P));d&&i.set(d,{match:!0,matcher:g})}),{matches:c,labelsMatch:i}}function h(a,r){for(const c of a)if(!R(c,r))return!1;return!0}function v(a,r){let c=[];const i=E(a.object_matchers??[],r);if(!i.matches)return[];if(a.routes)for(const g of a.routes){let d=v(g,r);if(c=c.concat(d),d.length&&!g.continue)break}return c.length===0&&c.push({route:a,labelsMatch:i.labelsMatch}),c}function M(a){function r(i){i.object_matchers=(0,n.J$)(i),delete i.matchers,delete i.match,delete i.match_re,i.routes?.forEach(r)}const c=structuredClone(a);return r(c),c}function A(a){function r(i){i.object_matchers=i.object_matchers?.map(([g,d,P])=>[unquoteWithUnescape(g),d,unquoteWithUnescape(P)]),i.routes?.forEach(r)}const c=structuredClone(a);return r(c),c}function l(a,r,c){const i=[];return c.reduce((g,d)=>{const P=d.alerts.filter(u=>{const D=Object.entries(u.labels);return v(a,D).some(C=>C.route===r)});return P.length&&g.push({...d,alerts:P}),g},i)}function _(a,r,c){const g={...(0,o.pick)(a,s),...c};return(0,o.reduce)(g,(P,u,D)=>{const C=u!=null,U=[void 0,"",null].some(K=>r[D]===K)&&C,B=D==="group_by"&&C&&(0,o.isArray)(r[D])&&r[D]?.length===0;return(U||B)&&(P[D]=u),P},{})}function O(a){return{...a,routes:a.routes?.map(r=>{const c=_(a,r);return O({...r,...c})})}}const p={[t.ho.equal]:(a,r)=>a===r,[t.ho.notEqual]:(a,r)=>a!==r,[t.ho.regex]:(a,r)=>new RegExp(r).test(a),[t.ho.notRegex]:(a,r)=>!new RegExp(r).test(a)};function R(a,r){const[c,i,g]=a;let d="";const P=Object.fromEntries(r)[c];P&&(d=P);const u=p[i];if(!u)throw new Error(`no such operator: ${i}`);return u(d,g)}function y(a,r){let[c,i]=r;const[g,d,P]=a;if(c!==g)return!1;const u=p[d];if(!u)throw new Error(`no such operator: ${d}`);return u(i,P)}}}]);

//# sourceMappingURL=6489.b78a59e3add021033b65.js.map