12345678910111213141516171819 |
- "use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7918],{20293:(e,r,n)=>{n.r(r),n.d(r,{RedirectToRuleViewer:()=>x,default:()=>b});var s,a,t,l,o=n(36636),u=(n(68404),n(42326)),i=n(69783),c=n(94322),d=n(31865),p=n(80145),m=n(19462),f=n(39357),g=n(45916);const h="Alerting / Find rule";function x(e){const{name:r,sourceName:n}=e.match.params,o=(0,i.useStyles2)(j),{error:x,loading:b,result:v,dispatched:y}=(0,p.X)(r,n);if(x)return(0,g.jsx)(d.$,{title:h,children:(0,g.jsx)(i.Alert,{title:`Failed to load rules from ${n}`,children:(0,g.jsxs)("details",{className:o.errorMessage,children:[x.message,s||(s=(0,g.jsx)("br",{})),!(null==x||!x.stack)&&x.stack]})})});if(b||!y||!Array.isArray(v))return a||(a=(0,g.jsx)(d.$,{title:h,children:(0,g.jsx)(i.LoadingPlaceholder,{text:"Loading rule..."})}));if(!r||!n)return t||(t=(0,g.jsx)(u.l_,{to:"/notfound"}));const $=(0,m.o_)(n);if(!$)return(0,g.jsx)(d.$,{title:h,children:(0,g.jsx)(i.Alert,{title:"Could not view rule",children:(0,g.jsx)("details",{className:o.errorMessage,children:`Could not find data source with name: ${n}.`})})});if(1===v.length){const[e]=v;return(0,g.jsx)(u.l_,{to:(0,f.V2)($,e,"/alerting/list")})}return(0,g.jsxs)(d.$,{title:h,children:[(0,g.jsxs)("div",{children:["Several rules in ",(0,g.jsx)("span",{className:o.param,children:n})," matched the name"," ",(0,g.jsx)("span",{className:o.param,children:r}),", please select the rule you want to view."]}),(0,g.jsx)("div",{className:o.rules,children:v.map(((e,r)=>(0,g.jsxs)(i.Card,{href:(0,f.V2)($,e,"/alerting/list"),children:[(0,g.jsx)(i.Card.Heading,{children:e.name}),(0,g.jsxs)(i.Card.Meta,{separator:"",children:[l||(l=(0,g.jsx)(i.Icon,{name:"folder"})),(0,g.jsx)("span",{className:o.namespace,children:`${e.namespace.name} / ${e.group.name}`})]}),(0,g.jsx)(i.Card.Tags,{children:(0,g.jsx)(c.s,{labels:e.labels})})]},`${e.name}-${r}`)))})]})}function j(e){return{param:o.css`
- font-style: italic;
- color: ${e.colors.text.secondary};
- `,rules:o.css`
- margin-top: ${e.spacing(2)};
- `,namespace:o.css`
- margin-left: ${e.spacing(1)};
- `,errorMessage:o.css`
- white-space: pre-wrap;
- `}}const b=(0,i.withErrorBoundary)(x,{style:"page"})},31865:(e,r,n)=>{n.d(r,{$:()=>u,l:()=>i});var s=n(36636),a=(n(68404),n(90923)),t=n(69783),l=n(33801),o=n(45916);function u(e){const{wrapInContent:r=!0,children:n,title:s}=e,u=(0,t.useStyles2)(c);return(0,o.jsxs)(l.T,{children:[(0,o.jsx)(t.PageToolbar,{title:s,pageIcon:"bell",onGoBack:()=>a.locationService.push("/alerting/list")}),(0,o.jsx)("div",{className:u.content,children:r?(0,o.jsx)(i,Object.assign({},e)):n})]})}function i(e){let{children:r,padding:n=2}=e;const s=(0,t.useStyles2)(d(n));return(0,o.jsx)("div",{className:s.wrapper,children:r})}const c=e=>({content:s.css`
- margin: ${e.spacing(0,2,2)};
- max-width: ${e.breakpoints.values.xxl}px;
- `}),d=e=>r=>({wrapper:s.css`
- background: ${r.colors.background.primary};
- border: 1px solid ${r.colors.border.weak};
- border-radius: ${r.shape.borderRadius()};
- padding: ${r.spacing(e)};
- `})},80145:(e,r,n)=>{n.d(r,{H:()=>p,X:()=>m});var s=n(68404),a=n(18745),t=n(94087),l=n(83809),o=n(8455),u=n(59940),i=n(86647),c=n(75678),d=n(33899);function p(e,r){const n=f(r),a=(0,c.Zo)(r),t=(0,s.useMemo)((()=>{if(e&&r&&0!==a.length)for(const n of a)for(const s of n.groups)for(const n of s.rules){const s=u.Yd(r,n);if(u.Dg(s,e))return n}}),[e,r,a]);return Object.assign({},n,{result:t})}function m(e,r){const n=f(r),a=(0,c.Zo)(r),t=(0,s.useMemo)((()=>{if(!e||!r||0===a.length)return[];const n=[];for(const r of a)for(const s of r.groups)for(const r of s.rules)r.name===e&&n.push(r);return n}),[e,r,a]);return Object.assign({},n,{result:t})}function f(e){var r;const n=(0,a.useDispatch)(),s=(0,d._)((e=>e.promRules)),o=g(e,s),u=(0,d._)((e=>e.rulerRules)),c=g(e,u),{loading:p}=(0,t.Z)((async()=>{e&&await n((0,l.dn)({rulesSourceName:e}))}),[n,e]);return{loading:p,error:(null!==(r=o.error)&&void 0!==r?r:(0,i.m$)(c))?void 0:c.error,dispatched:o.dispatched&&c.dispatched}}function g(e,r){if(!e)return o.oq;const n=r[e];return n||o.oq}},75678:(e,r,n)=>{n.d(r,{Kd:()=>u,Zo:()=>o});var s=n(68404),a=n(19462),t=n(86647),l=n(33899);function o(e){const r=(0,l._)((e=>e.promRules)),n=(0,l._)((e=>e.rulerRules)),o=(0,s.useRef)({}),u=(0,s.useMemo)((()=>{if(e){const r=(0,a.o_)(e);if(!r)throw new Error(`Unknown rules source: ${e}`);return[r]}return(0,a.h_)()}),[e]);return(0,s.useMemo)((()=>u.map((e=>{var s,l;const u=(0,a.jq)(e)?e.name:e,c=null===(s=r[u])||void 0===s?void 0:s.result,d=null===(l=n[u])||void 0===l?void 0:l.result,p=o.current[u];if(p&&p.promRules===c&&p.rulerRules===d)return p.result;const m={};Object.entries(d||{}).forEach((r=>{let[n,s]=r;const a={rulesSource:e,name:n,groups:[]};m[n]=a,function(e,r){e.groups=r.map((r=>{const n={name:r.name,interval:r.interval,source_tenants:r.source_tenants,rules:[]};return n.rules=r.rules.map((r=>function(e,r,n){return(0,t.cG)(e)?{name:e.alert,query:e.expr,labels:e.labels||{},annotations:e.annotations||{},rulerRule:e,namespace:r,group:n}:(0,t.yF)(e)?{name:e.record,query:e.expr,labels:e.labels||{},annotations:{},rulerRule:e,namespace:r,group:n}:{name:e.grafana_alert.title,query:"",labels:e.labels||{},annotations:e.annotations||{},rulerRule:e,namespace:r,group:n}}(r,e,n))),n}))}(a,s)})),null==c||c.forEach((r=>{let{name:n,groups:s}=r;!function(e,r){r.forEach((r=>{var n;let s=e.groups.find((e=>e.name===r.name));s||(s={name:r.name,rules:[]},e.groups.push(s)),(null!==(n=r.rules)&&void 0!==n?n:[]).forEach((r=>{const n=function(e,r,n){var s;if((0,a.HY)(n))return r.rules.find((r=>r.name===e.name));return null!==(s=r.rules.find((r=>!r.promRule&&i(r,e,!0))))&&void 0!==s?s:r.rules.find((r=>!r.promRule&&i(r,e,!1)))}(r,s,e.rulesSource);n?n.promRule=r:s.rules.push(function(e,r,n){return{name:e.name,query:e.query,labels:e.labels||{},annotations:(0,t.x_)(e)&&e.annotations||{},promRule:e,namespace:r,group:n}}(r,e,s))}))}))}(m[n]=m[n]||{rulesSource:e,name:n,groups:[]},s)}));const f=Object.values(m);return o.current[u]={promRules:c,rulerRules:d,result:f},f})).flat()),[r,n,u])}function u(e){return e.map((e=>{const r=Object.assign({},e,{groups:[]});var n;return r.groups.push({name:"default",rules:(n=e.groups.flatMap((e=>e.rules)),n.sort(((e,r)=>e.name.localeCompare(r.name))))}),r}))}function i(e,r){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e.name===r.name&&JSON.stringify([n?c(e.query):"",e.labels,e.annotations])===JSON.stringify([n?c(r.query):"",r.labels||{},(0,t.x_)(r)&&r.annotations||{}])}function c(e){return e.length>1&&"("===e[0]&&")"===e[e.length-1]&&(e=e.slice(1,-1)),(e=e.replace(/\s|\n/g,"")).split("").sort().join("")}}}]);
- //# sourceMappingURL=AlertingRedirectToRule.68531cf96aa6317776ff.js.map
|