"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[1783],{75429:(W,S,a)=>{a.d(S,{x:()=>C});var e=a(27702),p=a(18771),v=a(92071);function C(A){const x=(0,p.useDispatch)(),D=(0,e.useRef)(A);D.current=A,(0,e.useEffect)(()=>()=>{x((0,v.e)({cleanupAction:D.current}))},[x])}},68836:(W,S,a)=>{a.r(S),a.d(S,{default:()=>St});var e=a(27702),p=a(7662),v=a(63439),C=a(37647),A=a(18771),x=a(37194),D=a(81324),L=a(80118),r=a(42844),b=a(89949),P=a(46089),K=a(29956),y=a(32082),Z=a(8508),$=a(99633),z=a(34667),T=a(66310),he=a(5229),R=a(22209),F=a(1128),pe=a(60105),U=a(66670),Ae=a(75429),B=a(62862),ye=a(79003),X=a(10027),G=a(47702),O=a(76658),Se=a(32925),N=a(39036),k=a(84369),xe=a(16310),Ce=a(28580),De=a(67437);const Pe=({className:t})=>{const n=(0,T.wW)(Me),s=(0,P.Gc)(),{control:c,register:o,formState:{errors:m}}=s,{fields:l=[],append:u,remove:i}=(0,P.Dq)({name:"matchers"});return e.createElement("div",{className:(0,r.cx)(t,n.wrapper)},e.createElement(R.g,{label:"Matching labels",required:!0},e.createElement("div",null,e.createElement("div",{className:n.matchers},l.map((g,d)=>e.createElement("div",{className:n.row,key:`${g.id}`,"data-testid":"matcher"},e.createElement(R.g,{label:"Label",invalid:!!m?.matchers?.[d]?.name,error:m?.matchers?.[d]?.name?.message},e.createElement(F.I,{...o(`matchers.${d}.name`,{required:{value:!0,message:"Required."}}),defaultValue:g.name,placeholder:"label"})),e.createElement(R.g,{label:"Operator"},e.createElement(xe.g,{control:c,render:({field:{onChange:f,ref:h,...E}})=>e.createElement(Ce.Ph,{...E,onChange:M=>f(M.value),className:n.matcherOptions,options:O.tA,"aria-label":"operator"}),defaultValue:g.operator||O.tA[0].value,name:`matchers.${d}.operator`,rules:{required:{value:!0,message:"Required."}}})),e.createElement(R.g,{label:"Value",invalid:!!m?.matchers?.[d]?.value,error:m?.matchers?.[d]?.value?.message},e.createElement(F.I,{...o(`matchers.${d}.value`,{required:{value:!0,message:"Required."}}),defaultValue:g.value,placeholder:"value"})),l.length>1&&e.createElement(De.h,{className:n.removeButton,tooltip:"Remove matcher",name:"trash-alt",onClick:()=>i(d)},"Remove")))),e.createElement(U.zx,{type:"button",icon:"plus",variant:"secondary",onClick:()=>{const g={name:"",value:"",operator:B._M.equal};u(g)}},"Add matcher"))))},Me=t=>({wrapper:(0,r.css)`
      margin-top: ${t.spacing(2)};
    `,row:(0,r.css)`
      display: flex;
      align-items: flex-start;
      flex-direction: row;
      background-color: ${t.colors.background.secondary};
      padding: ${t.spacing(1)} ${t.spacing(1)} 0 ${t.spacing(1)};
      & > * + * {
        margin-left: ${t.spacing(2)};
      }
    `,removeButton:(0,r.css)`
      margin-left: ${t.spacing(1)};
      margin-top: ${t.spacing(2.5)};
    `,matcherOptions:(0,r.css)`
      min-width: 140px;
    `,matchers:(0,r.css)`
      max-width: ${t.breakpoints.values.sm}px;
      margin: ${t.spacing(1)} 0;
      padding-top: ${t.spacing(.5)};
    `}),Te=Pe;var Ie=a(95059);const be=()=>{const{control:t,getValues:n}=(0,P.Gc)(),{field:{onChange:s,value:c},fieldState:{invalid:o}}=(0,P.bc)({name:"startsAt",control:t,rules:{validate:E=>n().endsAt>E}}),{field:{onChange:m,value:l},fieldState:{invalid:u}}=(0,P.bc)({name:"endsAt",control:t,rules:{validate:E=>n().startsAt<E}}),{field:{onChange:i,value:g}}=(0,P.bc)({name:"timeZone",control:t}),d=o||u,f=(0,$.CQ)(c),h=(0,$.CQ)(l);return e.createElement(R.g,{className:Oe.timeRange,label:"Silence start and end",error:d?"To is before or the same as from":"",invalid:d},e.createElement(Ie.K,{value:{from:f,to:h,raw:{from:f,to:h}},timeZone:g,onChange:E=>{s((0,$.CQ)(E.from)),m((0,$.CQ)(E.to))},onChangeTimeZone:E=>i(E),hideTimeZone:!1,hideQuickRanges:!0,placeholder:"Select time range"}))},Oe={timeRange:(0,r.css)`
    width: 400px;
  `};var Re=a(25357),$e=a(52419),Be=a(52646),Ne=a(447),ae=a(8254),ne=a(45986),se=a(22201);const We=({amSourceName:t,matchers:n})=>{const{useGetAlertmanagerAlertsQuery:s}=Be.alertmanagerApi,c=(0,T.wW)(re),o=Le(),m=n.some(d=>d.value&&d.name),{currentData:l=[],isFetching:u,isError:i}=s({amSourceName:t,filter:{matchers:n}},{skip:!m,refetchOnMountOrArgChange:!0}),g=l.map(d=>({id:d.fingerprint,data:d}));return e.createElement("div",null,e.createElement("h4",{className:c.title},"Affected alert instances",g.length>0?e.createElement(Re.C,{className:c.badge,color:"blue",text:g.length}):null),!m&&e.createElement("span",null,"Add a valid matcher to see affected alerts"),i&&e.createElement(v.b,{title:"Preview not available",severity:"error"},"Error occured when generating affected alerts preview. Are you matchers valid?"),u&&e.createElement($e.u,{text:"Loading..."}),!u&&!i&&m&&e.createElement("div",{className:c.table},g.length>0?e.createElement(ne.t,{items:g,isExpandable:!1,cols:o,pagination:{itemsPerPage:10}}):e.createElement("span",null,"No matching alert instances found")))};function Le(){const t=(0,T.wW)(re);return[{id:"state",label:"State",renderCell:function({data:s}){return e.createElement(se.G,{state:s.status.state})},size:"120px",className:t.stateColumn},{id:"labels",label:"Labels",renderCell:function({data:s}){return e.createElement(ae.s,{labels:s.labels,size:"sm"})},size:"auto"},{id:"created",label:"Created",renderCell:function({data:s}){return e.createElement(e.Fragment,null,(0,Ne.gV)(s.startsAt)?"-":(0,$.CQ)(s.startsAt).format("YYYY-MM-DD HH:mm:ss"))},size:"180px"}]}const re=t=>({table:(0,r.css)`
    max-width: ${t.breakpoints.values.lg}px;
  `,moreMatches:(0,r.css)`
    margin-top: ${t.spacing(1)};
  `,title:(0,r.css)`
    display: flex;
    align-items: center;
  `,badge:(0,r.css)`
    margin-left: ${t.spacing(1)};
  `,stateColumn:(0,r.css)`
    display: flex;
    align-items: center;
  `}),Ke=t=>{const n={},s=t.get("comment"),c=t.getAll("matcher"),o=(0,Se.RT)(c);return o.length&&(n.matchers=o.map(O.cm)),s&&(n.comment=s),n},Ue=(t,n)=>{const s=new Date;if(n){const o=Date.parse(n.endsAt)<Date.now()?{start:s,end:(0,y.Ks)(s,{hours:2})}:{start:new Date(n.startsAt),end:new Date(n.endsAt)};return{id:n.id,startsAt:o.start.toISOString(),endsAt:o.end.toISOString(),comment:n.comment,createdBy:n.createdBy,duration:(0,y.vT)(o),isRegex:!1,matchers:n.matchers?.map(O.cm)||[],matcherName:"",matcherValue:"",timeZone:Z.Ys}}else{const c=(0,y.Ks)(s,{hours:2});return{id:"",startsAt:s.toISOString(),endsAt:c.toISOString(),comment:`created ${(0,$.CQ)().format("YYYY-MM-DD HH:mm")}`,createdBy:z.config.bootData.user.name,duration:"2h",isRegex:!1,matchers:[{name:"",value:"",operator:B._M.equal}],matcherName:"",matcherValue:"",timeZone:Z.Ys,...Ke(t)}}},ze=({silence:t,alertManagerSourceName:n})=>{const[s]=(0,ye.j)(),c=(0,e.useMemo)(()=>Ue(s,t),[t,s]),o=(0,P.cI)({defaultValues:c}),m=(0,A.useDispatch)(),l=(0,T.wW)(Fe),[u,i]=(0,e.useState)(c.matchers.map(O._J)),{loading:g}=(0,X._)(I=>I.updateSilence);(0,Ae.x)(I=>I.unifiedAlerting.updateSilence=k.oq);const{register:d,handleSubmit:f,formState:h,watch:E,setValue:M,clearErrors:xt}=o,Ct=I=>{const{id:V,startsAt:J,endsAt:Pt,comment:Mt,createdBy:Tt,matchers:It}=I,bt=It.map(O._J),fe=(0,b.pickBy)({id:V,startsAt:J,endsAt:Pt,comment:Mt,createdBy:Tt,matchers:bt},Ot=>!!Ot);m((0,G.QY)({alertManagerSourceName:n,payload:fe,exitOnSave:!0,successMessage:`Silence ${fe.id?"updated":"created"}`}))},w=E("duration"),Y=E("startsAt"),j=E("endsAt"),ge=E("matchers"),[Ee,ve]=(0,e.useState)(w);(0,K.Z)(()=>{if((0,y.qb)(Y)&&(0,y.qb)(j))if(w!==Ee)M("endsAt",(0,$.CQ)((0,y.Ks)(new Date(Y),(0,y.RA)(w))).toISOString()),ve(w);else{const I=new Date(Y).valueOf();if(new Date(j).valueOf()>I){const J=(0,y.vT)({start:new Date(Y),end:new Date(j)});M("duration",J),ve(J)}}},700,[xt,w,j,Ee,M,Y]),(0,K.Z)(()=>{const I=ge.filter(V=>V.name&&V.value).map(O._J);(0,b.isEqual)(u,I)||i(I)},700,[ge]);const Dt=!!(z.config.bootData.user.isSignedIn&&z.config.bootData.user.name);return e.createElement(P.RV,{...o},e.createElement("form",{onSubmit:f(Ct)},e.createElement(he.C,{label:`${t?"Recreate silence":"Create silence"}`},e.createElement("div",{className:(0,r.cx)(l.flexRow,l.silencePeriod)},e.createElement(be,null),e.createElement(R.g,{label:"Duration",invalid:!!h.errors.duration,error:h.errors.duration&&(h.errors.duration.type==="required"?"Required field":h.errors.duration.message)},e.createElement(F.I,{className:l.createdBy,...d("duration",{validate:I=>Object.keys((0,y.RA)(I)).length===0?"Invalid duration. Valid example: 1d 4h (Available units: y, M, w, d, h, m, s)":void 0}),id:"duration"}))),e.createElement(Te,null),e.createElement(R.g,{className:(0,r.cx)(l.field,l.textArea),label:"Comment",required:!0,error:h.errors.comment?.message,invalid:!!h.errors.comment},e.createElement(pe.K,{...d("comment",{required:{value:!0,message:"Required."}}),rows:5,placeholder:"Details about the silence"})),!Dt&&e.createElement(R.g,{className:(0,r.cx)(l.field,l.createdBy),label:"Created By",required:!0,error:h.errors.createdBy?.message,invalid:!!h.errors.createdBy},e.createElement(F.I,{...d("createdBy",{required:{value:!0,message:"Required."}}),placeholder:"Who's creating the silence"})),e.createElement(We,{amSourceName:n,matchers:u})),e.createElement("div",{className:l.flexRow},g&&e.createElement(U.zx,{disabled:!0,icon:"fa fa-spinner",variant:"primary"},"Saving..."),!g&&e.createElement(U.zx,{type:"submit"},"Save silence"),e.createElement(U.Qj,{href:(0,N.eQ)("alerting/silences",n),variant:"secondary"},"Cancel"))))},Fe=t=>({field:(0,r.css)`
    margin: ${t.spacing(1,0)};
  `,textArea:(0,r.css)`
    max-width: ${t.breakpoints.values.sm}px;
  `,createdBy:(0,r.css)`
    width: 200px;
  `,flexRow:(0,r.css)`
    display: flex;
    flex-direction: row;
    justify-content: flex-start;

    & > * {
      margin-right: ${t.spacing(1)};
    }
  `,silencePeriod:(0,r.css)`
    max-width: ${t.breakpoints.values.sm}px;
  `}),le=ze;var H=a(1726),q=a(23852),Qe=a(62499),_=a(73453),we=a(9848),ee=a(89033),Q=a(91368),te=a(2082),Ye=a(89439);const ce=({className:t,...n})=>{const s=(0,T.wW)(Ve);return e.createElement(U.zx,{variant:"secondary",size:"xs",className:(0,r.cx)(s.wrapper,t),...n})},Ve=t=>({wrapper:(0,r.css)`
    height: 24px;
    font-size: ${t.typography.bodySmall.fontSize};
  `});var Ze=a(18686),Ge=a(86004);const He=({matchers:t})=>{const n=(0,T.wW)(je);return e.createElement("div",null,e.createElement(Ge.P,{className:n.tags,tags:t.map(s=>`${s.name}${(0,O.zy)(s)}${s.value}`)}))},je=()=>({tags:(0,r.css)`
    justify-content: flex-start;
  `});var Je=a(60801),Xe=a(66970);const ke=({alertManagerSourceName:t})=>{const n=(0,te.QX)(t);return Q.contextSrv.hasAccess(n.create,Q.contextSrv.isEditor)?e.createElement(Xe.Z,{title:"You haven't created any silences yet",buttonIcon:"bell-slash",buttonLink:(0,N.eQ)("alerting/silence/new",t),buttonTitle:"Create silence"}):e.createElement(Je._,{callToActionElement:e.createElement("div",null),message:"No silences found."})};var qe=a(38338),_e=a(10759);const et=({alert:t,className:n})=>{const[s,c]=(0,e.useState)(!0),o=(0,y.vT)({start:new Date(t.startsAt),end:new Date(t.endsAt)}),m=Object.entries(t.labels).reduce((l,[u,i])=>((u==="alertname"||u==="__alert_rule_title__")&&(l=i),l),"");return e.createElement(e.Fragment,null,e.createElement("tr",{className:n},e.createElement("td",null,e.createElement(_e.U,{isCollapsed:s,onToggle:l=>c(l)})),e.createElement("td",null,e.createElement(se.G,{state:t.status.state})),e.createElement("td",null,"for ",o," seconds"),e.createElement("td",null,m)),!s&&e.createElement("tr",{className:n},e.createElement("td",null),e.createElement("td",{colSpan:5},e.createElement(ae.s,{labels:t.labels,size:"sm"}))))},tt=({silencedAlerts:t})=>{const n=(0,T.wW)(qe.D),s=(0,T.wW)(at);return t.length?e.createElement("table",{className:(0,r.cx)(n.table,s.tableMargin)},e.createElement("colgroup",null,e.createElement("col",{className:n.colExpand}),e.createElement("col",{className:s.colState}),e.createElement("col",null),e.createElement("col",{className:s.colName})),e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null),e.createElement("th",null,"State"),e.createElement("th",null),e.createElement("th",null,"Alert name"))),e.createElement("tbody",null,t.map((c,o)=>e.createElement(et,{key:c.fingerprint,alert:c,className:o%2===0?n.evenRow:""})))):null},at=t=>({tableMargin:(0,r.css)`
    margin-bottom: ${t.spacing(1)};
  `,colState:(0,r.css)`
    width: 110px;
  `,colName:(0,r.css)`
    width: 65%;
  `}),nt=tt,st=({silence:t})=>{const{startsAt:n,endsAt:s,comment:c,createdBy:o,silencedAlerts:m}=t,l=(0,T.wW)(rt),u="YYYY-MM-DD HH:mm",i=H.parse(n),g=H.parse(s),d=(0,y.vT)({start:new Date(n),end:new Date(s)});return e.createElement("div",{className:l.container},e.createElement("div",{className:l.title},"Comment"),e.createElement("div",null,c),e.createElement("div",{className:l.title},"Schedule"),e.createElement("div",null,`${i?.format(u)} - ${g?.format(u)}`),e.createElement("div",{className:l.title},"Duration"),e.createElement("div",null," ",d),e.createElement("div",{className:l.title},"Created by"),e.createElement("div",null," ",o),e.createElement("div",{className:l.title},"Affected alerts"),e.createElement(nt,{silencedAlerts:m}))},rt=t=>({container:(0,r.css)`
    display: grid;
    grid-template-columns: 1fr 9fr;
    grid-row-gap: 1rem;
  `,title:(0,r.css)`
    color: ${t.colors.text.primary};
  `,row:(0,r.css)`
    margin: ${t.spacing(1,0)};
  `});var lt=a(6949);const ct={[B.As.Active]:"good",[B.As.Expired]:"neutral",[B.As.Pending]:"neutral"},ot=({state:t})=>e.createElement(lt.i,{state:ct[t]},t);var it=a(79978),dt=a(80011);const oe=()=>(0,b.uniqueId)("query-string-"),mt=()=>{const[t,n]=(0,e.useState)(oe()),[s,c]=(0,ee.K)(),{queryString:o}=(0,N.pF)(s),m=(0,T.wW)(ut),l=(0,b.debounce)(g=>{const d=g.target;c({queryString:d.value||null})},400),u=()=>{c({queryString:null,silenceState:null}),setTimeout(()=>n(oe()))},i=o&&o.length>3?(0,O.Zh)(o).length===0:!1;return e.createElement("div",{className:m.flexRow},e.createElement(R.g,{className:m.rowChild,label:e.createElement(it._,null,e.createElement(q.K,{gap:.5},e.createElement("span",null,"Search by matchers"),e.createElement(dt.u,{content:e.createElement("div",null,"Filter silences by matchers using a comma separated list of matchers, ie:",e.createElement("pre",null,"severity=critical, instance=~cluster-us-.+"))},e.createElement(_.J,{name:"info-circle",size:"sm"})))),invalid:i,error:i?"Query must use valid matcher syntax":null},e.createElement(F.I,{key:t,className:m.searchInput,prefix:e.createElement(_.J,{name:"search"}),onChange:l,defaultValue:o??"",placeholder:"Search","data-testid":"search-query-input"})),o&&e.createElement("div",{className:m.rowChild},e.createElement(U.zx,{variant:"secondary",icon:"times",onClick:u},"Clear filters")))},ut=t=>({searchInput:(0,r.css)`
    width: 360px;
  `,flexRow:(0,r.css)`
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    padding-bottom: ${t.spacing(3)};
    border-bottom: 1px solid ${t.colors.border.medium};
  `,rowChild:(0,r.css)`
    margin-right: ${t.spacing(1)};
    margin-bottom: 0;
    max-height: 52px;
  `,fieldLabel:(0,r.css)`
    font-size: 12px;
    font-weight: 500;
  `}),gt=({silences:t,alertManagerAlerts:n,alertManagerSourceName:s})=>{const c=(0,T.wW)(me),[o]=(0,ee.K)(),m=de(t,!1),l=de(t,!0),u=(0,te.QX)(s),{silenceState:i}=(0,N.pF)(o),g=i===B.As.Expired,d=(0,e.useMemo)(()=>{const h=E=>n.filter(M=>M.status.silencedBy.includes(E));return m.map(E=>{const M=h(E.id);return{id:E.id,data:{...E,silencedAlerts:M}}})},[m,n]),f=(0,e.useMemo)(()=>{const h=E=>n.filter(M=>M.status.silencedBy.includes(E));return l.map(E=>{const M=h(E.id);return{id:E.id,data:{...E,silencedAlerts:M}}})},[l,n]);return e.createElement("div",{"data-testid":"silences-table"},!!t.length&&e.createElement(q.K,{direction:"column"},e.createElement(mt,null),e.createElement(Ye.q,{actions:[u.create],fallback:Q.contextSrv.isEditor},e.createElement("div",{className:c.topButtonContainer},e.createElement(U.Qj,{href:(0,N.eQ)("/alerting/silence/new",s),icon:"plus"},"Add Silence"))),e.createElement(ie,{items:d,alertManagerSourceName:s,dataTestId:"not-expired-table"}),f.length>0&&e.createElement(Qe.s,{label:`Expired silences (${f.length})`,isOpen:g},e.createElement("div",{className:c.callout},e.createElement(_.J,{className:c.calloutIcon,name:"info-circle"}),e.createElement("span",null,"Expired silences are automatically deleted after 5 days.")),e.createElement(ie,{items:f,alertManagerSourceName:s,dataTestId:"expired-table"}))),!t.length&&e.createElement(ke,{alertManagerSourceName:s}))};function ie({items:t,alertManagerSourceName:n,dataTestId:s}){const c=Et(n);return t.length?e.createElement(ne.t,{items:t,cols:c,isExpandable:!0,dataTestId:s,renderExpandedContent:({data:o})=>e.createElement(st,{silence:o})}):e.createElement(e.Fragment,null,"No matching silences found")}const de=(t,n=!1)=>{const[s]=(0,ee.K)();return(0,e.useMemo)(()=>{const{queryString:c}=(0,N.pF)(s),o=s?.silenceIds;return t.filter(m=>typeof o=="string"&&!o.split(",").includes(m.id)||c&&!(0,O.Zh)(c).every(i=>m.matchers?.some(({name:g,value:d,isEqual:f,isRegex:h})=>i.name===g&&i.value===d&&i.isEqual===f&&i.isRegex===h))?!1:n?m.status.state===B.As.Expired:m.status.state!==B.As.Expired)},[s,t,n])},me=t=>({topButtonContainer:(0,r.css)`
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
  `,addNewSilence:(0,r.css)`
    margin: ${t.spacing(2,0)};
  `,callout:(0,r.css)`
    background-color: ${t.colors.background.secondary};
    border-top: 3px solid ${t.colors.info.border};
    border-radius: ${t.shape.borderRadius()};
    height: 62px;
    display: flex;
    flex-direction: row;
    align-items: center;

    & > * {
      margin-left: ${t.spacing(1)};
    }
  `,calloutIcon:(0,r.css)`
    color: ${t.colors.info.text};
  `,editButton:(0,r.css)`
    margin-left: ${t.spacing(.5)};
  `});function Et(t){const n=(0,A.useDispatch)(),s=(0,T.wW)(me),c=(0,te.QX)(t);return(0,e.useMemo)(()=>{const o=u=>{n((0,G.yO)(t,u))},m=Q.contextSrv.hasAccess(c.update,Q.contextSrv.isEditor),l=[{id:"state",label:"State",renderCell:function({data:{status:i}}){return e.createElement(ot,{state:i.state})},size:4},{id:"matchers",label:"Matching labels",renderCell:function({data:{matchers:i}}){return e.createElement(He,{matchers:i||[]})},size:10},{id:"alerts",label:"Alerts",renderCell:function({data:{silencedAlerts:i}}){return e.createElement("span",{"data-testid":"alerts"},i.length)},size:4},{id:"schedule",label:"Schedule",renderCell:function({data:{startsAt:i,endsAt:g}}){const d=H.parse(i),f=H.parse(g),h="YYYY-MM-DD HH:mm";return e.createElement(e.Fragment,null," ",d?.format(h)," ","-",f?.format(h))},size:7}];return m&&l.push({id:"actions",label:"Actions",renderCell:function({data:i}){return e.createElement(q.K,{gap:.5},i.status.state==="expired"?e.createElement(we.r,{href:(0,N.eQ)(`/alerting/silence/${i.id}/edit`,t)},e.createElement(ce,{icon:"sync"},"Recreate")):e.createElement(ce,{icon:"bell",onClick:()=>o(i.id)},"Unsilence"),i.status.state!=="expired"&&e.createElement(Ze.A,{className:s.editButton,to:(0,N.eQ)(`/alerting/silence/${i.id}/edit`,t),icon:"pen",tooltip:"edit"}))},size:5}),l},[t,n,s,c])}const vt=gt,ue={icon:"bell-slash"};function ft(){const{isExact:t,path:n}=(0,p.$B)(),[s,c]=(0,e.useState)();return(0,e.useEffect)(()=>{n==="/alerting/silence/new"?c({...ue,id:"silence-new",text:"Add silence"}):n==="/alerting/silence/:id/edit"&&c({...ue,id:"silence-edit",text:"Edit silence"})},[n,t]),s}var ht=a(1469),pt=a(33555);const At=()=>{const{selectedAlertmanager:t}=(0,ht.Z)(),n=(0,A.useDispatch)(),s=(0,X._)(f=>f.silences),c=(0,X._)(f=>f.amAlerts),o=t?c[t]||k.oq:void 0,{currentData:m}=x.T.useDiscoverAmFeaturesQuery({amSourceName:t??""},{skip:!t});(0,e.useEffect)(()=>{function f(){t&&(n((0,G.je)(t)),n((0,G.dB)(t)))}f();const h=setInterval(()=>f,pt.cm);return()=>{clearInterval(h)}},[t,n]);const{result:l,loading:u,error:i}=t&&s[t]||k.oq,g=(0,e.useCallback)(f=>l&&l.find(h=>h.id===f),[l]),d=i?.message?.includes("the Alertmanager is not configured")&&m?.lazyConfigInit;return t?e.createElement(e.Fragment,null,e.createElement(L.u,{currentAlertmanager:t}),d&&e.createElement(v.b,{title:"The selected Alertmanager has no configuration",severity:"warning"},"Create a new contact point to create a configuration using the default values or contact your administrator to set up the Alertmanager."),i&&!u&&!d&&e.createElement(v.b,{severity:"error",title:"Error loading silences"},i.message||"Unknown error."),o?.error&&!o?.loading&&!d&&e.createElement(v.b,{severity:"error",title:"Error loading Alertmanager alerts"},o.error?.message||"Unknown error."),l&&!i&&e.createElement(p.rs,null,e.createElement(p.AW,{exact:!0,path:"/alerting/silences"},e.createElement(vt,{silences:l,alertManagerAlerts:o?.result??[],alertManagerSourceName:t})),e.createElement(p.AW,{exact:!0,path:"/alerting/silence/new"},e.createElement(le,{alertManagerSourceName:t})),e.createElement(p.AW,{exact:!0,path:"/alerting/silence/:id/edit"},({match:f})=>f?.params.id&&e.createElement(le,{silence:g(f.params.id),alertManagerSourceName:t})))):null};function yt(){const t=ft();return e.createElement(D.O,{pageId:"silences",pageNav:t,accessType:"instance"},e.createElement(At,null))}const St=(0,C.Pf)(yt,{style:"page"})},89439:(W,S,a)=>{a.d(S,{q:()=>v});var e=a(27702),p=a(91368);const v=({actions:C,children:A,fallback:x=!0})=>C.some(D=>p.contextSrv.hasAccess(D,x))?e.createElement(e.Fragment,null,A):null},80118:(W,S,a)=>{a.d(S,{u:()=>L});var e=a(42844),p=a(27702),v=a(66310),C=a(63439),A=a(62862),x=a(52646),D=a(22513);function L({currentAlertmanager:b}){const P=(0,v.wW)(r),{useGetAlertmanagerChoiceStatusQuery:K}=x.alertmanagerApi,{currentData:y}=K(),Z=b===D.GC;if(!(y?.alertmanagersChoice&&[A.TE.External,A.TE.All].includes(y?.alertmanagersChoice))||!Z)return null;const z=y.numExternalAlertmanagers>0;return y.alertmanagersChoice===A.TE.External?p.createElement(C.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.",p.createElement("div",{className:P.adminHint},"To change your Alertmanager setup, go to the Alerting Admin page. If you do not have access, contact your Administrator.")):y.alertmanagersChoice===A.TE.All&&z?p.createElement(C.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.",p.createElement("div",{className:P.adminHint},"To change your Alertmanager setup, go to the Alerting Admin page. If you do not have access, contact your Administrator.")):null}const r=b=>({adminHint:(0,e.css)`
    font-size: ${b.typography.bodySmall.fontSize};
    font-weight: ${b.typography.bodySmall.fontWeight};
  `})},18686:(W,S,a)=>{a.d(S,{A:()=>C});var e=a(27702),p=a(80011),v=a(66670);const C=({tooltip:A,icon:x,to:D,target:L,onClick:r,className:b,tooltipPlacement:P="top",...K})=>{const y=typeof A=="string"?A:void 0;return e.createElement(p.u,{content:A,placement:P},D?e.createElement(v.Qj,{variant:"secondary",fill:"text",icon:x,href:D,size:"sm",target:L,...K,"aria-label":y}):e.createElement(v.zx,{className:b,variant:"secondary",fill:"text",size:"sm",icon:x,type:"button",onClick:r,...K,"aria-label":y}))}},22201:(W,S,a)=>{a.d(S,{G:()=>A});var e=a(27702),p=a(62862),v=a(6949);const C={[p.Z9.Active]:"bad",[p.Z9.Unprocessed]:"neutral",[p.Z9.Suppressed]:"info"},A=({state:x})=>e.createElement(v.i,{state:C[x]},x)},79003:(W,S,a)=>{a.d(S,{j:()=>C});var e=a(27702),p=a(7662),v=a(26129);function C(){const{search:A}=(0,p.TH)(),x=(0,e.useMemo)(()=>new URLSearchParams(A),[A]),D=(0,e.useCallback)((L,r)=>{v.E1.partial(L,r)},[]);return[x,D]}},38338:(W,S,a)=>{a.d(S,{D:()=>p});var e=a(42844);const p=v=>({table:(0,e.css)`
    width: 100%;
    border-radius: ${v.shape.borderRadius()};
    border: solid 1px ${v.colors.border.weak};
    background-color: ${v.colors.background.secondary};

    th {
      padding: ${v.spacing(1)};
    }

    td {
      padding: 0 ${v.spacing(1)};
    }

    tr {
      height: 38px;
    }
  `,evenRow:(0,e.css)`
    background-color: ${v.colors.background.primary};
  `,colExpand:(0,e.css)`
    width: 36px;
  `,nameCell:(0,e.css)`
    gap: ${v.spacing(1)};
  `,actionsCell:(0,e.css)`
    text-align: right;
    width: 1%;
    white-space: nowrap;

    & > * + * {
      margin-left: ${v.spacing(.5)};
    }
  `})}}]);

//# sourceMappingURL=AlertSilences.f88f35508b4aa4c66bb6.js.map