2 lines
6.2 KiB
JavaScript
2 lines
6.2 KiB
JavaScript
"use strict";(self.webpackChunkgrafana_metricsdrilldown_app=self.webpackChunkgrafana_metricsdrilldown_app||[]).push([[913],{13934:(e,t,r)=>{r.d(t,{BR:()=>s,Hi:()=>i,KF:()=>n});var a=r(85959);const n=(0,r(69989).ef)(),s=(0,a.createContext)({trail:n});function i(){return(0,a.useContext)(s)}},32913:(e,t,r)=>{r.r(t),r.d(t,{default:()=>M});var a=r(18531),n=r(85959),s=r.n(n),i=r(77307),c=r(85358),o=r(28464),l=r(83535),u=r(63386),m=r(90903),d=r(87073),p=r(69989),g=r(57014),f=r(28904),h=r(19967);class b extends f.SceneObjectBase{filterVariableOptions(e){const t=e.state.options;if(0===t.length)return;const r=t.filter(e=>!String(e.value).startsWith("asserts"));r.length!==t.length&&e.setState({options:r})}constructor(e){super({}),this.addActivationHandler(()=>{const t=this.getRoot().subscribeToEvent(h.Y,t=>{var r;(null===(r=e.metric)||void 0===r?void 0:r.startsWith("asserts"))||this.filterVariableOptions(t.payload)});return()=>t.unsubscribe()})}}var v=r(34936),E=r(19148),_=r(26875),w=r(81311);class y extends f.SceneObjectBase{constructor(){var e,t,r;super({}),e=this,t="processedPanels",r=new WeakSet,t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,this.addActivationHandler(()=>{const e=this.getRoot(),t=()=>{const t=f.sceneGraph.findAllObjects(e,e=>e instanceof v.m);for(const e of t){var r;if(this.processedPanels.has(e))continue;const{metric:t,panelConfig:a}=e.state,n=(0,E.K)(t),s=null===(r=(w.x.getItem(_.V.METRIC_PREFS)||{})[t])||void 0===r?void 0:r.config;"classic-histogram"!==n&&"native-histogram"!==n||s||"heatmap"!==a.type||e.update({type:"percentiles"},{queries:[{fn:"histogram_quantile",params:{percentiles:[99,90,50]}}]}),this.processedPanels.add(e)}};t();const r=e.subscribeToState(t);return()=>r.unsubscribe()})}}var S=r(76217),k=r(82473);function R(e){const t=e.match(/^([a-zA-Z0-9]+)/);return t?t[1]:e}const M=e=>{const[t]=(0,o.n)(),r=(0,n.useRef)(!1);let f,h;(0,n.useEffect)(()=>{r.current||(r.current=!0,(0,d.z)("exposed_component_viewed",{component:"knowledge_graph_source_metrics"}))},[]);const{scenario:v,sourceMetrics:E,fallbackQuery:_}=function(e){if(e.sourceMetrics&&e.sourceMetrics.length>0)return{scenario:1===e.sourceMetrics.length?"single_source_metric":"multiple_source_metrics",sourceMetrics:e.sourceMetrics,fallbackQuery:void 0};let t;if(e.query)try{t=(0,S.$9)(e.query)}catch(t){m.v.error(new Error(`Failed to parse PromQL query: ${t}`),{query:e.query})}return t?{scenario:"recording_rule_fallback",sourceMetrics:void 0,fallbackQuery:t}:{scenario:"missing_metric_information",sourceMetrics:void 0,fallbackQuery:void 0}}(e);switch(v){case"single_source_metric":f=E[0].metricName,h=E[0].labels.map(e=>(0,g.Do)(e));break;case"multiple_source_metrics":h=E[0].labels.map(e=>(0,g.Do)(e));const t=["asserts","ALERTS"],r=function(e){const t=new Set(e.map(R));return Array.from(t)}(E.map(e=>e.metricName)).filter(e=>t.every(t=>!e.startsWith(t)));if(null==r?void 0:r.length){const e=`${p.mc}-${u.G.prefix}`;a.locationService.partial({[e]:r.join(",")},!0);const t=`${p.mc}-var-${l.NJ}`;a.locationService.partial({[t]:"alphabetical"},!0)}break;case"recording_rule_fallback":f=_.metric,h=_.labels.map(e=>(0,g.Do)(e));break;case"missing_metric_information":const n=new Error("Missing metric information for Knowledge Graph insight");return m.v.error(n,{query:e.query}),s().createElement(i.E,{error:n})}const w=(0,p.ef)({metric:f,initialDS:e.dataSource.uid,initialFilters:h,$timeRange:(0,k._)(e.initialStart,e.initialEnd),embedded:!0,$behaviors:[new b({metric:f}),new y]});return s().createElement("div",{"data-testid":"metrics-drilldown-embedded-label-breakdown"},t?s().createElement(i.E,{error:t}):s().createElement(c.X,{trail:w}))}},77307:(e,t,r)=>{r.d(t,{E:()=>u});var a=r(46089),n=r(37768),s=r(82007),i=r(85959),c=r.n(i),o=r(81159),l=r(60341);function u({error:e}){const t=(0,s.useStyles2)(m),r=(0,o.useNavigate)(),{pathname:a,search:u}=(0,o.useLocation)(),d=(0,i.useCallback)(()=>{const e=new URLSearchParams(u),t=new URLSearchParams;["from","to","timezone"].filter(t=>e.has(t)).forEach(r=>t.set(r,e.get(r))),r({pathname:a,search:t.toString()}),window.location.reload()},[r,a,u]),[p,g]=(0,i.useState)(!1);return c().createElement("div",{className:t.container},c().createElement(l._,{severity:"error",title:(0,n.t)("error-view.title","Fatal error!"),error:e,errorContext:{handheldBy:"React error boundary"},message:c().createElement(c().Fragment,null,c().createElement("p",{className:t.message},c().createElement(n.x6,{i18nKey:"error-view.message"},"Please"," ",c().createElement(s.TextLink,{href:"#",onClick:d},"try reloading the page")," ","or, if the problem persists, contact your organization admin. Sorry for the inconvenience.")),c().createElement("p",null,c().createElement(s.Collapse,{className:t.callStack,label:(0,n.t)("error-view.stack-trace-label","View stack trace"),isOpen:p,onToggle:()=>g(!p)},c().createElement("pre",null,c().createElement("code",null,e.stack)))))}))}function m(e){return{container:(0,a.css)({margin:e.spacing(2)}),message:(0,a.css)({margin:e.spacing(2,0,1,0)}),callStack:(0,a.css)({backgroundColor:"transparent",border:"0 none","& button":(0,a.css)({paddingLeft:e.spacing(1.5)}),"& button:focus":(0,a.css)({outline:"none",boxShadow:"none"}),"& button > svg":(0,a.css)({marginLeft:e.spacing(-2),marginRight:e.spacing(.5)}),'& [class$="collapse__loader"]':(0,a.css)({display:"none"})})}}},82473:(e,t,r)=>{r.d(t,{_:()=>i});var a=r(87781),n=r(28904);function s(e){return"string"==typeof e&&a.dateMath.isMathString(e)?e:a.dateMath.toDateTime(new Date(e),{roundUp:!1}).toISOString()}function i(e,t){return new n.SceneTimeRange({from:s(e),to:s(t)})}},85358:(e,t,r)=>{r.d(t,{S:()=>u,X:()=>o});var a=r(85959),n=r.n(a),s=r(81159),i=r(98928),c=r(13934);const o=(0,a.lazy)(()=>r.e(899).then(r.bind(r,87899))),l=()=>{const e=(0,s.useLocation)();return n().createElement(s.Navigate,{to:`${i.b.Drilldown}${e.search}`,replace:!0})},u=()=>{const{trail:e}=(0,c.Hi)();return n().createElement(s.Routes,null,n().createElement(s.Route,{path:i.b.Drilldown,element:n().createElement(o,{trail:e})}),n().createElement(s.Route,{path:i.b.Trail,element:n().createElement(l,null)}),n().createElement(s.Route,{path:"*",element:n().createElement(s.Navigate,{to:i.b.Drilldown,replace:!0})}))}}}]);
|
|
//# sourceMappingURL=913.js.map?_cache=7114f8bc77d7e100d586
|