"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[689],{61324:(z,O,t)=>{t.d(O,{C0:()=>G,Uv:()=>R,Xq:()=>M});var e=t(39953),E=t(33155),S=t(12608),R=(c=>(c.ContactPoint="contact point",c.Template="template",c.MuteTiming="mute timing",c.AlertRule="alert rule",c.RootNotificationPolicy="root notification policy",c))(R||{});const M=({resource:c})=>e.createElement(E.b,{title:`This ${c} cannot be edited through the UI`,severity:"info"},"This ",c," has been provisioned, that means it was created by config. Please contact your server admin to update this ",c,"."),G=()=>e.createElement(S.C,{text:"Provisioned",color:"purple"})},90689:(z,O,t)=>{t.r(O),t.d(O,{default:()=>L});var e=t(39953),E=t(27366),S=t(84766),R=t(4919),M=t(12190),G=t(33155),c=t(22784),U=t(77804),T=t(90201),u=t(98632),h=t(17330),H=t(20015),J=t(61205);function Q(r){const{chrome:l}=(0,J.p)();(0,e.useLayoutEffect)(()=>{r?.name&&l.update({pageNav:{text:r.name}})},[l,r]),r&&(document.title=`${r.name} - Alerting - ${H.c.AppTitle}`)}var b=t(75690),N=t(30391),B=t(15032),$=t(41407),I=t(82803),x=t(69865);const n=r=>{const l=(0,I.wW)(a,r);return e.createElement(x.u,{content:String(r.state),placement:"top"},e.createElement("div",{className:l.dot}))},a=(r,l)=>{const i=r.spacing(1.25);return{dot:(0,$.css)`
      width: ${i};
      height: ${i};

      border-radius: 100%;

      background-color: ${r.colors.secondary.main};
      outline: solid calc(${i} / 2.5) ${r.colors.secondary.transparent};

      ${l.state===h.bj.Normal&&(0,$.css)`
        background-color: ${r.colors.success.main};
        outline-color: ${r.colors.success.transparent};
      `}

      ${l.state===h.bj.Pending&&(0,$.css)`
        background-color: ${r.colors.warning.main};
        outline-color: ${r.colors.warning.transparent};
      `}

      ${l.state===h.bj.Alerting&&(0,$.css)`
        background-color: ${r.colors.error.main};
        outline-color: ${r.colors.error.transparent};
      `}
    `}};var o=t(61324),s=t(67111);const v=()=>e.createElement(e.Fragment,null,"History"),m=()=>e.createElement(e.Fragment,null,"Instances"),p=()=>e.createElement(e.Fragment,null,"Query results"),D=()=>e.createElement(e.Fragment,null,"Routing");var g=(r=>(r[r.Instances=0]="Instances",r[r.Query=1]="Query",r[r.Routing=2]="Routing",r[r.History=3]="History",r))(g||{});const P=({match:r})=>{const{id:l}=r.params,[i,y]=(0,e.useState)(0),f=(0,e.useMemo)(()=>{if(!l)throw new Error("Rule ID is required");return N.Qc(l,!0)},[l]),{loading:C,error:A,result:d}=(0,b.HO)({ruleIdentifier:f});if(Q(d),C)return e.createElement(S.u,{text:"Loading..."});if(A)return String(A);if(d){const j=d.annotations.summary,V=d.promRule,Y=(0,B.x_)(V)?V.alerts?.length:void 0,X=(0,B.Jq)(d.group),Z=(0,B.Pc)(d.rulerRule)&&!!d.rulerRule.grafana_alert.provenance;return e.createElement(e.Fragment,null,e.createElement(E.K,{direction:"column",gap:3},e.createElement(E.K,null,e.createElement(F,{folder:d.namespace.name,evaluationGroup:d.group.name}),e.createElement(s.L,null),e.createElement(E.K,{gap:1},e.createElement(R.zx,{variant:"secondary",icon:"pen"},"Edit"),e.createElement(R.zx,{variant:"secondary"},e.createElement(E.K,{alignItems:"center",gap:1},"More ",e.createElement(M.J,{name:"angle-down"}))))),e.createElement(E.K,{direction:"column",gap:1},e.createElement(E.K,{alignItems:"center"},e.createElement(W,{name:d.name,state:h.bj.Alerting})),j&&e.createElement(K,{text:j})),X&&e.createElement(G.b,{severity:"info",title:"This rule is part of a federated rule group."},e.createElement(E.K,{direction:"column"},"Federated rule groups are currently an experimental feature.",e.createElement(R.zx,{fill:"text",icon:"book"},e.createElement("a",{href:"https://grafana.com/docs/metrics-enterprise/latest/tenant-management/tenant-federation/#cross-tenant-alerting-and-recording-rule-federation"},"Read documentation")))),Z&&e.createElement(o.Xq,{resource:o.Uv.AlertRule}),e.createElement(c.J,null,e.createElement(U.O,{label:"Instances",active:!0,counter:Y,onChangeTab:()=>y(0)}),e.createElement(U.O,{label:"Query",onChangeTab:()=>y(1)}),e.createElement(U.O,{label:"Routing",onChangeTab:()=>y(2)}),e.createElement(U.O,{label:"History",onChangeTab:()=>y(3)})),e.createElement(T.I,null,i===0&&e.createElement(m,null),i===1&&e.createElement(p,null),i===2&&e.createElement(D,null),i===3&&e.createElement(v,null))))}return null},F=({folder:r,evaluationGroup:l})=>e.createElement(E.K,{alignItems:"center",gap:.5},e.createElement(u.x,{color:"secondary"},e.createElement(M.J,{name:"folder"})),e.createElement(u.x,{variant:"body",color:"primary"},r),e.createElement(u.x,{variant:"body",color:"secondary"},e.createElement(M.J,{name:"angle-right"})),e.createElement(u.x,{variant:"body",color:"primary"},l)),W=({name:r,state:l})=>e.createElement("header",null,e.createElement(E.K,{alignItems:"center",gap:1},e.createElement(n,{size:"md",state:l}),e.createElement(u.x,{element:"h1",variant:"h2",weight:"bold"},r))),K=({text:r})=>e.createElement(u.x,{variant:"body",color:"secondary"},r),L=P},75690:(z,O,t)=>{t.d(O,{F3:()=>Q,HO:()=>B,eq:()=>x});var e=t(39953),E=t(20653),S=t(57721),R=t(26516),M=t(14055),G=t(79493),c=t(95712),U=t(57675),T=t(30391),u=t(15032),h=t(52106),H=t(26544);function J(n,a){const o=b(a),s=useCombinedRuleNamespaces(a),v=useMemo(()=>{if(!n||!a||s.length===0)return[];const m=[];for(const p of s)for(const D of p.groups)for(const g of D.rules)g.name===n&&m.push(g);return m},[n,a,s]);return{...o,result:v}}function Q(n,a,o){const s=(0,c.c$)(a),{dsFeatures:v,isLoadingDsFeatures:m}=x(a),{currentData:p=[],isLoading:D,error:g}=R.alertRuleApi.endpoints.prometheusRuleNamespaces.useQuery({ruleSourceName:a,ruleName:n,namespace:o?.namespace,groupName:o?.groupName}),[P]=R.alertRuleApi.endpoints.rulerRuleGroup.useLazyQuery(),{loading:F,error:W,value:K}=(0,E.Z)(async()=>{if(!s)throw new Error("Unable to obtain data source settings");if(g)throw new Error("Unable to obtain Prometheus rules");const L=[];if(v?.rulerConfig){const i=v.rulerConfig,y=p.map(f=>f.groups.map(C=>({namespace:f,group:C}))).flat();await Promise.allSettled(y.map(async f=>{const C=await P({rulerConfig:i,namespace:f.namespace.name,group:f.group.name}).unwrap();L.push(C)}))}return p.map(i=>(0,h.K$)(s,i,L)).flatMap(i=>i.groups.flatMap(y=>y.rules))},[s,v,D,g,p,P]);return{loading:m||F,error:W,rules:K}}function b(n,a){const o=useDispatch(),s=useUnifiedAlertingSelector(g=>g.promRules),v=N(n,s),m=useUnifiedAlertingSelector(g=>g.rulerRules),p=N(n,m),{loading:D}=useAsync(async()=>{n&&await o(fetchPromAndRulerRulesAction({rulesSourceName:n,identifier:a}))},[o,n]);return{loading:D,error:v.error??isRulerNotSupportedResponse(p)?void 0:p.error,dispatched:v.dispatched&&p.dispatched}}function N(n,a){if(!n)return initialAsyncRequestState;const o=a[n];return o||initialAsyncRequestState}function B({ruleIdentifier:n}){const{ruleSourceName:a}=n,o=(0,c.c$)(a),{dsFeatures:s,isLoadingDsFeatures:v}=x(a),{currentData:m,isLoading:p,error:D}=R.alertRuleApi.endpoints.prometheusRuleNamespaces.useQuery({ruleSourceName:n.ruleSourceName,namespace:(0,u.qE)(n)||(0,u.E4)(n)?n.namespace:void 0,groupName:(0,u.qE)(n)||(0,u.E4)(n)?n.groupName:void 0,ruleName:(0,u.qE)(n)||(0,u.E4)(n)?n.ruleName:void 0}),[g,{currentData:P,isLoading:F,error:W}]=R.alertRuleApi.endpoints.rulerRuleGroup.useLazyQuery(),[K,{currentData:L,isLoading:r,error:l}]=R.alertRuleApi.endpoints.rulerRules.useLazyQuery();(0,e.useEffect)(()=>{s?.rulerConfig&&(s.rulerConfig&&(0,u.E4)(n)?g({rulerConfig:s.rulerConfig,namespace:n.namespace,group:n.groupName}):(0,u.Kl)(n)&&K({rulerConfig:s.rulerConfig}))},[s,g,K,n]);const i=(0,e.useMemo)(()=>{if(m){if((0,u.Kl)(n)){const y=(0,h.bU)("grafana",m,L);for(const f of y)for(const C of f.groups)for(const A of C.rules){const d=T.Yd(a,A);if(T.Dg(d,n))return A}}if(o&&m.length>0&&((0,u.E4)(n)||(0,u.qE)(n))){const y=m.map(f=>(0,h.K$)(o,f,P?[P]:[]));for(const f of y)for(const C of f.groups)for(const A of C.rules){const d=T.Yd(a,A);if(T.Dg(d,n))return A}}}},[n,a,m,P,L,o]);return{loading:v||p||F||r,error:D??W??l,result:i}}const I={rulerConfig:{dataSourceName:c.GC,apiVersion:"legacy"}};function x(n){const a=(0,c.HY)(n),{currentData:o,isLoading:s}=M.T.endpoints.discoverDsFeatures.useQuery({rulesSourceName:n},{skip:a});return a?{isLoadingDsFeatures:!1,dsFeatures:I}:{isLoadingDsFeatures:s,dsFeatures:o}}}}]);

//# sourceMappingURL=689.60c9e60594ee9b4f0e55.js.map