"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4380],{46911:(V,x,a)=>{a.d(x,{g:()=>$});var d=a(66681),e=a(85960),h=a(47257),E=a(40377),v=a(13086),p=a(97666);const $=({children:O,icon:D,color:m="secondary",direction:N="row",...K})=>{const P=(0,h.wW)(S),C=typeof K.onClick=="function",c=N==="row",i=c?"center":"flex-start",R=c?.5:0;return e.createElement("div",{className:(0,d.cx)({[P.interactive]:C}),...K},e.createElement(E.x,{variant:"bodySmall",color:m},e.createElement(v.K,{direction:N,alignItems:i,gap:R,wrap:"wrap"},D&&e.createElement(p.J,{size:"sm",name:D}),O)))},S=()=>({interactive:(0,d.css)`
    cursor: pointer;
  `})},59787:(V,x,a)=>{a.d(x,{Z:()=>p});var d=a(85960),e=a(29165),h=a(13086),E=a(97666);const p=(0,d.forwardRef)(function(S,O){return d.createElement(e.zx,{variant:"secondary",size:"sm",type:"button","aria-label":"more-actions","data-testid":"more-actions",ref:O,...S},d.createElement(h.K,{direction:"row",alignItems:"center",gap:0},"More ",d.createElement(E.J,{name:"angle-down"})))})},44380:(V,x,a)=>{a.r(x),a.d(x,{EditButton:()=>ne,Title:()=>re,createListFilterLink:()=>_,default:()=>Se});var d=a(56375),e=a(85960),h=a(47475),E=a(44839),v=a(54635),p=a(13086),$=a(49199),S=a(29165),O=a(10305),D=a(79055),m=a(40377),N=a(49683),K=a(763),P=a(25119),C=a(73632),c=a(57297),i=a(46002),R=a(77294),F=a(60956),u=a(9001),Q=a(87873),T=a(2698),L=a(66681),A=a(47257);const Z=t=>{const n=(0,A.wW)(b,t);return e.createElement(p.K,{direction:"row",gap:.5},e.createElement("div",{className:n.dot}))},b=(t,n)=>{const r=t.spacing(1.25),o=`calc(${r} / 2.5)`;return{dot:(0,L.css)`
      width: ${r};
      height: ${r};

      border-radius: 100%;

      background-color: ${t.colors.secondary.main};
      outline: solid ${o} ${t.colors.secondary.transparent};
      margin: ${o};

      ${n.state===P.x_.Inactive&&(0,L.css)`
        background-color: ${t.colors.success.main};
        outline-color: ${t.colors.success.transparent};
      `}

      ${n.state===P.x_.Pending&&(0,L.css)`
        background-color: ${t.colors.warning.main};
        outline-color: ${t.colors.warning.transparent};
      `}

      ${n.state===P.x_.Firing&&(0,L.css)`
        background-color: ${t.colors.error.main};
        outline-color: ${t.colors.error.transparent};
      `}
    `}};var j=a(65892),M=a(59787),z=a(84237),U=a(23386),J=a(57582),B=a(55855),I=a(46911),g=a(13202),w=(t=>(t.GrafanaManagedAlertRule="Grafana-managed alert rule",t.CloudAlertRule="Cloud alert rule",t.CloudRecordingRule="Cloud recording rule",t))(w||{});const X=({rule:t})=>{const n=(0,A.wW)(q);let r;(0,u.Pc)(t.rulerRule)?r="Grafana-managed alert rule":(0,u.yF)(t.rulerRule)?r="Cloud recording rule":r="Cloud alert rule";const o=t.promRule?.evaluationTime,s=t.promRule?.lastEvaluation,f=(0,e.useCallback)(()=>(0,u.Pc)(t.rulerRule)?t.rulerRule.grafana_alert.uid:"",[t.rulerRule]),l=(0,u.yF)(t.rulerRule)?void 0:t.annotations??[];return e.createElement(p.K,{direction:"column",gap:3},e.createElement("div",{className:n.metadataWrapper},e.createElement(I.g,{direction:"column"},"Rule type",e.createElement(m.x,{color:"primary"},r)),e.createElement(I.g,{direction:"column"},(0,u.Pc)(t.rulerRule)&&e.createElement(e.Fragment,null,"Rule Identifier",e.createElement(p.K,{direction:"row",alignItems:"center",gap:.5},e.createElement(m.x,{color:"primary"},t.rulerRule.grafana_alert.uid,e.createElement(B.m,{fill:"text",variant:"secondary",icon:"copy",size:"sm",getText:f}))))),e.createElement(I.g,{direction:"column"},o&&e.createElement(e.Fragment,null,"Last evaluation",s&&o&&e.createElement("span",null,e.createElement(m.x,{color:"primary"},(0,J.Z)(new Date(s))," ago"),", took"," ",e.createElement(m.x,{color:"primary"},o,"ms")))),e.createElement(I.g,{direction:"column"},!(0,u.yF)(t.rulerRule)&&e.createElement(e.Fragment,null,"Pending period",e.createElement(m.x,{color:"primary"},t.rulerRule?.for??"0s"))),(0,u.Pc)(t.rulerRule)&&e.createElement(e.Fragment,null,e.createElement(I.g,{direction:"column"},"Alert state if no data or all values are null",e.createElement(m.x,{color:"primary"},t.rulerRule.grafana_alert.no_data_state)),e.createElement(I.g,{direction:"column"},"Alert state if execution error or timeout",e.createElement(m.x,{color:"primary"},t.rulerRule.grafana_alert.exec_err_state)))),l&&e.createElement(e.Fragment,null,e.createElement(m.x,{variant:"h4"},"Annotations"),Object.keys(l).length===0?e.createElement(m.x,{variant:"bodySmall",color:"secondary",italic:!0},"No annotations"):e.createElement("div",{className:n.metadataWrapper},Object.entries(l).map(([y,H])=>e.createElement(I.g,{direction:"column",key:y},y,e.createElement(k,{value:H}))))))};function k({value:t}){const n=t&&t.startsWith("http"),r=e.createElement(g.Z,{input:t,delimiter:["{{","}}"]});return n?e.createElement(D.h,{variant:"bodySmall",href:t,external:!0},t):e.createElement(m.x,{color:"primary"},r)}const q=t=>({metadataWrapper:(0,L.css)({display:"grid",gridTemplateColumns:"auto auto",rowGap:t.spacing(3),columnGap:t.spacing(12)})});var Y=a(90857),W=a(19721);const le=(0,e.lazy)(()=>a.e(990).then(a.bind(a,60990))),se=(0,e.lazy)(()=>a.e(2113).then(a.bind(a,97303))),ie=({rule:t})=>{const n=Y.config.unifiedAlerting.alertStateHistoryBackend,r=Y.config.unifiedAlerting.alertStateHistoryPrimary,s=[n,r].some(y=>y===W.N.Loki)?W.N.Loki:W.N.Annotations,f=t.grafana_alert.id??"",l=t.grafana_alert.uid;return e.createElement(e.Suspense,{fallback:"Loading..."},s===W.N.Loki&&e.createElement(se,{ruleUID:l}),s===W.N.Annotations&&e.createElement(le,{alertId:f}))};var ce=a(89248),me=a(3438);const de=({rule:t})=>e.createElement(me.M,{rule:t,pagination:{itemsPerPage:ce.gN},enableFiltering:!0});var ue=a(14405);const ve=()=>e.createElement(e.Fragment,null,"Routing");var ge=a(77980),Ee=a(59767),fe=a(5970),ye=a(76679);const he=()=>{const[t,n]=(0,e.useState)(),r=(0,e.useCallback)(()=>{n(void 0)},[]),o=(0,e.useCallback)(l=>{n(l)},[]),s=(0,e.useCallback)(l=>{if(l&&l.rulerRule){const y=(0,F.Zk)((0,ye.EG)(l.namespace.rulesSource),l.namespace.name,l.group.name,l.rulerRule);(0,Ee.WI)((0,fe.hS)(y,{navigateTo:"/alerting/list"})),r()}},[r]);return[(0,e.useMemo)(()=>e.createElement(ge.s,{isOpen:!!t,title:"Delete rule",body:"Deleting this rule will permanently remove it from your alert rule list. Are you sure you want to delete this rule?",confirmText:"Yes, delete",icon:"exclamation-triangle",onConfirm:()=>s(t),onDismiss:r}),[s,r,t]),o,r]};var ae=(t=>(t.Query="query",t.Instances="instances",t.History="history",t.Routing="routing",t.Details="details",t))(ae||{});const pe=({rule:t,identifier:n})=>{const{pageNav:r,activeTab:o}=Ie(t),[s,f]=he(),[l,y]=(0,c.wp)(t,c.iY.Update),H=l&&y,[ee,te]=(0,c.wp)(t,c.iY.Delete),G=ee&&te,[Pe,Te]=(0,c.wp)(t,c.iY.Duplicate),Ae=Pe&&Te,[Ce,Le]=(0,c.wp)(t,c.iY.Silence),Oe=Ce&&Le,[Ne,Ue]=(0,c.wp)(t,c.iY.ModifyExport),Be=Ne&&Ue,oe=t.promRule,We=(0,u.x_)(oe),$e=(0,u.Jq)(t.group),Ke=(0,u.Pc)(t.rulerRule)&&!!t.rulerRule.grafana_alert.provenance,Fe=!(0,R.Vj)()||(0,R.mt)(),Ze=(0,R.t6)(t.namespace.rulesSource,t),be=()=>{navigator.clipboard&&(navigator.clipboard.writeText(Ze),N.h$.emit(h.SI.alertSuccess,["URL copied to clipboard"]))};return e.createElement(j.J,{pageNav:r,navId:"alert-list",isLoading:!1,renderTitle:ze=>e.createElement(re,{name:ze,state:We?oe.state:void 0}),actions:[H&&e.createElement(ne,{key:"edit-action",identifier:n}),e.createElement(E.L,{key:"more-actions",overlay:e.createElement(v.v,null,Oe&&e.createElement(v.v.Item,{label:"Silence",icon:"bell-slash",url:(0,R.Vv)(n.ruleSourceName,t)}),Fe&&e.createElement(U.N,{title:t.name,url:""}),Ae&&e.createElement(v.v.Item,{label:"Duplicate",icon:"copy"}),e.createElement(v.v.Divider,null),e.createElement(v.v.Item,{label:"Copy link",icon:"share-alt",onClick:be}),Be&&e.createElement(v.v.Item,{label:"Export",icon:"download-alt",childItems:[e.createElement(v.v.Item,{key:"no-modifications",label:"Without modifications",icon:"file-blank"}),e.createElement(v.v.Item,{key:"with-modifications",label:"With modifications",icon:"file-alt"})]}),G&&e.createElement(e.Fragment,null,e.createElement(v.v.Divider,null),e.createElement(v.v.Item,{label:"Delete",icon:"trash-alt",destructive:!0,onClick:()=>f(t)})))},e.createElement(M.Z,{size:"md"}))],info:xe(t)},e.createElement(p.K,{direction:"column",gap:2},e.createElement(p.K,{direction:"column",gap:2},$e&&e.createElement($.b,{severity:"info",title:"This rule is part of a federated rule group."},e.createElement(p.K,{direction:"column"},"Federated rule groups are currently an experimental feature.",e.createElement(S.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")))),Ke&&e.createElement(z.Xq,{resource:z.Uv.AlertRule}),e.createElement(O.I,null,o==="query"&&e.createElement(ue.a,{rule:t}),o==="instances"&&e.createElement(de,{rule:t}),o==="history"&&(0,u.Pc)(t.rulerRule)&&e.createElement(ie,{rule:t.rulerRule}),o==="routing"&&e.createElement(ve,null),o==="details"&&e.createElement(X,{rule:t})))),s)},ne=({identifier:t})=>{const n=location.pathname+location.search,r=F.$V(t),o=(0,Q.u)(`/alerting/${encodeURIComponent(r)}/edit`,{returnTo:n});return e.createElement(S.Qj,{variant:"secondary",icon:"pen",href:o},"Edit")},xe=t=>{const{labels:n,annotations:r,group:o}=t,s=[],f=r[i.q6.runbookURL],l=r[i.q6.dashboardUID],y=r[i.q6.panelID],H=l&&y,ee=l&&!y,te=!(0,d.isEmpty)(n),G=o.interval;return f&&s.push({label:"Runbook",value:e.createElement(D.h,{variant:"bodySmall",href:f,external:!0},(0,d.truncate)(f,{length:42}))}),H?s.push({label:"Dashboard and panel",value:e.createElement(D.h,{variant:"bodySmall",href:(0,R.yM)(l,y),external:!0},"View panel")}):ee&&s.push({label:"Dashboard",value:e.createElement(D.h,{variant:"bodySmall",href:(0,R.RQ)(l),external:!0},"View dashboard")}),G&&s.push({label:"Evaluation interval",value:e.createElement(m.x,{color:"primary"},"Every ",G)}),te&&s.push({label:"Labels",value:e.createElement(T.s,{labels:n,size:"sm"})}),s},_=t=>{const n=new URLSearchParams([["search",t.map(([r,o])=>`${r}:"${o}"`).join(" ")]]);return(0,Q.u)("/alerting/list?"+n.toString())},re=({name:t,state:n})=>e.createElement("div",{style:{display:"flex",alignItems:"center",gap:8,maxWidth:"100%"}},e.createElement(S.Qj,{variant:"secondary",icon:"angle-left",href:"/alerting/list"}),e.createElement(m.x,{element:"h1",truncate:!0},t),n&&e.createElement(De,{state:n})),De=({state:t})=>{let n,r;switch(t){case P.x_.Inactive:r="success",n="Normal";break;case P.x_.Firing:r="error",n="Firing";break;case P.x_.Pending:r="warning",n="Pending";break}return e.createElement(p.K,{direction:"row",gap:.5},e.createElement(Z,{size:"md",state:t}),e.createElement(m.x,{variant:"bodySmall",color:r},n))};function Re(){const[t,n]=(0,K.K)(),r=t.tab;return[Me(r)?r:"query",f=>{n({tab:f})}]}function Me(t){return typeof t=="string"&&Object.values(ae).includes(t)}function Ie(t){const[n,r]=Re(),{annotations:o,promRule:s}=t,f=o[i.q6.summary],y=(0,u.x_)(s)?(s.alerts??[]).length:void 0;return{pageNav:{...C.defaultPageNav,text:t.name,subTitle:f,children:[{text:"Query and conditions",active:n==="query",onClick:()=>{r("query")}},{text:"Instances",active:n==="instances",onClick:()=>{r("instances")},tabCounter:y},{text:"History",active:n==="history",onClick:()=>{r("history")}},{text:"Details",active:n==="details",onClick:()=>{r("details")}}],parentItem:{text:t.group.name,url:_([["namespace",t.namespace.name],["group",t.group.name]]),parentItem:{text:t.namespace.name,url:_([["namespace",t.namespace.name]])}}},activeTab:n}}const Se=pe},87474:(V,x,a)=>{a.d(x,{Z:()=>d});function d(e,h){if(e==null)throw new TypeError("assign requires that input parameter not be null or undefined");for(var E in h)Object.prototype.hasOwnProperty.call(h,E)&&(e[E]=h[E]);return e}},37166:(V,x,a)=>{a.d(x,{Z:()=>e});var d=a(87474);function e(h){return(0,d.Z)({},h)}},57582:(V,x,a)=>{a.d(x,{Z:()=>P});var d=a(91671),e=a(89933),h=a(22799),E=a(78321),v=a(37166),p=a(87474),$=a(75847),S=a(12173),O=1e3*60,D=60*24,m=D*30,N=D*365;function K(C,c,i){var R,F,u;(0,S.Z)(2,arguments);var Q=(0,d.j)(),T=(R=(F=i?.locale)!==null&&F!==void 0?F:Q.locale)!==null&&R!==void 0?R:$.Z;if(!T.formatDistance)throw new RangeError("locale must contain localize.formatDistance property");var L=(0,h.Z)(C,c);if(isNaN(L))throw new RangeError("Invalid time value");var A=(0,p.Z)((0,v.Z)(i),{addSuffix:!!i?.addSuffix,comparison:L}),Z,b;L>0?(Z=(0,E.Z)(c),b=(0,E.Z)(C)):(Z=(0,E.Z)(C),b=(0,E.Z)(c));var j=String((u=i?.roundingMethod)!==null&&u!==void 0?u:"round"),M;if(j==="floor")M=Math.floor;else if(j==="ceil")M=Math.ceil;else if(j==="round")M=Math.round;else throw new RangeError("roundingMethod must be 'floor', 'ceil' or 'round'");var z=b.getTime()-Z.getTime(),U=z/O,J=(0,e.Z)(b)-(0,e.Z)(Z),B=(z-J)/O,I=i?.unit,g;if(I?g=String(I):U<1?g="second":U<60?g="minute":U<D?g="hour":B<m?g="day":B<N?g="month":g="year",g==="second"){var w=M(z/1e3);return T.formatDistance("xSeconds",w,A)}else if(g==="minute"){var X=M(U);return T.formatDistance("xMinutes",X,A)}else if(g==="hour"){var k=M(U/60);return T.formatDistance("xHours",k,A)}else if(g==="day"){var q=M(B/D);return T.formatDistance("xDays",q,A)}else if(g==="month"){var Y=M(B/m);return Y===12&&I!=="month"?T.formatDistance("xYears",1,A):T.formatDistance("xMonths",Y,A)}else if(g==="year"){var W=M(B/N);return T.formatDistance("xYears",W,A)}throw new RangeError("unit must be 'second', 'minute', 'hour', 'day', 'month' or 'year'")}function P(C,c){return(0,S.Z)(1,arguments),K(C,Date.now(),c)}}}]);

//# sourceMappingURL=4380.a7c8846ad6b96ab58d1d.js.map