"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4339],{26321:(C,m,t)=>{t.d(m,{Z:()=>e});var a=t(85960);function c({children:r,shouldWrap:s,wrap:u},O){return s?a.cloneElement(u(r)):r}const e=(0,a.forwardRef)(c)},4609:(C,m,t)=>{t.d(m,{NC:()=>A,ZV:()=>s,onCallApi:()=>O});var a=t(85445),c=t(66564),e=t(58533),r=t(58712);const s="grafana_alerting_v2",u=l=>`/api/plugin-proxy/${e.W.OnCall}${l}`,O=r.C.injectEndpoints({endpoints:l=>({grafanaOnCallIntegrations:l.query({query:()=>({url:u("/api/internal/v1/alert_receive_channels/"),params:{filters:!0,integration:[c.As,"legacy_grafana_alerting"]},showErrorAlert:!1}),transformResponse:i=>P(i)?i.results:i,providesTags:["OnCallIntegrations"]}),validateIntegrationName:l.query({query:i=>({url:u("/api/internal/v1/alert_receive_channels/validate_name/"),params:{verbal_name:i},showErrorAlert:!1})}),createIntegration:l.mutation({query:i=>({url:u("/api/internal/v1/alert_receive_channels/"),data:i,method:"POST",showErrorAlert:!0}),invalidatesTags:["OnCallIntegrations"]}),features:l.query({query:()=>({url:u("/api/internal/v1/features/"),showErrorAlert:!1})})})});function P(l){return"results"in l&&Array.isArray(l.results)}const{useGrafanaOnCallIntegrationsQuery:v}=O;function A(l){return(0,a.kW)(l)&&"detail"in l.data}},53914:(C,m,t)=>{t.d(m,{q:()=>s});var a=t(56375),c=t.n(a),e=t(85960),r=t(57297);const s=({actions:l,children:i})=>{const _=(0,a.filter)(l,v),M=(0,a.filter)(l,A);return _.length?e.createElement(u,{actions:_},i):M.length?e.createElement(O,{actions:M},i):null},u=({actions:l,children:i})=>{const _=(0,r.Mz)();return P(_,l)?e.createElement(e.Fragment,null,i):null},O=({actions:l,children:i})=>{const _=(0,r.K_)();return P(_,l)?e.createElement(e.Fragment,null,i):null};function P(l,i){return(0,a.chain)(l).pick(i).values().value().some(([_,M])=>M===!0)}function v(l){return Object.values(r.oI).includes(l)}function A(l){return Object.values(r.jU).includes(l)}},28157:(C,m,t)=>{t.d(m,{u:()=>P});var a=t(66681),c=t(85960),e=t(47257),r=t(49199),s=t(16901),u=t(81828),O=t(76679);function P({currentAlertmanager:A}){const l=(0,e.wW)(v),i=A===O.GC,{currentData:_}=u.alertmanagerApi.endpoints.getAlertmanagerChoiceStatus.useQuery(void 0,{skip:!i});if(!(_?.alertmanagersChoice&&[s.TE.External,s.TE.All].includes(_?.alertmanagersChoice))||!i)return null;const y=_.numExternalAlertmanagers>0;return _.alertmanagersChoice===s.TE.External?c.createElement(r.b,{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.",c.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.")):_.alertmanagersChoice===s.TE.All&&y?c.createElement(r.b,{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.",c.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 v=A=>({adminHint:(0,a.css)`
    font-size: ${A.typography.bodySmall.fontSize};
    font-weight: ${A.typography.bodySmall.fontWeight};
  `})},46911:(C,m,t)=>{t.d(m,{g:()=>O});var a=t(66681),c=t(85960),e=t(47257),r=t(40377),s=t(13086),u=t(97666);const O=({children:v,icon:A,color:l="secondary",direction:i="row",..._})=>{const M=(0,e.wW)(P),y=typeof _.onClick=="function",o=i==="row",n=o?"center":"flex-start",E=o?.5:0;return c.createElement("div",{className:(0,a.cx)({[M.interactive]:y}),..._},c.createElement(r.x,{variant:"bodySmall",color:l},c.createElement(s.K,{direction:i,alignItems:n,gap:E,wrap:"wrap"},A&&c.createElement(u.J,{size:"sm",name:A}),v)))},P=()=>({interactive:(0,a.css)`
    cursor: pointer;
  `})},35855:(C,m,t)=>{t.d(m,{c:()=>e});var a=t(85960),c=t(47257);const e=({children:r})=>{const s=(0,c.l4)();return a.createElement("strong",{style:{color:s.colors.text.primary}},r)}},27908:(C,m,t)=>{t.d(m,{u:()=>l});var a=t(66681),c=t(78344),e=t.n(c),r=t(85960),s=t(53565),u=t(47257),O=t(62577),P=t(29165),v=t(55855),A=t(23694);function l({format:_,textDefinition:M,downloadFileName:y,onClose:o}){const n=(0,u.wW)(i),E=(0,r.useCallback)(()=>{const d=new Blob([M],{type:`application/${_};charset=utf-8`});e()(d,`${y}.${_}`)},[M,y,_]),g=(0,r.useMemo)(()=>{const d=A.uN[_];return d.formatter?d.formatter(M):M},[_,M]);return r.createElement("div",{className:n.container},r.createElement("div",{className:n.content},r.createElement(s.Z,{disableWidth:!0},({height:d})=>r.createElement(O.p,{width:"100%",height:d,language:_,value:g,monacoOptions:{minimap:{enabled:!1},scrollBeyondLastLine:!1,lineNumbers:"on",readOnly:!0}}))),r.createElement("div",{className:n.actions},r.createElement(P.zx,{variant:"secondary",onClick:o},"Cancel"),r.createElement(v.m,{icon:"copy",getText:()=>M},"Copy code"),r.createElement(P.zx,{icon:"download-alt",onClick:E},"Download")))}const i=_=>({container:(0,a.css)`
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: ${_.spacing(2)};
  `,content:(0,a.css)`
    flex: 1 1 100%;
  `,actions:(0,a.css)`
    flex: 0;
    justify-content: flex-end;
    display: flex;
    gap: ${_.spacing(1)};
  `})},29657:(C,m,t)=>{t.d(m,{i:()=>r});var a=t(85960),c=t(63153),e=t(47831);function r({activeTab:s,onTabChange:u,children:O,onClose:P,formatProviders:v,title:A="Export"}){const l=Object.values(v).map(i=>({label:i.name,value:i.exportFormat}));return a.createElement(c.d,{title:A,subtitle:"Select the format and download the file or copy the contents to clipboard",tabs:a.createElement(e.mg,{tabs:l,setActiveTab:u,activeTab:s}),onClose:P,size:"md"},O)}},23694:(C,m,t)=>{t.d(m,{uN:()=>r});const a={name:"JSON",exportFormat:"json",formatter:u=>{try{return JSON.stringify(JSON.parse(u),null,4)}catch{return u}}},c={name:"YAML",exportFormat:"yaml"},e={name:"Terraform (HCL)",exportFormat:"hcl"},r={[a.exportFormat]:a,[c.exportFormat]:c,[e.exportFormat]:e},s=[a,c]},66564:(C,m,t)=>{t.d(m,{As:()=>a,Fs:()=>r,hM:()=>c});const a="grafana_alerting";var c=(s=>(s.OnCall="oncall",s))(c||{});const e=(s,u)=>u.includes(s),r=(s,u)=>{if(!s.grafana_managed_receiver_configs)return!1;const O=s.grafana_managed_receiver_configs.length===1,P=e(s.grafana_managed_receiver_configs[0]?.settings?.url??"",u.map(v=>v.integration_url));return O&&P}},47831:(C,m,t)=>{t.d(m,{CU:()=>n,mg:()=>E});var a=t(66681),c=t(48525),e=t(85960),r=t(53285),s=t(53565),u=t(47257),O=t(63153),P=t(70523),v=t(94439),A=t(29165),l=t(14607),i=t(97666),_=t(62577),M=t(38884),y=t(9001);const o=[{label:"Yaml",value:"yaml"}],n=({onClose:f})=>{const[p,R]=(0,e.useState)("yaml"),{setValue:I}=(0,r.Gc)(),L=(0,u.wW)(T),B=K=>{for(const W in K)I(W,K[W]);f()};return e.createElement(O.d,{title:"Inspect Alert rule",subtitle:e.createElement("div",{className:L.subtitle},e.createElement(E,{tabs:o,setActiveTab:R,activeTab:p})),onClose:f},p==="yaml"&&e.createElement(g,{onSubmit:B}))};function E({tabs:f,activeTab:p,setActiveTab:R}){return e.createElement(P.J,null,f.map((I,L)=>e.createElement(v.O,{key:`${I.value}-${L}`,label:I.label,value:I.value,onChangeTab:()=>R(I.value),active:p===I.value})))}const g=({onSubmit:f})=>{const p=(0,u.wW)(D),{getValues:R}=(0,r.Gc)(),I=(0,M.yh)(R()),[L,B]=(0,e.useState)((0,c.$w)(I)),K=()=>{const W=(0,c.zD)(L),U=R(),x=h(W);f({...U,...x})};return e.createElement(e.Fragment,null,e.createElement("div",{className:p.applyButton},e.createElement(A.zx,{type:"button",onClick:K},"Apply"),e.createElement(l.u,{content:e.createElement(d,null),theme:"info",placement:"left-start",interactive:!0},e.createElement(i.J,{name:"exclamation-triangle",size:"xl"}))),e.createElement("div",{className:p.content},e.createElement(s.Z,{disableWidth:!0},({height:W})=>e.createElement(_.p,{width:"100%",height:W,language:"yaml",value:L,onBlur:B,monacoOptions:{minimap:{enabled:!1}}}))))};function d(){return e.createElement("div",null,"The YAML content in the editor only contains alert rule configuration ",e.createElement("br",null),"To configure Prometheus, you need to provide the rest of the"," ",e.createElement("a",{href:"https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/",target:"_blank",rel:"noreferrer"},"configuration file content."))}function h(f){return(0,y.cG)(f)?(0,M.WL)(f):(0,y.yF)(f)?(0,M.lN)(f):{}}const D=f=>({content:(0,a.css)`
    flex-grow: 1;
    height: 100%;
    padding-bottom: 16px;
    margin-bottom: ${f.spacing(2)};
  `,applyButton:(0,a.css)`
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-grow: 0;
    margin-bottom: ${f.spacing(2)};
  `}),T=()=>({subtitle:(0,a.css)`
    display: flex;
    align-items: center;
    justify-content: space-between;
  `})},75636:(C,m,t)=>{t.d(m,{j:()=>r});var a=t(85960),c=t(30694),e=t(91);function r(){const{search:s}=(0,c.TH)(),u=(0,a.useMemo)(()=>new URLSearchParams(s),[s]),O=(0,a.useCallback)((P,v)=>{e.E1.partial(P,v)},[]);return[u,O]}},5493:(C,m,t)=>{t.d(m,{y:()=>a});const a={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"}},59439:(C,m,t)=>{t.d(m,{$2:()=>l,tK:()=>i,w2:()=>v});var a=t(56375),c=t.n(a),e=t(16901),r=t(41460);const s=["receiver","group_by","group_wait","group_interval","repeat_interval"];function u(o,n){const E=O(o,n),g=new Map(n.map(d=>[d,{match:!1,matcher:null}]));return o.forEach(d=>{const h=n.find(D=>y(d,D));h&&g.set(h,{match:!0,matcher:d})}),{matches:E,labelsMatch:g}}function O(o,n){for(const E of o)if(!M(E,n))return!1;return!0}function P(o,n){let E=[];const g=u(o.object_matchers??[],n);if(!g.matches)return[];if(o.routes)for(const d of o.routes){let h=P(d,n);if(E=E.concat(h),h.length&&!d.continue)break}return E.length===0&&E.push({route:o,labelsMatch:g.labelsMatch}),E}function v(o){function n(g){g.object_matchers=(0,r.QO)(g),delete g.matchers,delete g.match,delete g.match_re,g.routes?.forEach(n)}const E=structuredClone(o);return n(E),E}function A(o,n,E){const g=[];return E.reduce((d,h)=>{const D=h.alerts.filter(T=>{const f=Object.entries(T.labels);return P(o,f).some(p=>p.route===n)});return D.length&&d.push({...h,alerts:D}),d},g)}function l(o,n,E){const g=(0,a.merge)({},o,E),d=(0,a.pick)(g,s);return(0,a.reduce)(d,(D={},T,f)=>{const p=T!==void 0,R=p&&n[f]===void 0,I=p&&n[f]==="",L=f==="group_by"&&p&&(0,a.isArray)(n[f])&&n[f]?.length===0;return(R||I||L)&&(D[f]=T),D},{})}function i(o){return{...o,routes:o.routes?.map(n=>{const E=l(o,n);return i({...n,...E})})}}const _={[e._M.equal]:(o,n)=>o===n,[e._M.notEqual]:(o,n)=>o!==n,[e._M.regex]:(o,n)=>new RegExp(n).test(o),[e._M.notRegex]:(o,n)=>!new RegExp(n).test(o)};function M(o,n){const[E,g,d]=o;let h="";const D=Object.fromEntries(n)[E];D&&(h=D);const T=_[g];if(!T)throw new Error(`no such operator: ${g}`);return T(h,d)}function y(o,n){let[E,g]=n;const[d,h,D]=o;if(E!==d)return!1;const T=_[h];if(!T)throw new Error(`no such operator: ${h}`);return T(g,D)}}}]);

//# sourceMappingURL=4339.ff5f670c98a9c43edf31.js.map