@perses-dev/prometheus-plugin 0.51.0 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/__mf/js/{622.81d47848.js → 622.a776ec11.js} +1 -1
  2. package/__mf/js/{Prometheus.ce1e9458.js → Prometheus.c57c8a9f.js} +3 -3
  3. package/__mf/js/async/{5345.2e531d76.js → 5345.1f4fc17b.js} +1 -1
  4. package/__mf/js/async/{5503.d391f0fc.js → 5503.daedd4dd.js} +1 -1
  5. package/__mf/js/async/{__federation_expose_PrometheusExplorer.3f83dfda.js → __federation_expose_PrometheusExplorer.171d04eb.js} +1 -1
  6. package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.fc3c5730.js +1 -0
  7. package/__mf/js/{main.02b2cf43.js → main.9866e9bf.js} +1 -1
  8. package/lib/cjs/components/PromQLEditor.js +1 -1
  9. package/lib/cjs/components/TreeNode.js +1 -2
  10. package/lib/cjs/explore/PrometheusMetricsFinder/filter/FinderFilters.js +1 -1
  11. package/lib/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +2 -2
  12. package/lib/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +8 -0
  13. package/lib/components/PromQLEditor.js +1 -1
  14. package/lib/components/PromQLEditor.js.map +1 -1
  15. package/lib/components/TreeNode.js +1 -2
  16. package/lib/components/TreeNode.js.map +1 -1
  17. package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js +1 -1
  18. package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js.map +1 -1
  19. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +2 -2
  20. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
  21. package/lib/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -1
  22. package/lib/plugins/prometheus-time-series-query/get-time-series-data.js +8 -0
  23. package/lib/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
  24. package/lib/plugins/prometheus-time-series-query/query-editor-model.d.ts +1 -1
  25. package/lib/plugins/prometheus-time-series-query/query-editor-model.d.ts.map +1 -1
  26. package/lib/plugins/prometheus-time-series-query/query-editor-model.js.map +1 -1
  27. package/mf-manifest.json +28 -28
  28. package/mf-stats.json +31 -31
  29. package/package.json +1 -1
  30. package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.b4228802.js +0 -1
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkPrometheus=self.webpackChunkPrometheus||[]).push([["5742"],{35015:function(e,t,n){async function l(...e){let t=await n.g.fetch(...e);if(!1===t.ok){let e=t.headers.get("content-type");if(e?.includes("application/json")){let e=await t.json();if(e.error)throw new i(e.error,t.status);if(e.message)throw new i(e.message,t.status)}let n=await t.text();if(n)throw new i(n,t.status);throw new r(t)}return t}async function a(...e){let t=await l(...e);return await t.json()}n.d(t,{he:()=>l,rd:()=>a});class r extends Error{status;constructor(e){super(`${e.status} ${e.statusText}`),this.status=e.status,Object.setPrototypeOf(this,r.prototype)}}class i extends Error{status;constructor(e,t){super(e),this.status=t,Object.setPrototypeOf(this,i.prototype)}}},30666:function(e,t,n){t.default=void 0;var l,a=(l=n(30265))&&l.__esModule?l:{default:l};t.default=(0,a.default)("M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z","ArrowLeft")},82562:function(e,t,n){t.default=void 0;var l,a=(l=n(30265))&&l.__esModule?l:{default:l};t.default=(0,a.default)("M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z","Check")},77463:function(e,t,n){t.default=void 0;var l,a=(l=n(30265))&&l.__esModule?l:{default:l};t.default=(0,a.default)("M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z","Cog")},50737:function(e,t,n){t.default=void 0;var l,a=(l=n(30265))&&l.__esModule?l:{default:l};t.default=(0,a.default)("M14.19,14.19L6,18L9.81,9.81L18,6M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,10.9A1.1,1.1 0 0,0 10.9,12A1.1,1.1 0 0,0 12,13.1A1.1,1.1 0 0,0 13.1,12A1.1,1.1 0 0,0 12,10.9Z","Compass")},88160:function(e,t,n){t.default=void 0;var l,a=(l=n(30265))&&l.__esModule?l:{default:l};t.default=(0,a.default)("M11,18H13V16H11V18M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,6A4,4 0 0,0 8,10H10A2,2 0 0,1 12,8A2,2 0 0,1 14,10C14,12 11,11.75 11,15H13C13,12.75 16,12.5 16,10A4,4 0 0,0 12,6Z","HelpCircleOutline")},66268:function(e,t,n){t.default=void 0;var l,a=(l=n(30265))&&l.__esModule?l:{default:l};t.default=(0,a.default)("M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z","Magnify")},27472:function(e,t,n){n.r(t),n.d(t,{PrometheusExplorer:()=>ew});var l=n(24246),a=n(36372),r=n(25283),i=n(51781),s=n(49408),o=n(58891),d=n(90382),u=n(75276),c=n(32600),h=n(65456),x=n(75094),f=n(5549),p=n(10517),m=n(28797),g=n(82707),j=n(50898),b=n(8695),v=n(76992),Z=n(76439),C=n(94776),w=n(48565);function y(e){return e.to-e.from+1}function M(e,t){let n=e[t],l=null;return 0===t&&0!==n.from&&(l={from:0,to:n.from-1}),t>0&&(l={from:e[t-1].to+1,to:n.from-1}),l}class L{constructor(e){this.conf={caseSensitive:(null==e?void 0:e.caseSensitive)!==void 0&&e.caseSensitive,excludedChars:(null==e?void 0:e.excludedChars)===void 0?[]:e.excludedChars,includeMatches:(null==e?void 0:e.includeMatches)!==void 0&&e.includeMatches,shouldSort:(null==e?void 0:e.shouldSort)!==void 0&&e.shouldSort,shouldRender:(null==e?void 0:e.shouldRender)===void 0||e.shouldRender,escapeHTML:(null==e?void 0:e.escapeHTML)!==void 0&&e.escapeHTML,pre:(null==e?void 0:e.pre)===void 0?"":e.pre,post:(null==e?void 0:e.post)===void 0?"":e.post}}filter(e,t,n){let l=(null==n?void 0:n.shouldSort)!==void 0?n.shouldSort:this.conf.shouldSort,a=[];for(let l=0;l<t.length;l++){let r=this.match(e,t[l],n);null!==r&&(r.index=l,a.push(r))}return l&&(a=a.sort((e,t)=>t.score-e.score)),a}match(e,t,n){let l=e,a=t,r=(null==n?void 0:n.caseSensitive)!==void 0?n.caseSensitive:this.conf.caseSensitive,i=(null==n?void 0:n.includeMatches)!==void 0?n.includeMatches:this.conf.includeMatches,s=(null==n?void 0:n.shouldRender)!==void 0?n.shouldRender:this.conf.shouldRender;if(r||(l=l.toLowerCase(),a=a.toLowerCase()),l===a){let l=[{from:0,to:e.length-1}],a={original:t,rendered:s?this.render(t,l,n):t,score:1/0};return i&&(a.intervals=l),a}let o=[],d=0;for(let e=0;e<a.length-l.length+1;e++)if(a[e]===l[0]){let t=this.generateMatchingInterval(l,a,e,n);if(null===t)break;t.score>d&&(d=t.score,o=t.intervals)}if(0===o.length)return null;let u={original:t,rendered:s?this.render(t,o,n):t,score:d};return i&&(u.intervals=o),u}render(e,t,n){if(0==t.length)return e;let l="",a=(null==n?void 0:n.pre)?n.pre:this.conf.pre,r=(null==n?void 0:n.post)?n.post:this.conf.post;for(let i=0;i<t.length;i++){let s=t[i],o=M(t,i),d="";null!==o&&(d=this.extractSubString(e,o,n));let u=this.extractSubString(e,s,n);l=`${l}${d}${a}${u}${r}`}let i=t[t.length-1];return i.to<e.length-1&&(l+=this.extractSubString(e,{from:i.to+1,to:e.length},n)),l}extractSubString(e,t,n){let l=(null==n?void 0:n.escapeHTML)!==void 0?n.escapeHTML:this.conf.escapeHTML,a=e.substr(t.from,y(t));return l&&(a=a.replace(/[&<>"']/g,e=>{switch(e){case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";case'"':return"&quot;";default:return"&#039;"}})),a}generateMatchingInterval(e,t,n,l){let a=[];(null==l?void 0:l.excludedChars)!==void 0?a=l.excludedChars:void 0!==this.conf.excludedChars&&(a=this.conf.excludedChars);let r=0,i=[];for(let l=n;l<t.length&&r<e.length;){if(a.includes(t[l])){l++;continue}if(a.includes(e[r])){r++;continue}if(t[l]===e[r]){let n={from:l,to:l};r++,l++;for(let a=l;a<t.length&&r<e.length&&t[a]===e[r];a++)n.to=a,r++,l=a;i.push(n)}l++}return 0===i.length||r!==e.length?null:{score:function(e,t){let n=0;for(let l=0;l<e.length;l++){let a=e[l],r=M(e,l);null!==r&&(n-=y(r)/t),n+=y(a)**2}return n}(i,t.length),intervals:i}}}new L;var S=n(30666),k=n(77463),_=n(66268),E=n(54538),I=n(67430),T=n(87629),A=n(96205),V=n(52054),R=n(66224),P=n(79119),$=n(50737),O=n(83675),F=n(91909);function q(e){return`${e.map(e=>`${e.label}${e.operator}"${e.labelValues.join("|")}"`).join(",")}`}function H(e,t,n){let{data:l}=(0,o.useDatasourceClient)(t),a=e.replace(/(_count|_sum|_bucket)$/,""),{data:r,isLoading:i,error:s}=(0,F.useQuery)({enabled:!!l&&n,queryKey:["metricMetadata",a],queryFn:async()=>await l.metricMetadata({metric:a})});return{metadata:(0,E.useMemo)(()=>{var e;for(let t of(null==r?void 0:null===(e=r.data)||void 0===e?void 0:e[a])??[])if(t.help.length>0)return t},[r,a]),isLoading:i,error:s}}function N(e,t,n){let{absoluteTimeRange:{start:l,end:a}}=(0,o.useTimeRange)(),{data:r}=(0,o.useDatasourceClient)(n);return(0,F.useQuery)({enabled:!!r,queryKey:["labelValues",e,"datasource",n.name,"start",l,"end","filters",...t],queryFn:async()=>{let n={labelName:e,start:l.valueOf()/1e3,end:a.valueOf()/1e3};return t.length&&(n["match[]"]=[`{${q(t)}}`]),await r.labelValues(n)}})}var D=n(52889);function Q(e){let{label:t,...n}=e;return"gauge"===t?(0,l.jsx)(D.Z,{label:t,color:"success",...n}):"counter"===t?(0,l.jsx)(D.Z,{label:t,color:"primary",...n}):"histogram"===t?(0,l.jsx)(D.Z,{label:t,color:"warning",...n}):"summary"===t?(0,l.jsx)(D.Z,{label:t,color:"secondary",...n}):(0,l.jsx)(D.Z,{label:t,sx:{fontStyle:"unknown"===t?"italic":"initial"},...n})}function W(e){let{children:t,metricName:n,datasource:a,filters:r,isMetadataEnabled:i,onExplore:s}=e,{metadata:o,isLoading:u}=H(n,a,i),c=(0,d.useExplorerQueryParams)({data:{tab:"finder",datasource:a,filters:r,exploredMetric:n}});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(A.Z,{style:{width:"300px"},children:(0,l.jsx)(V.Z,{sx:{fontFamily:"monospace"},children:t??n})}),(0,l.jsx)(A.Z,{style:{width:115,textAlign:"center"},children:i&&u?(0,l.jsx)(R.Z,{variant:"rounded",width:75}):(0,l.jsx)(Q,{label:(null==o?void 0:o.type)??"unknown"})}),(0,l.jsx)(A.Z,{style:{width:"100%"},children:i&&u?(0,l.jsx)(R.Z,{variant:"text",width:180}):(0,l.jsx)(V.Z,{sx:{fontStyle:(null==o?void 0:o.help)?"initial":"italic",minWidth:"30vw"},children:o?o.help:"unknown"})}),(0,l.jsx)(A.Z,{style:{width:140},children:(0,l.jsx)(w.Z,{"aria-label":`explore metric ${n}`,variant:"contained",startIcon:(0,l.jsx)($.default,{}),style:{textWrap:"nowrap"},onClick:()=>null==s?void 0:s(n),component:I.Link,to:`?${c}`,children:"Explore"})})]})}function z(e){let{metricNames:t,filteredResults:n,datasource:a,filters:i,isMetadataEnabled:s,onExplore:o,...d}=e,u=new L,c=(0,E.useMemo)(()=>n||t.map(e=>({original:e})),[n,t]);return(0,l.jsxs)(r.Z,{gap:2,width:"100%",divider:(0,l.jsx)(P.Z,{orientation:"horizontal",flexItem:!0}),...d,children:[(0,l.jsx)(O._n,{style:{height:"70vh",width:"100%"},totalCount:c.length,itemContent:e=>(0,l.jsx)(W,{metricName:c[e].original,datasource:a,filters:i,isMetadataEnabled:s,onExplore:o,children:(0,l.jsx)("span",{dangerouslySetInnerHTML:{__html:u.render(c[e].original,c[e].intervals??[],{pre:'<strong style="color:darkorange">',post:"</strong>",escapeHTML:!0})}})})}),(0,l.jsx)(r.Z,{sx:{width:"100%"},textAlign:"end",children:(0,l.jsxs)(V.Z,{"data-testid":"finder-total",children:["Total: ",(0,l.jsx)("strong",{children:t.length})," metrics"]})})]})}var B=n(90192),Y=n(33755),J=n(11774),K=n(63767),U=n(80354);function G(e){let{datasource:t,value:n,filters:a,onChange:r,onDelete:i}=e,s=(0,E.useMemo)(()=>a.filter(e=>e.label!==n.label),[a,n.label]),{data:d,isLoading:u}=function(e,t){let{absoluteTimeRange:{start:n,end:l}}=(0,o.useTimeRange)(),{data:a}=(0,o.useDatasourceClient)(t);return(0,F.useQuery)({enabled:!!a,queryKey:["labels","datasource",t.name,"start",n,"end",l,"filters",...e],queryFn:async()=>{let t={start:n.valueOf()/1e3,end:l.valueOf()/1e3};return e.length&&(t["match[]"]=[`{${q(e)}}`]),await a.labelNames(t)}})}(s,t),{data:c,isLoading:h}=N(n.label,s,t);return(0,l.jsx)(ee,{value:n,labelOptions:(null==d?void 0:d.data)??[],labelValuesOptions:(null==c?void 0:c.data)??[],isLabelOptionsLoading:u,isLabelValuesOptionsLoading:h,onChange:r,onDelete:i})}let X=(0,E.forwardRef)((e,t)=>{let{children:n,...a}=e,r=(0,E.useRef)("500px"),[i,s]=(0,E.useState)(0);return(0,l.jsx)("ul",{style:{overflow:"hidden",padding:"0",height:i?`min(40vh, ${i}px)`:"40vh"},ref:e=>{let n=e?getComputedStyle(e).maxHeight:null;n&&n!==r.current&&(r.current=n),"function"==typeof t&&t(e)},...a,children:(0,l.jsx)(O.OO,{style:{height:r.current,padding:"10px 0"},data:n,totalListHeightChanged:s,itemContent:(e,t)=>(0,E.cloneElement)(t,{index:e,title:t.props.children})})})});function ee(e){let{value:t,labelOptions:n,labelValuesOptions:a,isLabelOptionsLoading:i,isLabelValuesOptionsLoading:s,onChange:o,onDelete:d}=e;return(0,l.jsxs)(r.Z,{gap:0,flexDirection:"row",alignItems:"center",children:[(0,l.jsx)(J.Z,{freeSolo:!0,disableClearable:!0,options:n??[],value:t.label,sx:{minWidth:200},ListboxComponent:X,loading:i,renderInput:e=>(0,l.jsx)(b.Z,{...e,label:"Label Name",variant:"outlined",fullWidth:!0,size:"medium",sx:{"& .MuiOutlinedInput-root":{borderTopRightRadius:0,borderBottomRightRadius:0}}}),onInputChange:(e,n)=>{o({label:n??"",labelValues:t.labelValues,operator:t.operator})}}),(0,l.jsxs)(K.Z,{value:t.operator,variant:"outlined",onChange:e=>{o({label:t.label,labelValues:t.labelValues,operator:e.target.value})},size:"medium",sx:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderTopRightRadius:0,borderBottomRightRadius:0},children:[(0,l.jsx)(p.Z,{value:"=",children:"="}),(0,l.jsx)(p.Z,{value:"!=",children:"!="}),(0,l.jsx)(p.Z,{value:"=~",children:"=~"}),(0,l.jsx)(p.Z,{value:"!~",children:"!~"})]}),(0,l.jsx)(J.Z,{freeSolo:!0,multiple:"=~"===t.operator||"!~"===t.operator,limitTags:1,disableClearable:!0,options:a??[],value:t.labelValues,ListboxComponent:X,sx:{minWidth:200},loading:s,renderInput:e=>(0,l.jsx)(b.Z,{...e,label:"=~"===t.operator||"!~"===t.operator?"Label Values":"Label Value",variant:"outlined",fullWidth:!0,size:"medium",sx:{"& .MuiOutlinedInput-root":{borderTopLeftRadius:0,borderBottomLeftRadius:0}},slotProps:{input:{...e.InputProps,style:{maxHeight:"53.13px"},endAdornment:(0,l.jsxs)(v.Z,{position:"end",children:[s?(0,l.jsx)(j.Z,{color:"inherit",size:20}):null,(0,l.jsx)(x.Z,{"aria-label":"delete label filter",onClick:()=>d(),edge:"end",children:(0,l.jsx)(U.default,{})})]})}}}),onInputChange:(e,n)=>{("="===t.operator||"!="===t.operator)&&o({label:t.label,labelValues:[n],operator:t.operator})},onChange:(e,n)=>{Array.isArray(n)&&o({label:t.label,labelValues:n,operator:t.operator})}})]})}function et(e){let{datasource:t,filters:n,filteredFilters:a,onDatasourceChange:i,onFiltersChange:s,...d}=e,{data:u}=(0,o.useListDatasourceSelectItems)(h.nY);return(0,l.jsxs)(r.Z,{...d,direction:"row",alignItems:"center",flexWrap:"wrap",gap:1,sx:{width:"100%"},children:[(0,l.jsx)(B.Z,{sx:{width:250},children:(0,l.jsx)(o.DatasourceSelect,{size:"medium",datasourcePluginKind:h.nY,value:t,onChange:function(e){i((0,o.datasourceSelectValueToSelector)(e,{},u)??{kind:h.nY})},label:"Prometheus Datasource",fullWidth:!0})}),n.map((e,r)=>(0,l.jsx)(G,{datasource:t,filters:a,value:e,onChange:e=>{let t=[...n];t[r]=e,s(t)},onDelete:()=>{let e=[...n];e.splice(r,1),s(e)}},r)),(0,l.jsx)(w.Z,{startIcon:(0,l.jsx)(Y.default,{}),"aria-label":"add filter",onClick:()=>{s([...n,{label:"",labelValues:[""],operator:"="}])},children:"Add filter"})]})}X.displayName="ListboxComponent";var en=n(32964),el=n(88160),ea=n(82562),er=n(10763),ei=n(72629);function es(e){let{label:t,valueCounters:n,onFilterAdd:a,...i}=e,[s,o]=(0,E.useState)(!1),[d,u]=(0,E.useState)("="),[c,h]=(0,E.useState)(""),[f,m]=(0,E.useState)(!1),g=(0,Z.Z)((0,C.Z)().breakpoints.down("md")),j=(0,E.useMemo)(()=>f?n:n.slice(0,5),[f,n]);return(0,l.jsxs)(r.Z,{sx:{width:"100%"},direction:g?"column":"row",alignItems:"center",gap:2,...i,children:[(0,l.jsxs)(r.Z,{sx:{width:"100%",height:"100%"},justifyContent:"space-between",alignContent:"center",direction:g?"column":"row",children:[(0,l.jsx)(V.Z,{sx:{fontFamily:"monospace"},pl:+!g,children:t}),(0,l.jsx)(r.Z,{direction:"row",gap:1,alignItems:"center",children:s?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(K.Z,{size:"small",value:d,variant:"outlined",onChange:e=>{u(e.target.value)},children:[(0,l.jsx)(p.Z,{value:"=",children:"="}),(0,l.jsx)(p.Z,{value:"!=",children:"!="}),(0,l.jsx)(p.Z,{value:"=~",children:"=~"}),(0,l.jsx)(p.Z,{value:"!~",children:"!~"})]}),(0,l.jsx)(J.Z,{freeSolo:!0,limitTags:1,disableClearable:!0,options:n.map(e=>e.labelValue),value:c,ListboxComponent:X,sx:{width:250},renderInput:e=>(0,l.jsx)(b.Z,{...e,label:"Value",variant:"outlined",fullWidth:!0,size:"small"}),onInputChange:(e,t)=>{h(t)}}),(0,l.jsx)(x.Z,{"aria-label":"confirm",onClick:()=>{a({label:t,labelValues:[c],operator:d}),o(!1)},children:(0,l.jsx)(ea.default,{})}),(0,l.jsx)(x.Z,{"aria-label":"cancel",onClick:()=>{o(!1)},children:(0,l.jsx)(er.default,{})})]}):(0,l.jsx)(w.Z,{startIcon:(0,l.jsx)(Y.default,{}),"aria-label":"add filter",onClick:()=>o(!0),children:"Add filter"})})]}),(0,l.jsxs)(r.Z,{sx:{width:"100%"},gap:.5,children:[(0,l.jsx)(r.Z,{direction:"row",gap:2,children:(0,l.jsxs)(V.Z,{variant:"subtitle1",children:[n.length," values"]})}),(0,l.jsx)(r.Z,{sx:{overflow:g?"auto":"unset"},children:j.map(e=>(0,l.jsxs)(r.Z,{direction:"row",gap:2,children:[(0,l.jsx)(V.Z,{sx:{color:e=>e.palette.success.main,fontFamily:"monospace",":hover":{backgroundColor:"rgba(127,127,127,0.35)",cursor:"pointer"},textWrap:g?"nowrap":"unset"},onClick:()=>a({label:t,labelValues:[e.labelValue],operator:"="}),children:e.labelValue}),(0,l.jsxs)(V.Z,{sx:{textWrap:"nowrap"},children:["(",e.counter," series)"]})]},`${t}-${e.labelValue}`))}),(0,l.jsx)(r.Z,{width:"100%",textAlign:g?"center":"unset",children:f?(0,l.jsx)(w.Z,{variant:"text",sx:{width:"fit-content"},onClick:()=>m(!1),children:"Hide full values"}):(0,l.jsx)(l.Fragment,{children:n.length>5&&(0,l.jsxs)(w.Z,{variant:"text",sx:{width:"fit-content"},onClick:()=>m(!0),children:["Show ",n.length-5," more values"]})})})]})]},t)}function eo(e){let{labelValueCounters:t,isLoading:n,onFilterAdd:a,...i}=e,s=(0,E.useMemo)(()=>[...t.keys()].sort(),[t]);return n?(0,l.jsx)(r.Z,{width:"100%",sx:{alignItems:"center",justifyContent:"center"},children:(0,l.jsx)(j.Z,{})}):(0,l.jsxs)(r.Z,{sx:{width:"100%"},divider:(0,l.jsx)(P.Z,{flexItem:!0,orientation:"horizontal"}),gap:2,...i,children:[(0,l.jsxs)(r.Z,{gap:2,direction:"row",sx:{width:"100%"},children:[(0,l.jsx)(r.Z,{sx:{width:"100%"},children:(0,l.jsx)(V.Z,{variant:"h3",children:"Label"})}),(0,l.jsx)(r.Z,{sx:{width:"100%"},children:(0,l.jsx)(V.Z,{variant:"h3",children:"Values"})})]}),s.map(e=>(0,l.jsx)(es,{label:e,valueCounters:t.get(e)??[],onFilterAdd:a},e))]})}function ed(e){let{metricName:t,datasource:n,filters:a,onFilterAdd:i,...s}=e,{metadata:d,isLoading:u,error:c}=H(t,n),{series:h,labelValueCounters:x,isLoading:f,error:p}=function(e,t,n){let{absoluteTimeRange:{start:l,end:a}}=(0,o.useTimeRange)(),{data:r}=(0,o.useDatasourceClient)(n),{data:i,isLoading:s,isError:d,error:u}=(0,F.useQuery)({enabled:!!r,queryKey:["series",e,"datasource",n,"start",l,"end","filters",...t],queryFn:async()=>{let e={"match[]":[`{${q(t)}}`],start:l.valueOf()/1e3,end:a.valueOf()/1e3};return await r.series(e)}}),c=(0,E.useMemo)(()=>{let e=new Map;if((null==i?void 0:i.data)===void 0)return e;for(let t of i.data)for(let[n,l]of Object.entries(t)){let t=e.get(n);if(void 0===t){e.set(n,[{labelValue:l,counter:1}]);continue}let a=t.find(e=>e.labelValue===l);void 0===a?t.push({labelValue:l,counter:1}):a.counter+=1}return e},[i]);return{series:null==i?void 0:i.data,labelValueCounters:c,isLoading:s,isError:d,error:u}}(t,a,n);return(0,l.jsxs)(r.Z,{gap:2,...s,children:[(0,l.jsxs)(r.Z,{direction:"row",gap:3,mt:1,justifyContent:"space-between",children:[(0,l.jsxs)(r.Z,{gap:1,children:[(0,l.jsx)(V.Z,{variant:"h1",sx:{fontFamily:"monospace"},children:t}),(0,l.jsx)(V.Z,{children:"Description:"}),u?(0,l.jsx)(R.Z,{variant:"text",width:180}):(0,l.jsx)(V.Z,{style:{fontStyle:(null==d?void 0:d.help)?"initial":"italic"},children:c?"Failed to fetch metadata":(null==d?void 0:d.help)??"unknown"})]}),(0,l.jsxs)(r.Z,{gap:1,justifyContent:"center",children:[u?(0,l.jsx)(R.Z,{variant:"rounded",width:75}):c?(0,l.jsx)(D.Z,{label:"failed to fetch",color:"error",sx:{fontStyle:"italic"}}):(0,l.jsx)(Q,{label:(null==d?void 0:d.type)??"unknown"}),(0,l.jsxs)(V.Z,{children:["Result:"," ",f?(0,l.jsx)(R.Z,{variant:"text",width:20,sx:{display:"inline-block"}}):p?(0,l.jsx)("strong",{children:"failed to fetch series"}):(0,l.jsxs)("strong",{children:[(null==h?void 0:h.length)??"unknown"," series"]})]})]})]}),p?(0,l.jsx)(ei.ErrorAlert,{error:{name:`Failed to fetch series ${(null==p?void 0:p.status)&&`(${p.status})`}`,message:(null==p?void 0:p.message)??"Failed to fetch series"}}):(null==h?void 0:h.length)===0?(0,l.jsx)(r.Z,{...s,children:(0,l.jsx)(V.Z,{sx:{color:e=>e.palette.warning.main},children:"No series found with current filters."})}):(0,l.jsx)(eo,{labelValueCounters:x,onFilterAdd:i,isLoading:f})]})}var eu=n(68808);function ec(e){let{job:t,filters:n,datasource:a,isMetadataEnabled:i,onExplore:s,...o}=e,d=(0,E.useMemo)(()=>{let e=n.filter(e=>"__name__"!==e.label&&"job"!==e.label);return e.push({label:"job",labelValues:[t],operator:"="}),e},[n,t]),{data:u,isLoading:c}=N("__name__",d,a);return c?(0,l.jsx)(r.Z,{width:"100%",sx:{alignItems:"center",justifyContent:"center"},children:(0,l.jsx)(j.Z,{})}):(0,l.jsx)(z,{metricNames:(null==u?void 0:u.data)??[],datasource:a,filters:d,isMetadataEnabled:i,onExplore:s,...o})}function eh(e){let{jobs:t,filters:n,datasource:a,isMetadataEnabled:i,onExplore:s,...o}=e,[d,u]=(0,E.useState)(t[0]??"");return d?(0,l.jsxs)(r.Z,{gap:2,...o,children:[t.length>2&&(0,l.jsxs)(B.Z,{fullWidth:!0,children:[(0,l.jsx)(eu.Z,{id:"job-select-label",children:"Job"}),(0,l.jsx)(K.Z,{labelId:"job-select-label",id:"job-select",label:"Job",variant:"outlined",value:d,onChange:e=>u(e.target.value),children:t.map(e=>(0,l.jsx)(p.Z,{value:e,children:e},e))})]}),d&&(0,l.jsx)(ec,{job:d,filters:n,datasource:a,isMetadataEnabled:i,onExplore:s})]}):(0,l.jsx)(V.Z,{children:"Something went wrong..."})}function ex(e){let{filters:t,datasource:n,isMetadataEnabled:a,onExplore:i,...s}=e,{data:o,isLoading:d}=N("job",t,n);return d?(0,l.jsx)(r.Z,{width:"100%",sx:{alignItems:"center",justifyContent:"center"},children:(0,l.jsx)(j.Z,{})}):(null==o?void 0:o.data)&&0!==o.data.length?(0,l.jsx)(eh,{jobs:o.data,filters:t,datasource:n,isMetadataEnabled:a,onExplore:i,...s}):(0,l.jsx)(r.Z,{...s,children:(0,l.jsx)(V.Z,{children:"No jobs found"})})}function ef(e){let{filters:t,datasource:n,isMetadataEnabled:a,onExplore:i,...s}=e,o=(0,E.useMemo)(()=>t.filter(e=>"__name__"!==e.label),[t]),{data:d,isLoading:u}=N("__name__",o,n);return u?(0,l.jsx)(r.Z,{width:"100%",sx:{alignItems:"center",justifyContent:"center"},children:(0,l.jsx)(j.Z,{})}):(0,l.jsx)(z,{metricNames:(null==d?void 0:d.data)??[],datasource:n,filters:o,isMetadataEnabled:a,onExplore:i,...s})}function ep(e){let{metricName:t,datasource:n,filters:a,type:i,isLoading:s,...d}=e,{width:h,ref:x}=(0,u.default)(),f=(0,o.useSuggestedStepMs)(h),[p,j]=(0,E.useState)(!0),{queries:b,definitions:v}=(0,E.useMemo)(()=>{let e=[{kind:"TimeSeriesQuery",spec:{plugin:{kind:"PrometheusTimeSeriesQuery",spec:{datasource:n,query:"counter"===i||p&&(void 0===i||"summary"===i||"histogram"===i)?`rate({__name__="${t}", ${q(a)}}[5m])`:`{__name__="${t}", ${q(a)}}`}}}}],l=e.map(e=>({kind:e.spec.plugin.kind,spec:e.spec.plugin.spec}));return{queries:e,definitions:l}},[n,a,t,p,i]);return s?(0,l.jsx)(r.Z,{...d,children:(0,l.jsx)(R.Z,{variant:"rectangular",height:"100%"})}):(0,l.jsxs)(r.Z,{ref:x,alignItems:"end",...d,children:[(void 0===i||"summary"===i||"histogram"===i)&&(0,l.jsx)(m.Z,{control:(0,l.jsx)(g.Z,{size:"small"}),label:"Enable rate",checked:p,onChange:(e,t)=>j(t)}),(0,l.jsx)(o.DataQueriesProvider,{definitions:v,options:{suggestedStepMs:f,mode:"range"},children:(0,l.jsx)(c.Panel,{panelOptions:{hideHeader:!0},definition:{kind:"Panel",spec:{queries:b,display:{name:""},plugin:{kind:"TimeSeriesChart",spec:{}}}}})})]})}function em(e){let{metricName:t,datasource:n,filters:a,isMetadataEnabled:o,isPanelEnabled:d,onExplore:u,onFiltersChange:c,...h}=e,[x,f]=(0,E.useState)(0),{metadata:p,isLoading:m}=H(t,n),g=(0,E.useMemo)(()=>{let e=a.filter(e=>"__name__"!==e.label);return e.push({label:"__name__",labelValues:[t],operator:"="}),e},[a,t]);function j(e,t){null==u||u(e),void 0!==t&&f(t)}return(0,l.jsxs)(r.Z,{sx:{width:"100%"},...h,children:[d&&(0,l.jsx)(ep,{metricName:t,filters:a,datasource:n,type:null==p?void 0:p.type,height:"250px",isLoading:o&&m}),(0,l.jsxs)(i.Z,{value:x,onChange:(e,t)=>f(t),variant:"scrollable",sx:{borderBottom:1,borderColor:"divider"},children:[(0,l.jsx)(s.Z,{label:"Overview"}),(0,l.jsx)(s.Z,{label:"Job related metrics",icon:(0,l.jsx)(en.Z,{title:"All metrics scraped from the same job",placement:"top",children:(0,l.jsx)(el.default,{})}),iconPosition:"end"}),a.length>0&&(0,l.jsx)(s.Z,{label:"Similar metrics",icon:(0,l.jsx)(en.Z,{title:"All metrics matching current filters",placement:"top",children:(0,l.jsx)(el.default,{})}),iconPosition:"end"})]}),(0,l.jsxs)(r.Z,{gap:1,children:[0===x&&(0,l.jsx)(ed,{metricName:t,datasource:n,filters:g,onFilterAdd:function(e){c([...a,e])}}),1===x&&(0,l.jsx)(ex,{filters:g,datasource:n,isMetadataEnabled:o,onExplore:e=>j(e,0)}),2===x&&(0,l.jsx)(ef,{filters:g,datasource:n,isMetadataEnabled:o,onExplore:e=>j(e,0)})]})]})}let eg="PERSES_METRICS_FINDER_SETTINGS";function ej(e){let{value:t,onChange:n}=e,[a,r]=(0,E.useState)(null);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(x.Z,{"aria-label":"settings",size:"large",onClick:e=>{r(e.currentTarget)},children:(0,l.jsx)(k.default,{})}),(0,l.jsxs)(f.Z,{id:"finder-settings-menu",anchorEl:a,open:!!a,onClose:()=>{r(null)},children:[(0,l.jsx)(p.Z,{onClick:e=>e.preventDefault(),children:(0,l.jsx)(m.Z,{control:(0,l.jsx)(g.Z,{}),label:"Enable Metadata",checked:t.isMetadataEnabled,onClick:()=>n({...t,isMetadataEnabled:!t.isMetadataEnabled})})}),(0,l.jsx)(p.Z,{onClick:e=>e.preventDefault(),children:(0,l.jsx)(m.Z,{control:(0,l.jsx)(g.Z,{}),label:"Enable Time Series Chart",checked:t.isPanelEnabled,onClick:()=>n({...t,isPanelEnabled:!t.isPanelEnabled})})})]})]})}function eb(e){let{datasource:t,filters:n,isMetadataEnabled:a,onExplore:i,...s}=e,{data:o,isLoading:d,error:u}=N("__name__",n,t),[c,h]=(0,E.useState)(""),x=(0,E.useMemo)(()=>new L({includeMatches:!0,excludedChars:[" "]}),[]),f=(0,E.useMemo)(()=>{if(c&&(null==o?void 0:o.data))return x.filter(c,o.data).sort((e,t)=>t.score-e.score)},[o,x,c]);return u?(0,l.jsxs)(r.Z,{width:"100%",children:["Error: ",u.message]}):d?(0,l.jsx)(r.Z,{width:"100%",sx:{alignItems:"center",justifyContent:"center"},children:(0,l.jsx)(j.Z,{})}):(0,l.jsxs)(r.Z,{...s,children:[(0,l.jsx)(b.Z,{value:c,onChange:e=>h(e.target.value),placeholder:"Search metric name...",InputProps:{startAdornment:(0,l.jsx)(v.Z,{position:"start",children:(0,l.jsx)(_.default,{})})}}),(0,l.jsx)(z,{metricNames:(null==o?void 0:o.data)??[],filteredResults:f,datasource:t,filters:n,isMetadataEnabled:a,onExplore:i})]})}function ev(e){let{value:{datasource:t=T.Mm,filters:n=[],exploredMetric:a},onChange:i,onExplore:s,...o}=e,u=localStorage.getItem(eg),[c,h]=(0,E.useState)(u?JSON.parse(u):{isMetadataEnabled:!0}),x=(0,Z.Z)((0,C.Z)().breakpoints.down("md")),f=(0,E.useMemo)(()=>n.filter(e=>e.label&&e.labelValues.length>0),[n]),p=(0,d.useExplorerQueryParams)({data:{tab:"finder",datasource:t,filters:n,exploredMetric:void 0}});function m(e){i({datasource:t,filters:e,exploredMetric:a})}return(0,l.jsxs)(r.Z,{...o,gap:1,children:[(0,l.jsxs)(r.Z,{direction:x?"column":"row",gap:2,justifyContent:"space-between",children:[(0,l.jsx)(et,{datasource:t??T.Mm,filters:n??[],filteredFilters:f,onDatasourceChange:function(e){i({datasource:e,filters:n,exploredMetric:a})},onFiltersChange:m}),(0,l.jsxs)(r.Z,{direction:"row",gap:1,alignItems:"center",children:[a&&(0,l.jsx)(w.Z,{variant:"contained","aria-label":"back to metric explorer",startIcon:(0,l.jsx)(S.default,{}),component:I.Link,to:`?${p}`,children:"Back"}),(0,l.jsx)(r.Z,{direction:"row",sx:{width:x?"100%":"unset"},justifyContent:x?"end":"unset",alignItems:"center",children:(0,l.jsx)(ej,{value:c,onChange:function(e){h(e),localStorage.setItem(eg,JSON.stringify(e))}})})]})]}),a?(0,l.jsx)(em,{metricName:a,datasource:t??T.Mm,filters:f,isMetadataEnabled:c.isMetadataEnabled,isPanelEnabled:c.isPanelEnabled,onFiltersChange:m,onExplore:s}):(0,l.jsx)(eb,{datasource:t??T.Mm,filters:f,isMetadataEnabled:c.isMetadataEnabled,onExplore:s})]})}function eZ(e){let{queries:t}=e,{width:n,ref:r}=(0,u.default)(),i=(0,o.useSuggestedStepMs)(n),s=t.length?t.map(e=>({kind:e.spec.plugin.kind,spec:e.spec.plugin.spec})):[];return(0,l.jsx)(a.Z,{ref:r,height:700,children:(0,l.jsx)(o.DataQueriesProvider,{definitions:s,options:{suggestedStepMs:i,mode:"range"},children:(0,l.jsx)(c.Panel,{panelOptions:{hideHeader:!0},definition:{kind:"Panel",spec:{queries:t,display:{name:""},plugin:{kind:"TimeSeriesChart",spec:{}}}}})})})}function eC(e){let{queries:t}=e,n=t.map(e=>({kind:e.spec.plugin.kind,spec:e.spec.plugin.spec}));return(0,l.jsx)(a.Z,{height:700,children:(0,l.jsx)(o.DataQueriesProvider,{definitions:n,options:{mode:"instant"},children:(0,l.jsx)(c.Panel,{panelOptions:{hideHeader:!0},definition:{kind:"Panel",spec:{queries:t,display:{name:""},plugin:{kind:"TimeSeriesTable",spec:{}}}}})})})}function ew(){let{data:{tab:e="table",queries:t=[],datasource:n=h.Mm,filters:a=[],exploredMetric:u},setData:c}=(0,d.useExplorerManagerContext)();return(0,l.jsxs)(r.Z,{gap:2,sx:{width:"100%"},children:[(0,l.jsxs)(i.Z,{value:e,onChange:(e,n)=>c({tab:n,queries:t}),variant:"scrollable",sx:{borderBottom:1,borderColor:"divider"},children:[(0,l.jsx)(s.Z,{value:"table",label:"Table"}),(0,l.jsx)(s.Z,{value:"graph",label:"Graph"}),(0,l.jsx)(s.Z,{value:"finder",label:"Finder"})]}),(0,l.jsxs)(r.Z,{gap:1,children:["table"===e&&(0,l.jsxs)(r.Z,{children:[(0,l.jsx)(o.MultiQueryEditor,{queryTypes:["TimeSeriesQuery"],onChange:t=>c({tab:e,queries:t}),queries:t}),(0,l.jsx)(eC,{queries:t})]}),"graph"===e&&(0,l.jsxs)(r.Z,{children:[(0,l.jsx)(o.MultiQueryEditor,{queryTypes:["TimeSeriesQuery"],onChange:t=>c({tab:e,queries:t}),queries:t}),(0,l.jsx)(eZ,{queries:t})]}),"finder"===e&&(0,l.jsx)(r.Z,{children:(0,l.jsx)(ev,{onChange:t=>c({tab:e,...t}),value:{datasource:n,filters:a,exploredMetric:u}})})]})]})}},87629:function(e,t,n){function l(e){let[t,n]=e;return[1e3*t,function(e){let t;switch(e){case"+Inf":t=Number.POSITIVE_INFINITY;break;case"-Inf":t=Number.NEGATIVE_INFINITY;break;default:t=parseFloat(e)}return t}(n)]}n.d(t,{X2:()=>u,mB:()=>h,mY:()=>o,k7:()=>C,c4:()=>r,Nr:()=>i,Mm:()=>g.Mm,Fp:()=>s,Rv:()=>g.Rv,sv:()=>g.sv,ac:()=>c,qJ:()=>l,nY:()=>g.nY,Bf:()=>v,PL:()=>d,wd:()=>Z});var a=n(35015);function r(e){return async()=>{let t=`${e.datasourceUrl}/-/healthy`;try{let n=await (0,a.he)(t,{headers:e.headers});return 200===n.status}catch{return!1}}}function i(e,t){return f("/api/v1/query",e,t)}function s(e,t){return f("/api/v1/query_range",e,t)}function o(e,t){return f("/api/v1/labels",e,t)}function d(e,t){let{labelName:n,...l}=e;return 0===n.length?new Promise(e=>{e({data:[]})}):x(`/api/v1/label/${encodeURIComponent(n)}/values`,l,t)}function u(e,t){return x("/api/v1/metadata",e,t)}function c(e,t){return f("/api/v1/series",e,t)}function h(e,t){return f("/api/v1/parse_query",e,t)}function x(e,t,n){let{datasourceUrl:l,headers:r}=n,i=`${l}${e}`,s=p(t).toString();return""!==s&&(i+=`?${s}`),(0,a.rd)(i,{method:"GET",headers:r})}function f(e,t,n){let{datasourceUrl:l,headers:a}=n;return m(`${l}${e}`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...a},body:p(t)})}function p(e){let t=new URLSearchParams;for(let n in e){let l=e[n];if(void 0!==l){if("string"==typeof l){t.append(n,l);continue}if("number"==typeof l){t.append(n,l.toString());continue}for(let e of l)t.append(n,e)}}return t}async function m(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let l=await (0,a.he)(...t);return{...await l.json(),rawResponse:l}}var g=n(65456),j=n(29085),b=n(20461);function v(e){let{start:t,end:n}=e;return{start:Math.ceil((0,b.getUnixTime)(t)),end:Math.ceil((0,b.getUnixTime)(n))}}function Z(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=(e.end-e.start)/1e4;return a>1&&(a=Math.ceil(a)),Math.max(l/1e3*n,t,a)}function C(e){if(!e)return;let t=(0,j.Ib)(e);return Math.floor((0,b.milliseconds)(t)/1e3)}},65456:function(e,t,n){n.d(t,{Mm:()=>r,Rv:()=>i,nY:()=>a,sv:()=>s});var l=n(58891);let a="PrometheusDatasource",r={kind:a};function i(e){return!(0,l.isVariableDatasource)(e)&&void 0===e.name}function s(e){return(0,l.isVariableDatasource)(e)||e.kind===a}}}]);
1
+ "use strict";(self.webpackChunkPrometheus=self.webpackChunkPrometheus||[]).push([["5742"],{35015:function(e,t,n){async function l(...e){let t=await n.g.fetch(...e);if(!1===t.ok){let e=t.headers.get("content-type");if(e?.includes("application/json")){let e=await t.json();if(e.error)throw new i(e.error,t.status);if(e.message)throw new i(e.message,t.status)}let n=await t.text();if(n)throw new i(n,t.status);throw new r(t)}return t}async function a(...e){let t=await l(...e);return await t.json()}n.d(t,{he:()=>l,rd:()=>a});class r extends Error{status;constructor(e){super(`${e.status} ${e.statusText}`),this.status=e.status,Object.setPrototypeOf(this,r.prototype)}}class i extends Error{status;constructor(e,t){super(e),this.status=t,Object.setPrototypeOf(this,i.prototype)}}},30666:function(e,t,n){t.default=void 0;var l,a=(l=n(30265))&&l.__esModule?l:{default:l};t.default=(0,a.default)("M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z","ArrowLeft")},82562:function(e,t,n){t.default=void 0;var l,a=(l=n(30265))&&l.__esModule?l:{default:l};t.default=(0,a.default)("M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z","Check")},77463:function(e,t,n){t.default=void 0;var l,a=(l=n(30265))&&l.__esModule?l:{default:l};t.default=(0,a.default)("M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z","Cog")},50737:function(e,t,n){t.default=void 0;var l,a=(l=n(30265))&&l.__esModule?l:{default:l};t.default=(0,a.default)("M14.19,14.19L6,18L9.81,9.81L18,6M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,10.9A1.1,1.1 0 0,0 10.9,12A1.1,1.1 0 0,0 12,13.1A1.1,1.1 0 0,0 13.1,12A1.1,1.1 0 0,0 12,10.9Z","Compass")},88160:function(e,t,n){t.default=void 0;var l,a=(l=n(30265))&&l.__esModule?l:{default:l};t.default=(0,a.default)("M11,18H13V16H11V18M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,6A4,4 0 0,0 8,10H10A2,2 0 0,1 12,8A2,2 0 0,1 14,10C14,12 11,11.75 11,15H13C13,12.75 16,12.5 16,10A4,4 0 0,0 12,6Z","HelpCircleOutline")},66268:function(e,t,n){t.default=void 0;var l,a=(l=n(30265))&&l.__esModule?l:{default:l};t.default=(0,a.default)("M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z","Magnify")},27472:function(e,t,n){n.r(t),n.d(t,{PrometheusExplorer:()=>ew});var l=n(24246),a=n(36372),r=n(25283),i=n(51781),s=n(49408),o=n(58891),d=n(90382),u=n(75276),c=n(32600),h=n(65456),x=n(75094),f=n(5549),p=n(10517),m=n(28797),g=n(82707),j=n(50898),b=n(8695),v=n(76992),Z=n(76439),C=n(94776),w=n(48565);function y(e){return e.to-e.from+1}function M(e,t){let n=e[t],l=null;return 0===t&&0!==n.from&&(l={from:0,to:n.from-1}),t>0&&(l={from:e[t-1].to+1,to:n.from-1}),l}class L{constructor(e){this.conf={caseSensitive:(null==e?void 0:e.caseSensitive)!==void 0&&e.caseSensitive,excludedChars:(null==e?void 0:e.excludedChars)===void 0?[]:e.excludedChars,includeMatches:(null==e?void 0:e.includeMatches)!==void 0&&e.includeMatches,shouldSort:(null==e?void 0:e.shouldSort)!==void 0&&e.shouldSort,shouldRender:(null==e?void 0:e.shouldRender)===void 0||e.shouldRender,escapeHTML:(null==e?void 0:e.escapeHTML)!==void 0&&e.escapeHTML,pre:(null==e?void 0:e.pre)===void 0?"":e.pre,post:(null==e?void 0:e.post)===void 0?"":e.post}}filter(e,t,n){let l=(null==n?void 0:n.shouldSort)!==void 0?n.shouldSort:this.conf.shouldSort,a=[];for(let l=0;l<t.length;l++){let r=this.match(e,t[l],n);null!==r&&(r.index=l,a.push(r))}return l&&(a=a.sort((e,t)=>t.score-e.score)),a}match(e,t,n){let l=e,a=t,r=(null==n?void 0:n.caseSensitive)!==void 0?n.caseSensitive:this.conf.caseSensitive,i=(null==n?void 0:n.includeMatches)!==void 0?n.includeMatches:this.conf.includeMatches,s=(null==n?void 0:n.shouldRender)!==void 0?n.shouldRender:this.conf.shouldRender;if(r||(l=l.toLowerCase(),a=a.toLowerCase()),l===a){let l=[{from:0,to:e.length-1}],a={original:t,rendered:s?this.render(t,l,n):t,score:1/0};return i&&(a.intervals=l),a}let o=[],d=0;for(let e=0;e<a.length-l.length+1;e++)if(a[e]===l[0]){let t=this.generateMatchingInterval(l,a,e,n);if(null===t)break;t.score>d&&(d=t.score,o=t.intervals)}if(0===o.length)return null;let u={original:t,rendered:s?this.render(t,o,n):t,score:d};return i&&(u.intervals=o),u}render(e,t,n){if(0==t.length)return e;let l="",a=(null==n?void 0:n.pre)?n.pre:this.conf.pre,r=(null==n?void 0:n.post)?n.post:this.conf.post;for(let i=0;i<t.length;i++){let s=t[i],o=M(t,i),d="";null!==o&&(d=this.extractSubString(e,o,n));let u=this.extractSubString(e,s,n);l=`${l}${d}${a}${u}${r}`}let i=t[t.length-1];return i.to<e.length-1&&(l+=this.extractSubString(e,{from:i.to+1,to:e.length},n)),l}extractSubString(e,t,n){let l=(null==n?void 0:n.escapeHTML)!==void 0?n.escapeHTML:this.conf.escapeHTML,a=e.substr(t.from,y(t));return l&&(a=a.replace(/[&<>"']/g,e=>{switch(e){case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";case'"':return"&quot;";default:return"&#039;"}})),a}generateMatchingInterval(e,t,n,l){let a=[];(null==l?void 0:l.excludedChars)!==void 0?a=l.excludedChars:void 0!==this.conf.excludedChars&&(a=this.conf.excludedChars);let r=0,i=[];for(let l=n;l<t.length&&r<e.length;){if(a.includes(t[l])){l++;continue}if(a.includes(e[r])){r++;continue}if(t[l]===e[r]){let n={from:l,to:l};r++,l++;for(let a=l;a<t.length&&r<e.length&&t[a]===e[r];a++)n.to=a,r++,l=a;i.push(n)}l++}return 0===i.length||r!==e.length?null:{score:function(e,t){let n=0;for(let l=0;l<e.length;l++){let a=e[l],r=M(e,l);null!==r&&(n-=y(r)/t),n+=y(a)**2}return n}(i,t.length),intervals:i}}}new L;var S=n(30666),k=n(77463),_=n(66268),E=n(54538),I=n(67430),T=n(87629),A=n(96205),V=n(52054),R=n(66224),P=n(79119),$=n(50737),O=n(83675),F=n(91909);function q(e){return`${e.map(e=>`${e.label}${e.operator}"${e.labelValues.join("|")}"`).join(",")}`}function H(e,t,n){let{data:l}=(0,o.useDatasourceClient)(t),a=e.replace(/(_count|_sum|_bucket)$/,""),{data:r,isLoading:i,error:s}=(0,F.useQuery)({enabled:!!l&&n,queryKey:["metricMetadata",a],queryFn:async()=>await l.metricMetadata({metric:a})});return{metadata:(0,E.useMemo)(()=>{var e;for(let t of(null==r?void 0:null===(e=r.data)||void 0===e?void 0:e[a])??[])if(t.help.length>0)return t},[r,a]),isLoading:i,error:s}}function N(e,t,n){let{absoluteTimeRange:{start:l,end:a}}=(0,o.useTimeRange)(),{data:r}=(0,o.useDatasourceClient)(n);return(0,F.useQuery)({enabled:!!r,queryKey:["labelValues",e,"datasource",n.name,"start",l,"end","filters",...t],queryFn:async()=>{let n={labelName:e,start:l.valueOf()/1e3,end:a.valueOf()/1e3};return t.length&&(n["match[]"]=[`{${q(t)}}`]),await r.labelValues(n)}})}var D=n(52889);function Q(e){let{label:t,...n}=e;return"gauge"===t?(0,l.jsx)(D.Z,{label:t,color:"success",...n}):"counter"===t?(0,l.jsx)(D.Z,{label:t,color:"primary",...n}):"histogram"===t?(0,l.jsx)(D.Z,{label:t,color:"warning",...n}):"summary"===t?(0,l.jsx)(D.Z,{label:t,color:"secondary",...n}):(0,l.jsx)(D.Z,{label:t,sx:{fontStyle:"unknown"===t?"italic":"initial"},...n})}function W(e){let{children:t,metricName:n,datasource:a,filters:r,isMetadataEnabled:i,onExplore:s}=e,{metadata:o,isLoading:u}=H(n,a,i),c=(0,d.useExplorerQueryParams)({data:{tab:"finder",datasource:a,filters:r,exploredMetric:n}});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(A.Z,{style:{width:"300px"},children:(0,l.jsx)(V.Z,{sx:{fontFamily:"monospace"},children:t??n})}),(0,l.jsx)(A.Z,{style:{width:115,textAlign:"center"},children:i&&u?(0,l.jsx)(R.Z,{variant:"rounded",width:75}):(0,l.jsx)(Q,{label:(null==o?void 0:o.type)??"unknown"})}),(0,l.jsx)(A.Z,{style:{width:"100%"},children:i&&u?(0,l.jsx)(R.Z,{variant:"text",width:180}):(0,l.jsx)(V.Z,{sx:{fontStyle:(null==o?void 0:o.help)?"initial":"italic",minWidth:"30vw"},children:o?o.help:"unknown"})}),(0,l.jsx)(A.Z,{style:{width:140},children:(0,l.jsx)(w.Z,{"aria-label":`explore metric ${n}`,variant:"contained",startIcon:(0,l.jsx)($.default,{}),style:{textWrap:"nowrap"},onClick:()=>null==s?void 0:s(n),component:I.Link,to:`?${c}`,children:"Explore"})})]})}function z(e){let{metricNames:t,filteredResults:n,datasource:a,filters:i,isMetadataEnabled:s,onExplore:o,...d}=e,u=new L,c=(0,E.useMemo)(()=>n||t.map(e=>({original:e})),[n,t]);return(0,l.jsxs)(r.Z,{gap:2,width:"100%",divider:(0,l.jsx)(P.Z,{orientation:"horizontal",flexItem:!0}),...d,children:[(0,l.jsx)(O._n,{style:{height:"70vh",width:"100%"},totalCount:c.length,itemContent:e=>(0,l.jsx)(W,{metricName:c[e].original,datasource:a,filters:i,isMetadataEnabled:s,onExplore:o,children:(0,l.jsx)("span",{dangerouslySetInnerHTML:{__html:u.render(c[e].original,c[e].intervals??[],{pre:'<strong style="color:darkorange">',post:"</strong>",escapeHTML:!0})}})})}),(0,l.jsx)(r.Z,{sx:{width:"100%"},textAlign:"end",children:(0,l.jsxs)(V.Z,{"data-testid":"finder-total",children:["Total: ",(0,l.jsx)("strong",{children:t.length})," metrics"]})})]})}var B=n(90192),Y=n(33755),J=n(11774),K=n(63767),U=n(80354);function G(e){let{datasource:t,value:n,filters:a,onChange:r,onDelete:i}=e,s=(0,E.useMemo)(()=>a.filter(e=>e.label!==n.label),[a,n.label]),{data:d,isLoading:u}=function(e,t){let{absoluteTimeRange:{start:n,end:l}}=(0,o.useTimeRange)(),{data:a}=(0,o.useDatasourceClient)(t);return(0,F.useQuery)({enabled:!!a,queryKey:["labels","datasource",t.name,"start",n,"end",l,"filters",...e],queryFn:async()=>{let t={start:n.valueOf()/1e3,end:l.valueOf()/1e3};return e.length&&(t["match[]"]=[`{${q(e)}}`]),await a.labelNames(t)}})}(s,t),{data:c,isLoading:h}=N(n.label,s,t);return(0,l.jsx)(ee,{value:n,labelOptions:(null==d?void 0:d.data)??[],labelValuesOptions:(null==c?void 0:c.data)??[],isLabelOptionsLoading:u,isLabelValuesOptionsLoading:h,onChange:r,onDelete:i})}let X=(0,E.forwardRef)((e,t)=>{let{children:n,...a}=e,r=(0,E.useRef)("500px"),[i,s]=(0,E.useState)(0);return(0,l.jsx)("ul",{style:{overflow:"hidden",padding:"0",height:i?`min(40vh, ${i}px)`:"40vh"},ref:e=>{let n=e?getComputedStyle(e).maxHeight:null;n&&n!==r.current&&(r.current=n),"function"==typeof t&&t(e)},...a,children:(0,l.jsx)(O.OO,{style:{height:r.current,padding:"10px 0"},data:n,totalListHeightChanged:s,itemContent:(e,t)=>(0,E.cloneElement)(t,{index:e,title:t.props.children})})})});function ee(e){let{value:t,labelOptions:n,labelValuesOptions:a,isLabelOptionsLoading:i,isLabelValuesOptionsLoading:s,onChange:o,onDelete:d}=e;return(0,l.jsxs)(r.Z,{gap:0,flexDirection:"row",alignItems:"center",children:[(0,l.jsx)(J.Z,{freeSolo:!0,disableClearable:!0,options:n??[],value:t.label,sx:{minWidth:200},ListboxComponent:X,loading:i,renderInput:e=>(0,l.jsx)(b.Z,{...e,label:"Label Name",variant:"outlined",fullWidth:!0,size:"medium",sx:{"& .MuiOutlinedInput-root":{borderTopRightRadius:0,borderBottomRightRadius:0}}}),onInputChange:(e,n)=>{o({label:n??"",labelValues:t.labelValues,operator:t.operator})}}),(0,l.jsxs)(K.Z,{value:t.operator,variant:"outlined",onChange:e=>{o({label:t.label,labelValues:t.labelValues,operator:e.target.value})},size:"medium",sx:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderTopRightRadius:0,borderBottomRightRadius:0},children:[(0,l.jsx)(p.Z,{value:"=",children:"="}),(0,l.jsx)(p.Z,{value:"!=",children:"!="}),(0,l.jsx)(p.Z,{value:"=~",children:"=~"}),(0,l.jsx)(p.Z,{value:"!~",children:"!~"})]}),(0,l.jsx)(J.Z,{freeSolo:!0,multiple:"=~"===t.operator||"!~"===t.operator,limitTags:1,disableClearable:!0,options:a??[],value:t.labelValues,ListboxComponent:X,sx:{minWidth:200},loading:s,renderInput:e=>(0,l.jsx)(b.Z,{...e,label:"=~"===t.operator||"!~"===t.operator?"Label Values":"Label Value",variant:"outlined",fullWidth:!0,size:"medium",sx:{"& .MuiOutlinedInput-root":{borderTopLeftRadius:0,borderBottomLeftRadius:0}},slotProps:{input:{...e.InputProps,style:{maxHeight:"53.13px"},endAdornment:(0,l.jsxs)(v.Z,{position:"end",children:[s?(0,l.jsx)(j.Z,{color:"inherit",size:20}):null,(0,l.jsx)(x.Z,{"aria-label":"delete label filter",onClick:()=>d(),edge:"end",children:(0,l.jsx)(U.default,{})})]})}}}),onInputChange:(e,n)=>{("="===t.operator||"!="===t.operator)&&o({label:t.label,labelValues:[n],operator:t.operator})},onChange:(e,n)=>{Array.isArray(n)&&o({label:t.label,labelValues:n,operator:t.operator})}})]})}function et(e){let{datasource:t,filters:n,filteredFilters:a,onDatasourceChange:i,onFiltersChange:s,...d}=e,{data:u}=(0,o.useListDatasourceSelectItems)(h.nY);return(0,l.jsxs)(r.Z,{...d,direction:"row",alignItems:"center",flexWrap:"wrap",gap:1,sx:{width:"100%"},children:[(0,l.jsx)(B.Z,{sx:{width:500},children:(0,l.jsx)(o.DatasourceSelect,{size:"medium",datasourcePluginKind:h.nY,value:t,onChange:function(e){i((0,o.datasourceSelectValueToSelector)(e,{},u)??{kind:h.nY})},label:"Prometheus Datasource",fullWidth:!0})}),n.map((e,r)=>(0,l.jsx)(G,{datasource:t,filters:a,value:e,onChange:e=>{let t=[...n];t[r]=e,s(t)},onDelete:()=>{let e=[...n];e.splice(r,1),s(e)}},r)),(0,l.jsx)(w.Z,{startIcon:(0,l.jsx)(Y.default,{}),"aria-label":"add filter",onClick:()=>{s([...n,{label:"",labelValues:[""],operator:"="}])},children:"Add filter"})]})}X.displayName="ListboxComponent";var en=n(32964),el=n(88160),ea=n(82562),er=n(10763),ei=n(72629);function es(e){let{label:t,valueCounters:n,onFilterAdd:a,...i}=e,[s,o]=(0,E.useState)(!1),[d,u]=(0,E.useState)("="),[c,h]=(0,E.useState)(""),[f,m]=(0,E.useState)(!1),g=(0,Z.Z)((0,C.Z)().breakpoints.down("md")),j=(0,E.useMemo)(()=>f?n:n.slice(0,5),[f,n]);return(0,l.jsxs)(r.Z,{sx:{width:"100%"},direction:g?"column":"row",alignItems:"center",gap:2,...i,children:[(0,l.jsxs)(r.Z,{sx:{width:"100%",height:"100%"},justifyContent:"space-between",alignContent:"center",direction:g?"column":"row",children:[(0,l.jsx)(V.Z,{sx:{fontFamily:"monospace"},pl:+!g,children:t}),(0,l.jsx)(r.Z,{direction:"row",gap:1,alignItems:"center",children:s?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(K.Z,{size:"small",value:d,variant:"outlined",onChange:e=>{u(e.target.value)},children:[(0,l.jsx)(p.Z,{value:"=",children:"="}),(0,l.jsx)(p.Z,{value:"!=",children:"!="}),(0,l.jsx)(p.Z,{value:"=~",children:"=~"}),(0,l.jsx)(p.Z,{value:"!~",children:"!~"})]}),(0,l.jsx)(J.Z,{freeSolo:!0,limitTags:1,disableClearable:!0,options:n.map(e=>e.labelValue),value:c,ListboxComponent:X,sx:{width:250},renderInput:e=>(0,l.jsx)(b.Z,{...e,label:"Value",variant:"outlined",fullWidth:!0,size:"small"}),onInputChange:(e,t)=>{h(t)}}),(0,l.jsx)(x.Z,{"aria-label":"confirm",onClick:()=>{a({label:t,labelValues:[c],operator:d}),o(!1)},children:(0,l.jsx)(ea.default,{})}),(0,l.jsx)(x.Z,{"aria-label":"cancel",onClick:()=>{o(!1)},children:(0,l.jsx)(er.default,{})})]}):(0,l.jsx)(w.Z,{startIcon:(0,l.jsx)(Y.default,{}),"aria-label":"add filter",onClick:()=>o(!0),children:"Add filter"})})]}),(0,l.jsxs)(r.Z,{sx:{width:"100%"},gap:.5,children:[(0,l.jsx)(r.Z,{direction:"row",gap:2,children:(0,l.jsxs)(V.Z,{variant:"subtitle1",children:[n.length," values"]})}),(0,l.jsx)(r.Z,{sx:{overflow:g?"auto":"unset"},children:j.map(e=>(0,l.jsxs)(r.Z,{direction:"row",gap:2,children:[(0,l.jsx)(V.Z,{sx:{color:e=>e.palette.success.main,fontFamily:"monospace",":hover":{backgroundColor:"rgba(127,127,127,0.35)",cursor:"pointer"},textWrap:g?"nowrap":"unset"},onClick:()=>a({label:t,labelValues:[e.labelValue],operator:"="}),children:e.labelValue}),(0,l.jsxs)(V.Z,{sx:{textWrap:"nowrap"},children:["(",e.counter," series)"]})]},`${t}-${e.labelValue}`))}),(0,l.jsx)(r.Z,{width:"100%",textAlign:g?"center":"unset",children:f?(0,l.jsx)(w.Z,{variant:"text",sx:{width:"fit-content"},onClick:()=>m(!1),children:"Hide full values"}):(0,l.jsx)(l.Fragment,{children:n.length>5&&(0,l.jsxs)(w.Z,{variant:"text",sx:{width:"fit-content"},onClick:()=>m(!0),children:["Show ",n.length-5," more values"]})})})]})]},t)}function eo(e){let{labelValueCounters:t,isLoading:n,onFilterAdd:a,...i}=e,s=(0,E.useMemo)(()=>[...t.keys()].sort(),[t]);return n?(0,l.jsx)(r.Z,{width:"100%",sx:{alignItems:"center",justifyContent:"center"},children:(0,l.jsx)(j.Z,{})}):(0,l.jsxs)(r.Z,{sx:{width:"100%"},divider:(0,l.jsx)(P.Z,{flexItem:!0,orientation:"horizontal"}),gap:2,...i,children:[(0,l.jsxs)(r.Z,{gap:2,direction:"row",sx:{width:"100%"},children:[(0,l.jsx)(r.Z,{sx:{width:"100%"},children:(0,l.jsx)(V.Z,{variant:"h3",children:"Label"})}),(0,l.jsx)(r.Z,{sx:{width:"100%"},children:(0,l.jsx)(V.Z,{variant:"h3",children:"Values"})})]}),s.map(e=>(0,l.jsx)(es,{label:e,valueCounters:t.get(e)??[],onFilterAdd:a},e))]})}function ed(e){let{metricName:t,datasource:n,filters:a,onFilterAdd:i,...s}=e,{metadata:d,isLoading:u,error:c}=H(t,n),{series:h,labelValueCounters:x,isLoading:f,error:p}=function(e,t,n){let{absoluteTimeRange:{start:l,end:a}}=(0,o.useTimeRange)(),{data:r}=(0,o.useDatasourceClient)(n),{data:i,isLoading:s,isError:d,error:u}=(0,F.useQuery)({enabled:!!r,queryKey:["series",e,"datasource",n,"start",l,"end","filters",...t],queryFn:async()=>{let e={"match[]":[`{${q(t)}}`],start:l.valueOf()/1e3,end:a.valueOf()/1e3};return await r.series(e)}}),c=(0,E.useMemo)(()=>{let e=new Map;if((null==i?void 0:i.data)===void 0)return e;for(let t of i.data)for(let[n,l]of Object.entries(t)){let t=e.get(n);if(void 0===t){e.set(n,[{labelValue:l,counter:1}]);continue}let a=t.find(e=>e.labelValue===l);void 0===a?t.push({labelValue:l,counter:1}):a.counter+=1}return e},[i]);return{series:null==i?void 0:i.data,labelValueCounters:c,isLoading:s,isError:d,error:u}}(t,a,n);return(0,l.jsxs)(r.Z,{gap:2,...s,children:[(0,l.jsxs)(r.Z,{direction:"row",gap:3,mt:1,justifyContent:"space-between",children:[(0,l.jsxs)(r.Z,{gap:1,children:[(0,l.jsx)(V.Z,{variant:"h1",sx:{fontFamily:"monospace"},children:t}),(0,l.jsx)(V.Z,{children:"Description:"}),u?(0,l.jsx)(R.Z,{variant:"text",width:180}):(0,l.jsx)(V.Z,{style:{fontStyle:(null==d?void 0:d.help)?"initial":"italic"},children:c?"Failed to fetch metadata":(null==d?void 0:d.help)??"unknown"})]}),(0,l.jsxs)(r.Z,{gap:1,justifyContent:"center",children:[u?(0,l.jsx)(R.Z,{variant:"rounded",width:75}):c?(0,l.jsx)(D.Z,{label:"failed to fetch",color:"error",sx:{fontStyle:"italic"}}):(0,l.jsx)(Q,{label:(null==d?void 0:d.type)??"unknown"}),(0,l.jsxs)(V.Z,{children:["Result:"," ",f?(0,l.jsx)(R.Z,{variant:"text",width:20,sx:{display:"inline-block"}}):p?(0,l.jsx)("strong",{children:"failed to fetch series"}):(0,l.jsxs)("strong",{children:[(null==h?void 0:h.length)??"unknown"," series"]})]})]})]}),p?(0,l.jsx)(ei.ErrorAlert,{error:{name:`Failed to fetch series ${(null==p?void 0:p.status)&&`(${p.status})`}`,message:(null==p?void 0:p.message)??"Failed to fetch series"}}):(null==h?void 0:h.length)===0?(0,l.jsx)(r.Z,{...s,children:(0,l.jsx)(V.Z,{sx:{color:e=>e.palette.warning.main},children:"No series found with current filters."})}):(0,l.jsx)(eo,{labelValueCounters:x,onFilterAdd:i,isLoading:f})]})}var eu=n(68808);function ec(e){let{job:t,filters:n,datasource:a,isMetadataEnabled:i,onExplore:s,...o}=e,d=(0,E.useMemo)(()=>{let e=n.filter(e=>"__name__"!==e.label&&"job"!==e.label);return e.push({label:"job",labelValues:[t],operator:"="}),e},[n,t]),{data:u,isLoading:c}=N("__name__",d,a);return c?(0,l.jsx)(r.Z,{width:"100%",sx:{alignItems:"center",justifyContent:"center"},children:(0,l.jsx)(j.Z,{})}):(0,l.jsx)(z,{metricNames:(null==u?void 0:u.data)??[],datasource:a,filters:d,isMetadataEnabled:i,onExplore:s,...o})}function eh(e){let{jobs:t,filters:n,datasource:a,isMetadataEnabled:i,onExplore:s,...o}=e,[d,u]=(0,E.useState)(t[0]??"");return d?(0,l.jsxs)(r.Z,{gap:2,...o,children:[t.length>2&&(0,l.jsxs)(B.Z,{fullWidth:!0,children:[(0,l.jsx)(eu.Z,{id:"job-select-label",children:"Job"}),(0,l.jsx)(K.Z,{labelId:"job-select-label",id:"job-select",label:"Job",variant:"outlined",value:d,onChange:e=>u(e.target.value),children:t.map(e=>(0,l.jsx)(p.Z,{value:e,children:e},e))})]}),d&&(0,l.jsx)(ec,{job:d,filters:n,datasource:a,isMetadataEnabled:i,onExplore:s})]}):(0,l.jsx)(V.Z,{children:"Something went wrong..."})}function ex(e){let{filters:t,datasource:n,isMetadataEnabled:a,onExplore:i,...s}=e,{data:o,isLoading:d}=N("job",t,n);return d?(0,l.jsx)(r.Z,{width:"100%",sx:{alignItems:"center",justifyContent:"center"},children:(0,l.jsx)(j.Z,{})}):(null==o?void 0:o.data)&&0!==o.data.length?(0,l.jsx)(eh,{jobs:o.data,filters:t,datasource:n,isMetadataEnabled:a,onExplore:i,...s}):(0,l.jsx)(r.Z,{...s,children:(0,l.jsx)(V.Z,{children:"No jobs found"})})}function ef(e){let{filters:t,datasource:n,isMetadataEnabled:a,onExplore:i,...s}=e,o=(0,E.useMemo)(()=>t.filter(e=>"__name__"!==e.label),[t]),{data:d,isLoading:u}=N("__name__",o,n);return u?(0,l.jsx)(r.Z,{width:"100%",sx:{alignItems:"center",justifyContent:"center"},children:(0,l.jsx)(j.Z,{})}):(0,l.jsx)(z,{metricNames:(null==d?void 0:d.data)??[],datasource:n,filters:o,isMetadataEnabled:a,onExplore:i,...s})}function ep(e){let{metricName:t,datasource:n,filters:a,type:i,isLoading:s,...d}=e,{width:h,ref:x}=(0,u.default)(),f=(0,o.useSuggestedStepMs)(h),[p,j]=(0,E.useState)(!0),{queries:b,definitions:v}=(0,E.useMemo)(()=>{let e=[{kind:"TimeSeriesQuery",spec:{plugin:{kind:"PrometheusTimeSeriesQuery",spec:{datasource:n,query:"counter"===i||p&&(void 0===i||"summary"===i||"histogram"===i)?`rate({__name__="${t}", ${q(a)}}[5m])`:`{__name__="${t}", ${q(a)}}`}}}}],l=e.map(e=>({kind:e.spec.plugin.kind,spec:e.spec.plugin.spec}));return{queries:e,definitions:l}},[n,a,t,p,i]);return s?(0,l.jsx)(r.Z,{...d,children:(0,l.jsx)(R.Z,{variant:"rectangular",height:"100%"})}):(0,l.jsxs)(r.Z,{ref:x,alignItems:"end",...d,children:[(void 0===i||"summary"===i||"histogram"===i)&&(0,l.jsx)(m.Z,{control:(0,l.jsx)(g.Z,{size:"small"}),label:"Enable rate",checked:p,onChange:(e,t)=>j(t)}),(0,l.jsx)(o.DataQueriesProvider,{definitions:v,options:{suggestedStepMs:f,mode:"range"},children:(0,l.jsx)(c.Panel,{panelOptions:{hideHeader:!0},definition:{kind:"Panel",spec:{queries:b,display:{name:""},plugin:{kind:"TimeSeriesChart",spec:{}}}}})})]})}function em(e){let{metricName:t,datasource:n,filters:a,isMetadataEnabled:o,isPanelEnabled:d,onExplore:u,onFiltersChange:c,...h}=e,[x,f]=(0,E.useState)(0),{metadata:p,isLoading:m}=H(t,n),g=(0,E.useMemo)(()=>{let e=a.filter(e=>"__name__"!==e.label);return e.push({label:"__name__",labelValues:[t],operator:"="}),e},[a,t]);function j(e,t){null==u||u(e),void 0!==t&&f(t)}return(0,l.jsxs)(r.Z,{sx:{width:"100%"},...h,children:[d&&(0,l.jsx)(ep,{metricName:t,filters:a,datasource:n,type:null==p?void 0:p.type,height:"250px",isLoading:o&&m}),(0,l.jsxs)(i.Z,{value:x,onChange:(e,t)=>f(t),variant:"scrollable",sx:{borderBottom:1,borderColor:"divider"},children:[(0,l.jsx)(s.Z,{label:"Overview"}),(0,l.jsx)(s.Z,{label:"Job related metrics",icon:(0,l.jsx)(en.Z,{title:"All metrics scraped from the same job",placement:"top",children:(0,l.jsx)(el.default,{})}),iconPosition:"end"}),a.length>0&&(0,l.jsx)(s.Z,{label:"Similar metrics",icon:(0,l.jsx)(en.Z,{title:"All metrics matching current filters",placement:"top",children:(0,l.jsx)(el.default,{})}),iconPosition:"end"})]}),(0,l.jsxs)(r.Z,{gap:1,children:[0===x&&(0,l.jsx)(ed,{metricName:t,datasource:n,filters:g,onFilterAdd:function(e){c([...a,e])}}),1===x&&(0,l.jsx)(ex,{filters:g,datasource:n,isMetadataEnabled:o,onExplore:e=>j(e,0)}),2===x&&(0,l.jsx)(ef,{filters:g,datasource:n,isMetadataEnabled:o,onExplore:e=>j(e,0)})]})]})}let eg="PERSES_METRICS_FINDER_SETTINGS";function ej(e){let{value:t,onChange:n}=e,[a,r]=(0,E.useState)(null);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(x.Z,{"aria-label":"settings",size:"large",onClick:e=>{r(e.currentTarget)},children:(0,l.jsx)(k.default,{})}),(0,l.jsxs)(f.Z,{id:"finder-settings-menu",anchorEl:a,open:!!a,onClose:()=>{r(null)},children:[(0,l.jsx)(p.Z,{onClick:e=>e.preventDefault(),children:(0,l.jsx)(m.Z,{control:(0,l.jsx)(g.Z,{}),label:"Enable Metadata",checked:t.isMetadataEnabled,onClick:()=>n({...t,isMetadataEnabled:!t.isMetadataEnabled})})}),(0,l.jsx)(p.Z,{onClick:e=>e.preventDefault(),children:(0,l.jsx)(m.Z,{control:(0,l.jsx)(g.Z,{}),label:"Enable Time Series Chart",checked:t.isPanelEnabled,onClick:()=>n({...t,isPanelEnabled:!t.isPanelEnabled})})})]})]})}function eb(e){let{datasource:t,filters:n,isMetadataEnabled:a,onExplore:i,...s}=e,{data:o,isLoading:d,error:u}=N("__name__",n,t),[c,h]=(0,E.useState)(""),x=(0,E.useMemo)(()=>new L({includeMatches:!0,excludedChars:[" "]}),[]),f=(0,E.useMemo)(()=>{if(c&&(null==o?void 0:o.data))return x.filter(c,o.data).sort((e,t)=>t.score-e.score)},[o,x,c]);return u?(0,l.jsxs)(r.Z,{width:"100%",children:["Error: ",u.message]}):d?(0,l.jsx)(r.Z,{width:"100%",sx:{alignItems:"center",justifyContent:"center"},children:(0,l.jsx)(j.Z,{})}):(0,l.jsxs)(r.Z,{...s,children:[(0,l.jsx)(b.Z,{value:c,onChange:e=>h(e.target.value),placeholder:"Search metric name...",InputProps:{startAdornment:(0,l.jsx)(v.Z,{position:"start",children:(0,l.jsx)(_.default,{})})}}),(0,l.jsx)(z,{metricNames:(null==o?void 0:o.data)??[],filteredResults:f,datasource:t,filters:n,isMetadataEnabled:a,onExplore:i})]})}function ev(e){let{value:{datasource:t=T.Mm,filters:n=[],exploredMetric:a},onChange:i,onExplore:s,...o}=e,u=localStorage.getItem(eg),[c,h]=(0,E.useState)(u?JSON.parse(u):{isMetadataEnabled:!0}),x=(0,Z.Z)((0,C.Z)().breakpoints.down("md")),f=(0,E.useMemo)(()=>n.filter(e=>e.label&&e.labelValues.length>0),[n]),p=(0,d.useExplorerQueryParams)({data:{tab:"finder",datasource:t,filters:n,exploredMetric:void 0}});function m(e){i({datasource:t,filters:e,exploredMetric:a})}return(0,l.jsxs)(r.Z,{...o,gap:1,children:[(0,l.jsxs)(r.Z,{direction:x?"column":"row",gap:2,justifyContent:"space-between",children:[(0,l.jsx)(et,{datasource:t??T.Mm,filters:n??[],filteredFilters:f,onDatasourceChange:function(e){i({datasource:e,filters:n,exploredMetric:a})},onFiltersChange:m}),(0,l.jsxs)(r.Z,{direction:"row",gap:1,alignItems:"center",children:[a&&(0,l.jsx)(w.Z,{variant:"contained","aria-label":"back to metric explorer",startIcon:(0,l.jsx)(S.default,{}),component:I.Link,to:`?${p}`,children:"Back"}),(0,l.jsx)(r.Z,{direction:"row",sx:{width:x?"100%":"unset"},justifyContent:x?"end":"unset",alignItems:"center",children:(0,l.jsx)(ej,{value:c,onChange:function(e){h(e),localStorage.setItem(eg,JSON.stringify(e))}})})]})]}),a?(0,l.jsx)(em,{metricName:a,datasource:t??T.Mm,filters:f,isMetadataEnabled:c.isMetadataEnabled,isPanelEnabled:c.isPanelEnabled,onFiltersChange:m,onExplore:s}):(0,l.jsx)(eb,{datasource:t??T.Mm,filters:f,isMetadataEnabled:c.isMetadataEnabled,onExplore:s})]})}function eZ(e){let{queries:t}=e,{width:n,ref:r}=(0,u.default)(),i=(0,o.useSuggestedStepMs)(n),s=t.length?t.map(e=>({kind:e.spec.plugin.kind,spec:e.spec.plugin.spec})):[];return(0,l.jsx)(a.Z,{ref:r,height:700,children:(0,l.jsx)(o.DataQueriesProvider,{definitions:s,options:{suggestedStepMs:i,mode:"range"},children:(0,l.jsx)(c.Panel,{panelOptions:{hideHeader:!0},definition:{kind:"Panel",spec:{queries:t,display:{name:""},plugin:{kind:"TimeSeriesChart",spec:{}}}}})})})}function eC(e){let{queries:t}=e,n=t.map(e=>({kind:e.spec.plugin.kind,spec:e.spec.plugin.spec}));return(0,l.jsx)(a.Z,{height:700,children:(0,l.jsx)(o.DataQueriesProvider,{definitions:n,options:{mode:"instant"},children:(0,l.jsx)(c.Panel,{panelOptions:{hideHeader:!0},definition:{kind:"Panel",spec:{queries:t,display:{name:""},plugin:{kind:"TimeSeriesTable",spec:{}}}}})})})}function ew(){let{data:{tab:e="table",queries:t=[],datasource:n=h.Mm,filters:a=[],exploredMetric:u},setData:c}=(0,d.useExplorerManagerContext)();return(0,l.jsxs)(r.Z,{gap:2,sx:{width:"100%"},children:[(0,l.jsxs)(i.Z,{value:e,onChange:(e,n)=>c({tab:n,queries:t}),variant:"scrollable",sx:{borderBottom:1,borderColor:"divider"},children:[(0,l.jsx)(s.Z,{value:"table",label:"Table"}),(0,l.jsx)(s.Z,{value:"graph",label:"Graph"}),(0,l.jsx)(s.Z,{value:"finder",label:"Finder"})]}),(0,l.jsxs)(r.Z,{gap:1,children:["table"===e&&(0,l.jsxs)(r.Z,{children:[(0,l.jsx)(o.MultiQueryEditor,{queryTypes:["TimeSeriesQuery"],onChange:t=>c({tab:e,queries:t}),queries:t}),(0,l.jsx)(eC,{queries:t})]}),"graph"===e&&(0,l.jsxs)(r.Z,{children:[(0,l.jsx)(o.MultiQueryEditor,{queryTypes:["TimeSeriesQuery"],onChange:t=>c({tab:e,queries:t}),queries:t}),(0,l.jsx)(eZ,{queries:t})]}),"finder"===e&&(0,l.jsx)(r.Z,{children:(0,l.jsx)(ev,{onChange:t=>c({tab:e,...t}),value:{datasource:n,filters:a,exploredMetric:u}})})]})]})}},87629:function(e,t,n){function l(e){let[t,n]=e;return[1e3*t,function(e){let t;switch(e){case"+Inf":t=Number.POSITIVE_INFINITY;break;case"-Inf":t=Number.NEGATIVE_INFINITY;break;default:t=parseFloat(e)}return t}(n)]}n.d(t,{X2:()=>u,mB:()=>h,mY:()=>o,k7:()=>C,c4:()=>r,Nr:()=>i,Mm:()=>g.Mm,Fp:()=>s,Rv:()=>g.Rv,sv:()=>g.sv,ac:()=>c,qJ:()=>l,nY:()=>g.nY,Bf:()=>v,PL:()=>d,wd:()=>Z});var a=n(35015);function r(e){return async()=>{let t=`${e.datasourceUrl}/-/healthy`;try{let n=await (0,a.he)(t,{headers:e.headers});return 200===n.status}catch{return!1}}}function i(e,t){return f("/api/v1/query",e,t)}function s(e,t){return f("/api/v1/query_range",e,t)}function o(e,t){return f("/api/v1/labels",e,t)}function d(e,t){let{labelName:n,...l}=e;return 0===n.length?new Promise(e=>{e({data:[]})}):x(`/api/v1/label/${encodeURIComponent(n)}/values`,l,t)}function u(e,t){return x("/api/v1/metadata",e,t)}function c(e,t){return f("/api/v1/series",e,t)}function h(e,t){return f("/api/v1/parse_query",e,t)}function x(e,t,n){let{datasourceUrl:l,headers:r}=n,i=`${l}${e}`,s=p(t).toString();return""!==s&&(i+=`?${s}`),(0,a.rd)(i,{method:"GET",headers:r})}function f(e,t,n){let{datasourceUrl:l,headers:a}=n;return m(`${l}${e}`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...a},body:p(t)})}function p(e){let t=new URLSearchParams;for(let n in e){let l=e[n];if(void 0!==l){if("string"==typeof l){t.append(n,l);continue}if("number"==typeof l){t.append(n,l.toString());continue}for(let e of l)t.append(n,e)}}return t}async function m(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let l=await (0,a.he)(...t);return{...await l.json(),rawResponse:l}}var g=n(65456),j=n(29085),b=n(20461);function v(e){let{start:t,end:n}=e;return{start:Math.ceil((0,b.getUnixTime)(t)),end:Math.ceil((0,b.getUnixTime)(n))}}function Z(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=(e.end-e.start)/1e4;return a>1&&(a=Math.ceil(a)),Math.max(l/1e3*n,t,a)}function C(e){if(!e)return;let t=(0,j.Ib)(e);return Math.floor((0,b.milliseconds)(t)/1e3)}},65456:function(e,t,n){n.d(t,{Mm:()=>r,Rv:()=>i,nY:()=>a,sv:()=>s});var l=n(58891);let a="PrometheusDatasource",r={kind:a};function i(e){return!(0,l.isVariableDatasource)(e)&&void 0===e.name}function s(e){return(0,l.isVariableDatasource)(e)||e.kind===a}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkPrometheus=self.webpackChunkPrometheus||[]).push([["9606"],{8702:function(e,t,a){a.r(t),a.d(t,{PrometheusTimeSeriesQuery:()=>y});var r=a(58891),s=a(29085),n=a(20461),l=a(87629);function u(e,t){let a=[];return Object.keys(e).sort().forEach(r=>{let s=e[r];void 0!==s&&(t?a.push(`"${r}":"${s}"`):a.push(`${r}="${s}"`))}),`{${a.join(",")}}`}function o(e,t,a){let r=function(e){let{removeExprWrap:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a="__name__";if(Object.prototype.hasOwnProperty.call(e,a)){let r=u({...e,[a]:void 0},t);return t?`${r}`:`${e[a]}${r}`}return u(e,t)}(t),s=a?a.replace(/\{\{\s*(.+?)\s*\}\}/g,(e,a)=>t[a]??""):r;return{name:r,formattedName:s}}var i=a(13690),c=a(6421);let d=async(e,t)=>{let a;if(void 0===e.query||null===e.query||""===e.query)return{series:[]};let u=await t.datasourceStore.listDatasourceSelectItems(l.nY),d=(0,r.datasourceSelectValueToSelector)(e.datasource??l.Mm,t.variableState,u)??l.Mm,m=await t.datasourceStore.getDatasource(d),p=Math.trunc((0,n.milliseconds)((0,s.Ib)(m.plugin.spec.scrapeInterval??i.v))/1e3),h=(0,l.k7)((0,r.replaceVariables)(e.minStep,t.variableState))??p,v=(0,l.Bf)(t.timeRange),g=(0,l.wd)(v,h,void 0,t.suggestedStepMs),{start:S,end:f}=v,b=60*new Date().getTimezoneOffset(),y=Math.floor((f+b)/g)*g-b;S=Math.floor((S+b)/g)*g-b,(f=y)===S&&(f=S+g,console.warn(`Step (${g}) was larger than the time range! end of time range was set accordingly.`));let w=(0,c.d)(e.query,1e3*h,1e3*g);w=(0,r.replaceVariables)(w,t.variableState);let q=e.seriesNameFormat;q&&(q=(0,r.replaceVariables)(q,t.variableState));let x=await t.datasourceStore.getDatasourceClient(d),C=(a="instant"===t.mode?await x.instantQuery({query:w,time:f}):await x.rangeQuery({query:w,start:S,end:f,step:g})).data,D=[];if("success"===a.status){let e=(a.warnings??[])[0]??"";""!==e&&D.push({type:"warning",message:e})}return{timeRange:{start:(0,n.fromUnixTime)(S),end:(0,n.fromUnixTime)(f)},stepMs:1e3*g,series:function(e,t,a){if(!t)return[];let r=t.resultType;switch(r){case"vector":return t.result.map(t=>{let{metric:r,value:s,histogram:n}=t,{name:u,formattedName:i}=o(e,r,a);return n?{name:u,formattedName:i,labels:r,values:[(0,l.qJ)([n[0],n[1].sum])],histograms:[n]}:{name:u,formattedName:i,labels:r,values:[(0,l.qJ)(s)]}});case"matrix":return t.result.map(t=>{let{metric:r,values:s,histograms:n}=t,{name:u,formattedName:i}=o(e,r,a);return n?{name:u,formattedName:i,labels:r,values:n.map(e=>(0,l.qJ)([e[0],e[1].sum])),histograms:n.map(e=>e)}:{name:u,formattedName:i,labels:r,values:s.map(l.qJ)}});case"scalar":return function(e,t,a){let{name:r,formattedName:s}=o(e,{},a);return[{name:r,values:[(0,l.qJ)(t.result)],formattedName:s}]}(e,t,a);default:return console.warn("Unknown result type",r,t),[]}}(w,C,q),metadata:{notices:D,executedQueryString:w}}};var m=a(24246),p=a(75586),h=a(72629),v=a(25283),g=a(90192),S=a(8695),f=a(82901),b=a(54538);let y={getTimeSeriesData:d,OptionsEditorComponent:function(e){let{onChange:t,value:a}=e,{datasource:s}=a,n=s??l.Mm,u=(0,h.useId)("prom-datasource-label"),o=(0,r.useDatasourceSelectValueToSelector)(n,l.nY),{data:c}=(0,r.useDatasourceClient)(o),d=null==c?void 0:c.options.datasourceUrl,{data:y}=(0,r.useDatasource)(o),{handleQueryChange:w,handleQueryBlur:q}=function(e){let{onChange:t,value:a}=e,[r,s]=(0,b.useState)(a.query),[n,l]=(0,b.useState)(a.query);return a.query!==n&&(s(a.query),l(a.query)),{query:r,handleQueryChange:e=>{s(e)},handleQueryBlur:()=>{l(r),t((0,p.Uy)(a,e=>{e.query=r}))}}}(e),{format:x,handleFormatChange:C,handleFormatBlur:D}=function(e){let{onChange:t,value:a}=e,[r,s]=(0,b.useState)(a.seriesNameFormat),[n,l]=(0,b.useState)(a.seriesNameFormat);return a.seriesNameFormat!==n&&(s(a.seriesNameFormat),l(a.seriesNameFormat)),{format:r,handleFormatChange:e=>{s(e)},handleFormatBlur:()=>{l(r),t((0,p.Uy)(a,e=>{e.seriesNameFormat=r}))}}}(e),{minStep:M,handleMinStepChange:T,handleMinStepBlur:j}=function(e){let{onChange:t,value:a}=e,[r,s]=(0,b.useState)(a.minStep),[n,l]=(0,b.useState)(a.minStep);return a.minStep!==n&&(s(a.minStep),l(a.minStep)),{minStep:r,handleMinStepChange:e=>{s(e)},handleMinStepBlur:()=>{l(r),t((0,p.Uy)(a,e=>{e.minStep=r}))}}}(e),F=M??(y&&(null==y?void 0:y.plugin.spec).scrapeInterval)??i.v;return(0,m.jsxs)(v.Z,{spacing:2,children:[(0,m.jsx)(g.Z,{margin:"dense",fullWidth:!1,children:(0,m.jsx)(r.DatasourceSelect,{datasourcePluginKind:l.nY,value:n,onChange:e=>{if((0,l.sv)(e)){t((0,p.Uy)(a,t=>{let a=(0,l.Rv)(e)?void 0:e;t.datasource=a}));return}throw Error("Got unexpected non-Prometheus datasource selector")},labelId:u,label:"Prometheus Datasource",notched:!0})}),(0,m.jsx)(f.P,{completeConfig:{remote:{url:d}},value:a.query,datasource:o,onChange:w,onBlur:q}),(0,m.jsxs)(v.Z,{direction:"row",spacing:2,children:[(0,m.jsx)(S.Z,{fullWidth:!0,label:"Legend",placeholder:"Example: '{{instance}}' will generate series names like 'webserver-123', 'webserver-456'...",helperText:"Text to be displayed in the legend and the tooltip. Use {{label_name}} to interpolate label values.",value:x??"",onChange:e=>C(e.target.value),onBlur:D}),(0,m.jsx)(S.Z,{label:"Min Step",placeholder:F,helperText:"Lower bound for the step. If not provided, the scrape interval of the datasource is used.",value:M??"",onChange:e=>T(e.target.value?e.target.value:void 0),onBlur:j,sx:{width:"250px"}})]})]})},createInitialOptions:()=>({query:"",datasource:void 0}),dependsOn:e=>{let t=(0,r.parseVariables)(e.query);return{variables:[...new Set([...t,...(0,r.parseVariables)(e.seriesNameFormat||""),...(0,r.isVariableDatasource)(e.datasource)?(0,r.parseVariables)(e.datasource??""):[]])]}}}},13690:function(e,t,a){a.d(t,{v:()=>r});let r="1m"}}]);
@@ -1 +1 @@
1
- (()=>{var e={5311:function(e,r,t){Promise.all([t.e("9677"),t.e("2179"),t.e("1620")]).then(t.bind(t,29161))}},r={};function t(o){var a=r[o];if(void 0!==a)return a.exports;var n=r[o]={id:o,loaded:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}t.m=e,t.c=r,t.federation||(t.federation={chunkMatcher:function(e){return!/^(5(037|263|987)|2(179|635|941)|9(157|46|494|677|729)|7(055|482|787)|(160|380|675)9|8267)$/.test(e)}}),t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},t.f={},t.e=e=>Promise.all(Object.keys(t.f).reduce((r,o)=>(t.f[o](e,r),r),[])),t.u=e=>"__mf/js/async/"+e+"."+({1465:"3b5e12d5",1620:"6376bd14",1964:"95da06f6",212:"bd5d617a",2285:"15378f70",2569:"daf868a6",2675:"99cf926f",3057:"e568f9b6",3090:"9fb5fe73",3224:"23f0dccf",3355:"a4dbcdb0",3818:"dde21d04",3871:"6915e369",3960:"129d5ef5",3980:"7cea5715",4062:"3ab7f987",4075:"b77ca1c7",4238:"8e4d29d5",4323:"4266fd6a",4421:"42e889f6",5214:"027c4332",528:"d364bb0e",5503:"d391f0fc",5724:"6ee6ec51",5769:"f14c9663",5774:"9b0b6be1",5790:"2273e061",5913:"4e5abd09",5914:"bd342d22",5981:"40bed0d0",6292:"7b8efa78",6377:"ca974d89",6770:"adb1c939",684:"ca510333",694:"f861d67c",7272:"a763aa92",7376:"c7eb05b9",738:"aca54e25",7740:"0c5363fd",8488:"5237550f",8587:"4891ea90",8930:"9fbbc975",8980:"afe002d4",9173:"e8fbead5",9550:"e19763f8"})[e]+".js",t.miniCssF=e=>"__mf/css/async/"+e+"."+({5263:"dacad691",6759:"dacad691"})[e]+".css",t.h=()=>"9d5a39e390c91777",(()=>{t.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})()})(),t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{var e={},r="Prometheus:";t.l=function(o,a,n,s){if(e[o]){e[o].push(a);return}if(void 0!==n)for(var i,l,c=document.getElementsByTagName("script"),d=0;d<c.length;d++){var u=c[d];if(u.getAttribute("src")==o||u.getAttribute("data-webpack")==r+n){i=u;break}}i||(l=!0,(i=document.createElement("script")).charset="utf-8",i.timeout=120,t.nc&&i.setAttribute("nonce",t.nc),i.setAttribute("data-webpack",r+n),i.src=o),e[o]=[a];var f=function(r,t){i.onerror=i.onload=null,clearTimeout(h);var a=e[o];if(delete e[o],i.parentNode&&i.parentNode.removeChild(i),a&&a.forEach(function(e){return e(t)}),r)return r(t)},h=setTimeout(f.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=f.bind(null,i.onerror),i.onload=f.bind(null,i.onload),l&&document.head.appendChild(i)}})(),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),t.nc=void 0,(()=>{var e=[];t.O=(r,o,a,n)=>{if(o){n=n||0;for(var s=e.length;s>0&&e[s-1][2]>n;s--)e[s]=e[s-1];e[s]=[o,a,n];return}for(var i=1/0,s=0;s<e.length;s++){for(var[o,a,n]=e[s],l=!0,c=0;c<o.length;c++)(!1&n||i>=n)&&Object.keys(t.O).every(e=>t.O[e](o[c]))?o.splice(c--,1):(l=!1,n<i&&(i=n));if(l){e.splice(s--,1);var d=a();void 0!==d&&(r=d)}}return r}})(),t.p="/plugins/Prometheus/",t.rv=()=>"1.2.8",t.j="6909",t.S={},t.initializeSharingData={scopeToSharingDataMapping:{default:[{name:"@emotion/react",version:"11.14.0",factory:()=>Promise.all([t.e("3960"),t.e("9677"),t.e("8930")]).then(()=>()=>t(96434)),eager:0,singleton:1,requiredVersion:"^11.11.3"},{name:"@emotion/styled",version:"11.14.0",factory:()=>Promise.all([t.e("9677"),t.e("9157"),t.e("694")]).then(()=>()=>t(51958)),eager:0,singleton:1},{name:"@hookform/resolvers",version:"3.10.0",factory:()=>Promise.all([t.e("3809"),t.e("5214")]).then(()=>()=>t(81228)),eager:0,singleton:1},{name:"@perses-dev/components",version:"0.51.0-rc.1",factory:()=>Promise.all([t.e("5774"),t.e("8587"),t.e("8980"),t.e("7272"),t.e("2569"),t.e("5914"),t.e("2675"),t.e("5769"),t.e("3871"),t.e("7376"),t.e("5724"),t.e("9550"),t.e("4323"),t.e("4238"),t.e("3224"),t.e("3090"),t.e("3818"),t.e("3057"),t.e("9677"),t.e("2179"),t.e("5987"),t.e("9157"),t.e("946"),t.e("8267"),t.e("5037"),t.e("6759")]).then(()=>()=>t(58970)),eager:0,singleton:1},{name:"@perses-dev/dashboards",version:"0.51.0-rc.1",factory:()=>Promise.all([t.e("5774"),t.e("8587"),t.e("8980"),t.e("7272"),t.e("2569"),t.e("5914"),t.e("2675"),t.e("5769"),t.e("3871"),t.e("9550"),t.e("4323"),t.e("1465"),t.e("5913"),t.e("9677"),t.e("2179"),t.e("5987"),t.e("9157"),t.e("9729"),t.e("946"),t.e("3809"),t.e("7055"),t.e("2941"),t.e("7787"),t.e("3355")]).then(()=>()=>t(76803)),eager:0,singleton:1},{name:"@perses-dev/explore",version:"0.51.0-rc.1",factory:()=>Promise.all([t.e("2569"),t.e("5914"),t.e("7376"),t.e("1465"),t.e("4421"),t.e("9677"),t.e("9157"),t.e("946"),t.e("2941"),t.e("7787"),t.e("1609"),t.e("8488")]).then(()=>()=>t(73223)),eager:0,singleton:1},{name:"@perses-dev/plugin-system",version:"0.51.0-rc.1",factory:()=>Promise.all([t.e("5774"),t.e("8587"),t.e("8980"),t.e("7272"),t.e("2569"),t.e("5914"),t.e("5769"),t.e("3871"),t.e("7376"),t.e("1465"),t.e("528"),t.e("9677"),t.e("2179"),t.e("5987"),t.e("9157"),t.e("9729"),t.e("946"),t.e("3809"),t.e("7055"),t.e("8267"),t.e("2941"),t.e("7482"),t.e("2635"),t.e("684")]).then(()=>()=>t(42625)),eager:0,singleton:1},{name:"@tanstack/react-query",version:"4.39.1",factory:()=>Promise.all([t.e("3980"),t.e("9677")]).then(()=>()=>t(27474)),eager:0,singleton:1},{name:"date-fns",version:"4.1.0",factory:()=>Promise.all([t.e("4238"),t.e("3224"),t.e("4075")]).then(()=>()=>t(99657)),eager:0,singleton:1},{name:"echarts",version:"5.5.0",factory:()=>Promise.all([t.e("3090"),t.e("5503")]).then(()=>()=>t(28919)),eager:0,singleton:1},{name:"lodash",version:"4.17.21",factory:()=>t.e("5981").then(()=>()=>t(98784)),eager:0,singleton:1},{name:"react-dom",version:"18.3.1",factory:()=>Promise.all([t.e("9173"),t.e("9677")]).then(()=>()=>t(31542)),eager:0,singleton:1,requiredVersion:"18.2.0"},{name:"react-hook-form",version:"7.54.2",factory:()=>Promise.all([t.e("6292"),t.e("9677")]).then(()=>()=>t(36679)),eager:0,singleton:1},{name:"react-router-dom",version:"6.30.0",factory:()=>Promise.all([t.e("6377"),t.e("9677"),t.e("2179")]).then(()=>()=>t(65895)),eager:0,singleton:1},{name:"react",version:"18.3.1",factory:()=>t.e("1964").then(()=>()=>t(27378)),eager:0,singleton:1,requiredVersion:"18.2.0"}]},uniqueName:"Prometheus"},t.I=t.I||function(){throw Error("should have __webpack_require__.I")},t.consumesLoadingData={chunkMapping:{9729:["91909"],7055:["84275","64293"],2941:["20370"],9157:["72116"],7787:["71141"],7482:["32600","90382"],1609:["76006"],9677:["54538"],5037:["48137"],9494:["57871"],8267:["4665"],2635:["55922","89605","30156","57751","74614"],2179:["6085"],5987:["20461"],946:["45913"],3809:["57576"]},moduleIdToConsumeDataMapping:{57751:{shareScope:"default",shareKey:"@perses-dev/plugin-system",import:"@perses-dev/plugin-system",requiredVersion:"*",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>()=>t(42625)},30156:{shareScope:"default",shareKey:"echarts",import:"echarts",requiredVersion:"*",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("3090"),t.e("5503")]).then(()=>()=>t(28919))},72116:{shareScope:"default",shareKey:"@emotion/react",import:"@emotion/react",requiredVersion:"^11.11.3",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("3960").then(()=>()=>t(96434))},89605:{shareScope:"default",shareKey:"react-router-dom",import:"react-router-dom",requiredVersion:"*",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("6377").then(()=>()=>t(65895))},20370:{shareScope:"default",shareKey:"@perses-dev/components",import:"@perses-dev/components",requiredVersion:"0.51.0-rc.1",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("5774"),t.e("8587"),t.e("8980"),t.e("7272"),t.e("2675"),t.e("5769"),t.e("3871"),t.e("7376"),t.e("5724"),t.e("9550"),t.e("4323"),t.e("4238"),t.e("3224"),t.e("3090"),t.e("3818"),t.e("3057"),t.e("2179"),t.e("5987"),t.e("8267"),t.e("5037"),t.e("5263")]).then(()=>()=>t(58970))},84275:{shareScope:"default",shareKey:"@hookform/resolvers",import:"@hookform/resolvers",requiredVersion:"^2.0.0",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("738").then(()=>()=>t(81228))},90382:{shareScope:"default",shareKey:"@perses-dev/explore",import:"@perses-dev/explore",requiredVersion:"^0.51.0-rc.1",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("1465"),t.e("4421"),t.e("2941"),t.e("7787"),t.e("1609"),t.e("4062")]).then(()=>()=>t(73223))},4665:{shareScope:"default",shareKey:"date-fns-tz",import:"date-fns-tz",requiredVersion:"^3.2.0",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("3224"),t.e("7740"),t.e("9494")]).then(()=>()=>t(48872))},54538:{shareScope:"default",shareKey:"react",import:"react",requiredVersion:"18.2.0",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("1964").then(()=>()=>t(27378))},64293:{shareScope:"default",shareKey:"react-hook-form",import:"react-hook-form",requiredVersion:"^7.46.1",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("6292").then(()=>()=>t(36679))},55922:{shareScope:"default",shareKey:"@emotion/styled",import:"@emotion/styled",requiredVersion:"*",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("6770").then(()=>()=>t(51958))},71141:{shareScope:"default",shareKey:"@perses-dev/plugin-system",import:"@perses-dev/plugin-system",requiredVersion:"0.51.0-rc.1",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("5774"),t.e("8587"),t.e("8980"),t.e("7272"),t.e("5769"),t.e("3871"),t.e("7376"),t.e("528"),t.e("2179"),t.e("5987"),t.e("9729"),t.e("3809"),t.e("7055"),t.e("8267"),t.e("7482"),t.e("2635"),t.e("212")]).then(()=>()=>t(42625))},48137:{shareScope:"default",shareKey:"react-hook-form",import:"react-hook-form",requiredVersion:"^7.51.3",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("6292").then(()=>()=>t(36679))},20461:{shareScope:"default",shareKey:"date-fns",import:"date-fns",requiredVersion:"^4.1.0",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("4238"),t.e("3224"),t.e("4075")]).then(()=>()=>t(99657))},74614:{shareScope:"default",shareKey:"lodash",import:"lodash",requiredVersion:"*",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("5981").then(()=>()=>t(98784))},6085:{shareScope:"default",shareKey:"react-dom",import:"react-dom",requiredVersion:"18.2.0",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("9173").then(()=>()=>t(31542))},57871:{shareScope:"default",shareKey:"date-fns",import:"date-fns",requiredVersion:"^3.0.0 || ^4.0.0",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("4238"),t.e("4075")]).then(()=>()=>t(99657))},91909:{shareScope:"default",shareKey:"@tanstack/react-query",import:"@tanstack/react-query",requiredVersion:"^4.39.1",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("3980").then(()=>()=>t(27474))},76006:{shareScope:"default",shareKey:"@perses-dev/dashboards",import:"@perses-dev/dashboards",requiredVersion:"0.51.0-rc.1",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("5774"),t.e("8587"),t.e("8980"),t.e("7272"),t.e("2675"),t.e("5769"),t.e("3871"),t.e("9550"),t.e("4323"),t.e("5913"),t.e("2179"),t.e("5987"),t.e("9729"),t.e("3809"),t.e("7055")]).then(()=>()=>t(76803))},57576:{shareScope:"default",shareKey:"react-hook-form",import:"react-hook-form",requiredVersion:"^7.0.0",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("6292"),t.e("9677")]).then(()=>()=>t(36679))},32600:{shareScope:"default",shareKey:"@perses-dev/dashboards",import:"@perses-dev/dashboards",requiredVersion:"^0.51.0-rc.1",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("5774"),t.e("2675"),t.e("3871"),t.e("9550"),t.e("4323"),t.e("1465"),t.e("5913"),t.e("3809"),t.e("7055"),t.e("2941"),t.e("7787"),t.e("2285")]).then(()=>()=>t(76803))},45913:{shareScope:"default",shareKey:"@emotion/styled",import:"@emotion/styled",requiredVersion:"^11.3.0",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("5790").then(()=>()=>t(51958))}},initialConsumes:[]},t.f.consumes=t.f.consumes||function(){throw Error("should have __webpack_require__.f.consumes")},(()=>{if("undefined"!=typeof document){var e=function(e,r,o,a,n){var s=document.createElement("link");return s.rel="stylesheet",s.type="text/css",t.nc&&(s.nonce=t.nc),s.onerror=s.onload=function(t){if(s.onerror=s.onload=null,"load"===t.type)a();else{var o=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.href||r,l=Error("Loading CSS chunk "+e+" failed.\\n("+i+")");l.code="CSS_CHUNK_LOAD_FAILED",l.type=o,l.request=i,s.parentNode&&s.parentNode.removeChild(s),n(l)}},s.href=r,o?o.parentNode.insertBefore(s,o.nextSibling):document.head.appendChild(s),s},r=function(e,r){for(var t=document.getElementsByTagName("link"),o=0;o<t.length;o++){var a=t[o],n=a.getAttribute("data-href")||a.getAttribute("href");if("stylesheet"===a.rel&&(n===e||n===r))return a}for(var s=document.getElementsByTagName("style"),o=0;o<s.length;o++){var a=s[o],n=a.getAttribute("data-href");if(n===e||n===r)return a}},o={6909:0};t.f.miniCss=function(a,n){if(o[a])n.push(o[a]);else if(0!==o[a]&&({5263:1,6759:1})[a])n.push(o[a]=new Promise(function(o,n){var s=t.miniCssF(a),i=t.p+s;if(r(s,i))return o();e(a,i,null,o,n)}).then(function(){o[a]=0},function(e){throw delete o[a],e}))}}})(),(()=>{var e={6909:0};t.f.j=function(r,o){var a=t.o(e,r)?e[r]:void 0;if(0!==a){if(a)o.push(a[2]);else if(/^(5(037|263|987)|2(179|635|941)|9(157|46|494|677|729)|7(055|482|787)|(160|380|675)9|8267)$/.test(r))e[r]=0;else{var n=new Promise((t,o)=>a=e[r]=[t,o]);o.push(a[2]=n);var s=t.p+t.u(r),i=Error();t.l(s,function(o){if(t.o(e,r)&&(0!==(a=e[r])&&(e[r]=void 0),a)){var n=o&&("load"===o.type?"missing":o.type),s=o&&o.target&&o.target.src;i.message="Loading chunk "+r+" failed.\n("+n+": "+s+")",i.name="ChunkLoadError",i.type=n,i.request=s,a[1](i)}},"chunk-"+r,r)}}},t.O.j=r=>0===e[r];var r=(r,o)=>{var a,n,[s,i,l]=o,c=0;if(s.some(r=>0!==e[r])){for(a in i)t.o(i,a)&&(t.m[a]=i[a]);if(l)var d=l(t)}for(r&&r(o);c<s.length;c++)n=s[c],t.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return t.O(d)},o=self.webpackChunkPrometheus=self.webpackChunkPrometheus||[];o.forEach(r.bind(null,0)),o.push=r.bind(null,o.push.bind(o))})(),t.ruid="bundler=rspack@1.2.8",t.O(void 0,["622"],function(){return t(96177)});var o=t.O(void 0,["622"],function(){return t(5311)});o=t.O(o)})();
1
+ (()=>{var e={5311:function(e,r,t){Promise.all([t.e("9677"),t.e("2179"),t.e("1620")]).then(t.bind(t,29161))}},r={};function t(o){var a=r[o];if(void 0!==a)return a.exports;var n=r[o]={id:o,loaded:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}t.m=e,t.c=r,t.federation||(t.federation={chunkMatcher:function(e){return!/^(5(037|263|987)|2(179|635|941)|9(157|46|494|677|729)|7(055|482|787)|(160|380|675)9|8267)$/.test(e)}}),t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},t.f={},t.e=e=>Promise.all(Object.keys(t.f).reduce((r,o)=>(t.f[o](e,r),r),[])),t.u=e=>"__mf/js/async/"+e+"."+({1465:"3b5e12d5",1620:"6376bd14",1964:"95da06f6",212:"bd5d617a",2285:"15378f70",2569:"daf868a6",2675:"99cf926f",3057:"e568f9b6",3090:"9fb5fe73",3224:"23f0dccf",3355:"a4dbcdb0",3818:"dde21d04",3871:"6915e369",3960:"129d5ef5",3980:"7cea5715",4062:"3ab7f987",4075:"b77ca1c7",4238:"8e4d29d5",4323:"4266fd6a",4421:"42e889f6",5214:"027c4332",528:"d364bb0e",5503:"daedd4dd",5724:"6ee6ec51",5769:"f14c9663",5774:"9b0b6be1",5790:"2273e061",5913:"4e5abd09",5914:"bd342d22",5981:"40bed0d0",6292:"7b8efa78",6377:"ca974d89",6770:"adb1c939",684:"ca510333",694:"f861d67c",7272:"a763aa92",7376:"c7eb05b9",738:"aca54e25",7740:"0c5363fd",8488:"5237550f",8587:"4891ea90",8930:"9fbbc975",8980:"afe002d4",9173:"e8fbead5",9550:"e19763f8"})[e]+".js",t.miniCssF=e=>"__mf/css/async/"+e+"."+({5263:"dacad691",6759:"dacad691"})[e]+".css",t.h=()=>"8cb3c63a47532baa",(()=>{t.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})()})(),t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{var e={},r="Prometheus:";t.l=function(o,a,n,s){if(e[o]){e[o].push(a);return}if(void 0!==n)for(var i,l,c=document.getElementsByTagName("script"),d=0;d<c.length;d++){var u=c[d];if(u.getAttribute("src")==o||u.getAttribute("data-webpack")==r+n){i=u;break}}i||(l=!0,(i=document.createElement("script")).charset="utf-8",i.timeout=120,t.nc&&i.setAttribute("nonce",t.nc),i.setAttribute("data-webpack",r+n),i.src=o),e[o]=[a];var f=function(r,t){i.onerror=i.onload=null,clearTimeout(h);var a=e[o];if(delete e[o],i.parentNode&&i.parentNode.removeChild(i),a&&a.forEach(function(e){return e(t)}),r)return r(t)},h=setTimeout(f.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=f.bind(null,i.onerror),i.onload=f.bind(null,i.onload),l&&document.head.appendChild(i)}})(),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),t.nc=void 0,(()=>{var e=[];t.O=(r,o,a,n)=>{if(o){n=n||0;for(var s=e.length;s>0&&e[s-1][2]>n;s--)e[s]=e[s-1];e[s]=[o,a,n];return}for(var i=1/0,s=0;s<e.length;s++){for(var[o,a,n]=e[s],l=!0,c=0;c<o.length;c++)(!1&n||i>=n)&&Object.keys(t.O).every(e=>t.O[e](o[c]))?o.splice(c--,1):(l=!1,n<i&&(i=n));if(l){e.splice(s--,1);var d=a();void 0!==d&&(r=d)}}return r}})(),t.p="/plugins/Prometheus/",t.rv=()=>"1.2.8",t.j="6909",t.S={},t.initializeSharingData={scopeToSharingDataMapping:{default:[{name:"@emotion/react",version:"11.14.0",factory:()=>Promise.all([t.e("3960"),t.e("9677"),t.e("8930")]).then(()=>()=>t(96434)),eager:0,singleton:1,requiredVersion:"^11.11.3"},{name:"@emotion/styled",version:"11.14.0",factory:()=>Promise.all([t.e("9677"),t.e("9157"),t.e("694")]).then(()=>()=>t(51958)),eager:0,singleton:1},{name:"@hookform/resolvers",version:"3.10.0",factory:()=>Promise.all([t.e("3809"),t.e("5214")]).then(()=>()=>t(81228)),eager:0,singleton:1},{name:"@perses-dev/components",version:"0.51.0-rc.1",factory:()=>Promise.all([t.e("5774"),t.e("8587"),t.e("8980"),t.e("7272"),t.e("2569"),t.e("5914"),t.e("2675"),t.e("5769"),t.e("3871"),t.e("7376"),t.e("5724"),t.e("9550"),t.e("4323"),t.e("4238"),t.e("3224"),t.e("3090"),t.e("3818"),t.e("3057"),t.e("9677"),t.e("2179"),t.e("5987"),t.e("9157"),t.e("946"),t.e("8267"),t.e("5037"),t.e("6759")]).then(()=>()=>t(58970)),eager:0,singleton:1},{name:"@perses-dev/dashboards",version:"0.51.0-rc.1",factory:()=>Promise.all([t.e("5774"),t.e("8587"),t.e("8980"),t.e("7272"),t.e("2569"),t.e("5914"),t.e("2675"),t.e("5769"),t.e("3871"),t.e("9550"),t.e("4323"),t.e("1465"),t.e("5913"),t.e("9677"),t.e("2179"),t.e("5987"),t.e("9157"),t.e("9729"),t.e("946"),t.e("3809"),t.e("7055"),t.e("2941"),t.e("7787"),t.e("3355")]).then(()=>()=>t(76803)),eager:0,singleton:1},{name:"@perses-dev/explore",version:"0.51.0-rc.1",factory:()=>Promise.all([t.e("2569"),t.e("5914"),t.e("7376"),t.e("1465"),t.e("4421"),t.e("9677"),t.e("9157"),t.e("946"),t.e("2941"),t.e("7787"),t.e("1609"),t.e("8488")]).then(()=>()=>t(73223)),eager:0,singleton:1},{name:"@perses-dev/plugin-system",version:"0.51.0-rc.1",factory:()=>Promise.all([t.e("5774"),t.e("8587"),t.e("8980"),t.e("7272"),t.e("2569"),t.e("5914"),t.e("5769"),t.e("3871"),t.e("7376"),t.e("1465"),t.e("528"),t.e("9677"),t.e("2179"),t.e("5987"),t.e("9157"),t.e("9729"),t.e("946"),t.e("3809"),t.e("7055"),t.e("8267"),t.e("2941"),t.e("7482"),t.e("2635"),t.e("684")]).then(()=>()=>t(42625)),eager:0,singleton:1},{name:"@tanstack/react-query",version:"4.39.1",factory:()=>Promise.all([t.e("3980"),t.e("9677")]).then(()=>()=>t(27474)),eager:0,singleton:1},{name:"date-fns",version:"4.1.0",factory:()=>Promise.all([t.e("4238"),t.e("3224"),t.e("4075")]).then(()=>()=>t(99657)),eager:0,singleton:1},{name:"echarts",version:"5.5.0",factory:()=>Promise.all([t.e("3090"),t.e("5503")]).then(()=>()=>t(28919)),eager:0,singleton:1},{name:"lodash",version:"4.17.21",factory:()=>t.e("5981").then(()=>()=>t(98784)),eager:0,singleton:1},{name:"react-dom",version:"18.3.1",factory:()=>Promise.all([t.e("9173"),t.e("9677")]).then(()=>()=>t(31542)),eager:0,singleton:1,requiredVersion:"18.2.0"},{name:"react-hook-form",version:"7.54.2",factory:()=>Promise.all([t.e("6292"),t.e("9677")]).then(()=>()=>t(36679)),eager:0,singleton:1},{name:"react-router-dom",version:"6.30.0",factory:()=>Promise.all([t.e("6377"),t.e("9677"),t.e("2179")]).then(()=>()=>t(65895)),eager:0,singleton:1},{name:"react",version:"18.3.1",factory:()=>t.e("1964").then(()=>()=>t(27378)),eager:0,singleton:1,requiredVersion:"18.2.0"}]},uniqueName:"Prometheus"},t.I=t.I||function(){throw Error("should have __webpack_require__.I")},t.consumesLoadingData={chunkMapping:{9729:["91909"],7055:["84275","64293"],2941:["20370"],9157:["72116"],7787:["71141"],7482:["32600","90382"],1609:["76006"],9677:["54538"],5037:["48137"],9494:["57871"],8267:["4665"],2635:["55922","89605","30156","57751","74614"],2179:["6085"],5987:["20461"],946:["45913"],3809:["57576"]},moduleIdToConsumeDataMapping:{57751:{shareScope:"default",shareKey:"@perses-dev/plugin-system",import:"@perses-dev/plugin-system",requiredVersion:"*",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>()=>t(42625)},30156:{shareScope:"default",shareKey:"echarts",import:"echarts",requiredVersion:"*",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("3090"),t.e("5503")]).then(()=>()=>t(28919))},72116:{shareScope:"default",shareKey:"@emotion/react",import:"@emotion/react",requiredVersion:"^11.11.3",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("3960").then(()=>()=>t(96434))},89605:{shareScope:"default",shareKey:"react-router-dom",import:"react-router-dom",requiredVersion:"*",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("6377").then(()=>()=>t(65895))},20370:{shareScope:"default",shareKey:"@perses-dev/components",import:"@perses-dev/components",requiredVersion:"0.51.0-rc.1",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("5774"),t.e("8587"),t.e("8980"),t.e("7272"),t.e("2675"),t.e("5769"),t.e("3871"),t.e("7376"),t.e("5724"),t.e("9550"),t.e("4323"),t.e("4238"),t.e("3224"),t.e("3090"),t.e("3818"),t.e("3057"),t.e("2179"),t.e("5987"),t.e("8267"),t.e("5037"),t.e("5263")]).then(()=>()=>t(58970))},84275:{shareScope:"default",shareKey:"@hookform/resolvers",import:"@hookform/resolvers",requiredVersion:"^2.0.0",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("738").then(()=>()=>t(81228))},90382:{shareScope:"default",shareKey:"@perses-dev/explore",import:"@perses-dev/explore",requiredVersion:"^0.51.0-rc.1",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("1465"),t.e("4421"),t.e("2941"),t.e("7787"),t.e("1609"),t.e("4062")]).then(()=>()=>t(73223))},4665:{shareScope:"default",shareKey:"date-fns-tz",import:"date-fns-tz",requiredVersion:"^3.2.0",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("3224"),t.e("7740"),t.e("9494")]).then(()=>()=>t(48872))},54538:{shareScope:"default",shareKey:"react",import:"react",requiredVersion:"18.2.0",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("1964").then(()=>()=>t(27378))},64293:{shareScope:"default",shareKey:"react-hook-form",import:"react-hook-form",requiredVersion:"^7.46.1",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("6292").then(()=>()=>t(36679))},55922:{shareScope:"default",shareKey:"@emotion/styled",import:"@emotion/styled",requiredVersion:"*",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("6770").then(()=>()=>t(51958))},71141:{shareScope:"default",shareKey:"@perses-dev/plugin-system",import:"@perses-dev/plugin-system",requiredVersion:"0.51.0-rc.1",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("5774"),t.e("8587"),t.e("8980"),t.e("7272"),t.e("5769"),t.e("3871"),t.e("7376"),t.e("528"),t.e("2179"),t.e("5987"),t.e("9729"),t.e("3809"),t.e("7055"),t.e("8267"),t.e("7482"),t.e("2635"),t.e("212")]).then(()=>()=>t(42625))},48137:{shareScope:"default",shareKey:"react-hook-form",import:"react-hook-form",requiredVersion:"^7.51.3",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("6292").then(()=>()=>t(36679))},20461:{shareScope:"default",shareKey:"date-fns",import:"date-fns",requiredVersion:"^4.1.0",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("4238"),t.e("3224"),t.e("4075")]).then(()=>()=>t(99657))},74614:{shareScope:"default",shareKey:"lodash",import:"lodash",requiredVersion:"*",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("5981").then(()=>()=>t(98784))},6085:{shareScope:"default",shareKey:"react-dom",import:"react-dom",requiredVersion:"18.2.0",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("9173").then(()=>()=>t(31542))},57871:{shareScope:"default",shareKey:"date-fns",import:"date-fns",requiredVersion:"^3.0.0 || ^4.0.0",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("4238"),t.e("4075")]).then(()=>()=>t(99657))},91909:{shareScope:"default",shareKey:"@tanstack/react-query",import:"@tanstack/react-query",requiredVersion:"^4.39.1",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("3980").then(()=>()=>t(27474))},76006:{shareScope:"default",shareKey:"@perses-dev/dashboards",import:"@perses-dev/dashboards",requiredVersion:"0.51.0-rc.1",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("5774"),t.e("8587"),t.e("8980"),t.e("7272"),t.e("2675"),t.e("5769"),t.e("3871"),t.e("9550"),t.e("4323"),t.e("5913"),t.e("2179"),t.e("5987"),t.e("9729"),t.e("3809"),t.e("7055")]).then(()=>()=>t(76803))},57576:{shareScope:"default",shareKey:"react-hook-form",import:"react-hook-form",requiredVersion:"^7.0.0",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("6292"),t.e("9677")]).then(()=>()=>t(36679))},32600:{shareScope:"default",shareKey:"@perses-dev/dashboards",import:"@perses-dev/dashboards",requiredVersion:"^0.51.0-rc.1",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>Promise.all([t.e("5774"),t.e("2675"),t.e("3871"),t.e("9550"),t.e("4323"),t.e("1465"),t.e("5913"),t.e("3809"),t.e("7055"),t.e("2941"),t.e("7787"),t.e("2285")]).then(()=>()=>t(76803))},45913:{shareScope:"default",shareKey:"@emotion/styled",import:"@emotion/styled",requiredVersion:"^11.3.0",strictVersion:!1,singleton:!0,eager:!1,fallback:()=>t.e("5790").then(()=>()=>t(51958))}},initialConsumes:[]},t.f.consumes=t.f.consumes||function(){throw Error("should have __webpack_require__.f.consumes")},(()=>{if("undefined"!=typeof document){var e=function(e,r,o,a,n){var s=document.createElement("link");return s.rel="stylesheet",s.type="text/css",t.nc&&(s.nonce=t.nc),s.onerror=s.onload=function(t){if(s.onerror=s.onload=null,"load"===t.type)a();else{var o=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.href||r,l=Error("Loading CSS chunk "+e+" failed.\\n("+i+")");l.code="CSS_CHUNK_LOAD_FAILED",l.type=o,l.request=i,s.parentNode&&s.parentNode.removeChild(s),n(l)}},s.href=r,o?o.parentNode.insertBefore(s,o.nextSibling):document.head.appendChild(s),s},r=function(e,r){for(var t=document.getElementsByTagName("link"),o=0;o<t.length;o++){var a=t[o],n=a.getAttribute("data-href")||a.getAttribute("href");if("stylesheet"===a.rel&&(n===e||n===r))return a}for(var s=document.getElementsByTagName("style"),o=0;o<s.length;o++){var a=s[o],n=a.getAttribute("data-href");if(n===e||n===r)return a}},o={6909:0};t.f.miniCss=function(a,n){if(o[a])n.push(o[a]);else if(0!==o[a]&&({5263:1,6759:1})[a])n.push(o[a]=new Promise(function(o,n){var s=t.miniCssF(a),i=t.p+s;if(r(s,i))return o();e(a,i,null,o,n)}).then(function(){o[a]=0},function(e){throw delete o[a],e}))}}})(),(()=>{var e={6909:0};t.f.j=function(r,o){var a=t.o(e,r)?e[r]:void 0;if(0!==a){if(a)o.push(a[2]);else if(/^(5(037|263|987)|2(179|635|941)|9(157|46|494|677|729)|7(055|482|787)|(160|380|675)9|8267)$/.test(r))e[r]=0;else{var n=new Promise((t,o)=>a=e[r]=[t,o]);o.push(a[2]=n);var s=t.p+t.u(r),i=Error();t.l(s,function(o){if(t.o(e,r)&&(0!==(a=e[r])&&(e[r]=void 0),a)){var n=o&&("load"===o.type?"missing":o.type),s=o&&o.target&&o.target.src;i.message="Loading chunk "+r+" failed.\n("+n+": "+s+")",i.name="ChunkLoadError",i.type=n,i.request=s,a[1](i)}},"chunk-"+r,r)}}},t.O.j=r=>0===e[r];var r=(r,o)=>{var a,n,[s,i,l]=o,c=0;if(s.some(r=>0!==e[r])){for(a in i)t.o(i,a)&&(t.m[a]=i[a]);if(l)var d=l(t)}for(r&&r(o);c<s.length;c++)n=s[c],t.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return t.O(d)},o=self.webpackChunkPrometheus=self.webpackChunkPrometheus||[];o.forEach(r.bind(null,0)),o.push=r.bind(null,o.push.bind(o))})(),t.ruid="bundler=rspack@1.2.8",t.O(void 0,["622"],function(){return t(96177)});var o=t.O(void 0,["622"],function(){return t(5311)});o=t.O(o)})();
@@ -70,7 +70,7 @@ function PromQLEditor({ completeConfig, datasource, ...rest }) {
70
70
  shrink: true,
71
71
  sx: {
72
72
  position: 'absolute',
73
- top: '-8px',
73
+ top: '-12px',
74
74
  left: '10px',
75
75
  padding: '0 4px',
76
76
  color: theme.palette.text.primary,
@@ -359,8 +359,7 @@ function QueryStatus({ mergedChildState, isFetching, error, resultStats, respons
359
359
  " result",
360
360
  resultStats.numSeries !== 1 && 's',
361
361
  "  –  ",
362
- responseTime,
363
- "ms",
362
+ responseTime ? `${Math.round(responseTime)}ms` : '? ms',
364
363
  resultStats.sortedLabelCards.length > 0 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
365
364
  children: "  –"
366
365
  })
@@ -51,7 +51,7 @@ function FinderFilters({ datasource, filters, filteredFilters, onDatasourceChang
51
51
  children: [
52
52
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControl, {
53
53
  sx: {
54
- width: 250
54
+ width: 500
55
55
  },
56
56
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceSelect, {
57
57
  size: "medium",
@@ -96,8 +96,8 @@ function PrometheusTimeSeriesQueryEditor(props) {
96
96
  label: "Min Step",
97
97
  placeholder: minStepPlaceholder,
98
98
  helperText: "Lower bound for the step. If not provided, the scrape interval of the datasource is used.",
99
- value: minStep,
100
- onChange: (e)=>handleMinStepChange(e.target.value),
99
+ value: minStep ?? '',
100
+ onChange: (e)=>handleMinStepChange(e.target.value ? e.target.value : undefined),
101
101
  onBlur: handleMinStepBlur,
102
102
  sx: {
103
103
  width: '250px'
@@ -52,6 +52,14 @@ const getTimeSeriesData = async (spec, context)=>{
52
52
  const alignedStart = Math.floor((start + utcOffsetSec) / step) * step - utcOffsetSec;
53
53
  start = alignedStart;
54
54
  end = alignedEnd;
55
+ /* Ensure end is always greater than start:
56
+ If the step is greater than equal to the diff of end and start,
57
+ both start, and end will eventually be rounded to the same value,
58
+ Consequently, the time range will be zero, which does not return any valid value
59
+ */ if (end === start) {
60
+ end = start + step;
61
+ console.warn(`Step (${step}) was larger than the time range! end of time range was set accordingly.`);
62
+ }
55
63
  // Replace variable placeholders in PromQL query
56
64
  const intervalMs = step * 1000;
57
65
  const minStepMs = minStep * 1000;
@@ -55,7 +55,7 @@ export function PromQLEditor({ completeConfig, datasource, ...rest }) {
55
55
  shrink: true,
56
56
  sx: {
57
57
  position: 'absolute',
58
- top: '-8px',
58
+ top: '-12px',
59
59
  left: '10px',
60
60
  padding: '0 4px',
61
61
  color: theme.palette.text.primary,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PromQLEditor.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport CodeMirror, { ReactCodeMirrorProps } from '@uiw/react-codemirror';\nimport { PromQLExtension, CompleteConfiguration } from '@prometheus-io/codemirror-promql';\nimport { EditorView } from '@codemirror/view';\nimport { useTheme, CircularProgress, InputLabel, Stack, IconButton, Tooltip } from '@mui/material';\nimport FileTreeIcon from 'mdi-material-ui/FileTree';\nimport { ReactElement, useMemo, useState } from 'react';\nimport { ErrorAlert } from '@perses-dev/components';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useReplaceVariablesInString } from '@perses-dev/plugin-system';\nimport { PrometheusDatasourceSelector } from '../model';\nimport { replacePromBuiltinVariables } from '../plugins/prometheus-time-series-query/replace-prom-builtin-variables';\nimport { useParseQuery } from './query';\nimport TreeNode from './TreeNode';\n\nconst treeViewStr = 'Tree View';\nconst treeViewOpenStr = 'Open ' + treeViewStr;\nconst treeViewCloseStr = 'Close ' + treeViewStr;\n\nexport type PromQLEditorProps = {\n completeConfig: CompleteConfiguration;\n datasource: PrometheusDatasourceSelector;\n} & Omit<ReactCodeMirrorProps, 'theme' | 'extensions'>;\n\nexport function PromQLEditor({ completeConfig, datasource, ...rest }: PromQLEditorProps): ReactElement {\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n const [isTreeViewVisible, setTreeViewVisible] = useState(false);\n\n const promQLExtension = useMemo(() => {\n return new PromQLExtension().activateLinter(false).setComplete(completeConfig).asExtension();\n }, [completeConfig]);\n\n let queryExpr = useReplaceVariablesInString(rest.value);\n if (queryExpr) {\n // TODO placeholder values for steps to be replaced with actual values\n // Looks like providing proper values involves some refactoring: currently we'd need to rely on the timeseries query context,\n // but these step values are actually computed independently / before the queries are getting fired, so it's useless to fire\n // queries here, so maybe we should extract this part to independant hook(s), to be reused here?\n queryExpr = replacePromBuiltinVariables(queryExpr, 12345, 12345);\n }\n\n const { data: parseQueryResponse, isLoading, error } = useParseQuery(queryExpr ?? '', datasource, isTreeViewVisible);\n\n const handleShowTreeView = (): void => {\n setTreeViewVisible(!isTreeViewVisible);\n };\n\n return (\n <Stack position=\"relative\">\n <InputLabel // reproduce the same kind of input label that regular MUI TextFields have\n shrink\n sx={{\n position: 'absolute',\n top: '-8px',\n left: '10px',\n padding: '0 4px',\n color: theme.palette.text.primary,\n zIndex: 1,\n }}\n >\n PromQL Expression\n </InputLabel>\n <CodeMirror\n {...rest}\n style={{ border: `1px solid ${theme.palette.divider}` }}\n theme={isDarkMode ? 'dark' : 'light'}\n basicSetup={{\n highlightActiveLine: false,\n highlightActiveLineGutter: false,\n foldGutter: false,\n }}\n extensions={[\n EditorView.lineWrapping,\n promQLExtension,\n EditorView.theme({\n '.cm-content': {\n paddingTop: '8px',\n paddingBottom: '8px',\n paddingRight: '40px', // offset for the tree view button\n },\n }),\n ]}\n placeholder=\"Example: sum(rate(http_requests_total[5m]))\"\n />\n {queryExpr && (\n <>\n <Tooltip title={isTreeViewVisible ? treeViewCloseStr : treeViewOpenStr}>\n <IconButton\n aria-label={isTreeViewVisible ? treeViewCloseStr : treeViewOpenStr}\n onClick={handleShowTreeView}\n sx={{ position: 'absolute', right: '5px', top: '5px' }}\n size=\"small\"\n key=\"tree-view-button\"\n >\n <FileTreeIcon sx={{ fontSize: '18px' }} />\n </IconButton>\n </Tooltip>\n {isTreeViewVisible && (\n <div style={{ border: `1px solid ${theme.palette.divider}`, position: 'relative' }}>\n <Tooltip title={treeViewCloseStr}>\n <IconButton\n aria-label={treeViewCloseStr}\n onClick={() => setTreeViewVisible(false)}\n sx={{ position: 'absolute', top: '5px', right: '5px' }}\n size=\"small\"\n key=\"tree-view-close-button\"\n >\n <CloseIcon sx={{ fontSize: '18px' }} />\n </IconButton>\n </Tooltip>\n {error ? (\n // Here the user is able to hide the error alert\n <ErrorAlert\n error={{\n name: `${treeViewStr} not available`,\n message: error.message,\n }}\n />\n ) : (\n <div\n style={{\n padding: `${theme.spacing(1.5)} ${theme.spacing(1.5)} 0 ${theme.spacing(1.5)}`, // let paddingBottom at 0 because nodes have margin-bottom\n overflowX: 'auto',\n backgroundColor: theme.palette.background.default,\n }}\n >\n {isLoading ? (\n <CircularProgress />\n ) : parseQueryResponse?.data ? (\n <TreeNode node={parseQueryResponse.data} reverse={false} childIdx={0} datasource={datasource} />\n ) : null}\n </div>\n )}\n </div>\n )}\n </>\n )}\n </Stack>\n );\n}\n"],"names":["CodeMirror","PromQLExtension","EditorView","useTheme","CircularProgress","InputLabel","Stack","IconButton","Tooltip","FileTreeIcon","useMemo","useState","ErrorAlert","CloseIcon","useReplaceVariablesInString","replacePromBuiltinVariables","useParseQuery","TreeNode","treeViewStr","treeViewOpenStr","treeViewCloseStr","PromQLEditor","completeConfig","datasource","rest","theme","isDarkMode","palette","mode","isTreeViewVisible","setTreeViewVisible","promQLExtension","activateLinter","setComplete","asExtension","queryExpr","value","data","parseQueryResponse","isLoading","error","handleShowTreeView","position","shrink","sx","top","left","padding","color","text","primary","zIndex","style","border","divider","basicSetup","highlightActiveLine","highlightActiveLineGutter","foldGutter","extensions","lineWrapping","paddingTop","paddingBottom","paddingRight","placeholder","title","aria-label","onClick","right","size","fontSize","div","name","message","spacing","overflowX","backgroundColor","background","default","node","reverse","childIdx"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,gBAA0C,wBAAwB;AACzE,SAASC,eAAe,QAA+B,mCAAmC;AAC1F,SAASC,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,QAAQ,EAAEC,gBAAgB,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,EAAEC,OAAO,QAAQ,gBAAgB;AACnG,OAAOC,kBAAkB,2BAA2B;AACpD,SAAuBC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACxD,SAASC,UAAU,QAAQ,yBAAyB;AACpD,OAAOC,eAAe,wBAAwB;AAC9C,SAASC,2BAA2B,QAAQ,4BAA4B;AAExE,SAASC,2BAA2B,QAAQ,yEAAyE;AACrH,SAASC,aAAa,QAAQ,UAAU;AACxC,OAAOC,cAAc,aAAa;AAElC,MAAMC,cAAc;AACpB,MAAMC,kBAAkB,UAAUD;AAClC,MAAME,mBAAmB,WAAWF;AAOpC,OAAO,SAASG,aAAa,EAAEC,cAAc,EAAEC,UAAU,EAAE,GAAGC,MAAyB;IACrF,MAAMC,QAAQtB;IACd,MAAMuB,aAAaD,MAAME,OAAO,CAACC,IAAI,KAAK;IAC1C,MAAM,CAACC,mBAAmBC,mBAAmB,GAAGnB,SAAS;IAEzD,MAAMoB,kBAAkBrB,QAAQ;QAC9B,OAAO,IAAIT,kBAAkB+B,cAAc,CAAC,OAAOC,WAAW,CAACX,gBAAgBY,WAAW;IAC5F,GAAG;QAACZ;KAAe;IAEnB,IAAIa,YAAY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C;wBAAInB,OAAO;4BAAEC,QAAQ,CAAC,UAAU,EAAE5B,MAAME,OAAO,CAAC2B,OAAO,EAAE;4BAAEZ,UAAU;wBAAW;;0CAC/E,KAAClC;gCAAQyD,OAAO7C;0CACd,cAAA,KAACb;oCACC2D,cAAY9C;oCACZ+C,SAAS,IAAMrC,mBAAmB;oCAClCc,IAAI;wCAAEF,UAAU;wCAAYG,KAAK;wCAAOuB,OAAO;oCAAM;oCACrDC,MAAK;8CAGL,cAAA,KAACxD;wCAAU+B,IAAI;4CAAE0B,UAAU;wCAAO;;mCAF9B;;4BAKP9B,QACC,gDAAgD;0CAChD,KAAC5B;gCACC4B,OAAO;oCACLgC,MAAM,GAAGtD,YAAY,cAAc,CAAC;oCACpCuD,SAASjC,MAAMiC,OAAO;gCACxB;+CAGF,KAACF;gCACCnB,OAAO;oCACLL,SAAS,GAAGtB,MAAMiD,OAAO,CAAC,KAAK,CAAC,EAAEjD,MAAMiD,OAAO,CAAC,KAAK,GAAG,EAAEjD,MAAMiD,OAAO,CAAC,MAAM;oCAC9EC,WAAW;oCACXC,iBAAiBnD,MAAME,OAAO,CAACkD,UAAU,CAACC,OAAO;gCACnD;0CAECvC,0BACC,KAACnC,wBACCkC,oBAAoBD,qBACtB,KAACpB;oCAAS8D,MAAMzC,mBAAmBD,IAAI;oCAAE2C,SAAS;oCAAOC,UAAU;oCAAG1D,YAAYA;qCAChF;;;;;;;;AAStB"}
1
+ {"version":3,"sources":["../../../src/components/PromQLEditor.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport CodeMirror, { ReactCodeMirrorProps } from '@uiw/react-codemirror';\nimport { PromQLExtension, CompleteConfiguration } from '@prometheus-io/codemirror-promql';\nimport { EditorView } from '@codemirror/view';\nimport { useTheme, CircularProgress, InputLabel, Stack, IconButton, Tooltip } from '@mui/material';\nimport FileTreeIcon from 'mdi-material-ui/FileTree';\nimport { ReactElement, useMemo, useState } from 'react';\nimport { ErrorAlert } from '@perses-dev/components';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useReplaceVariablesInString } from '@perses-dev/plugin-system';\nimport { PrometheusDatasourceSelector } from '../model';\nimport { replacePromBuiltinVariables } from '../plugins/prometheus-time-series-query/replace-prom-builtin-variables';\nimport { useParseQuery } from './query';\nimport TreeNode from './TreeNode';\n\nconst treeViewStr = 'Tree View';\nconst treeViewOpenStr = 'Open ' + treeViewStr;\nconst treeViewCloseStr = 'Close ' + treeViewStr;\n\nexport type PromQLEditorProps = {\n completeConfig: CompleteConfiguration;\n datasource: PrometheusDatasourceSelector;\n} & Omit<ReactCodeMirrorProps, 'theme' | 'extensions'>;\n\nexport function PromQLEditor({ completeConfig, datasource, ...rest }: PromQLEditorProps): ReactElement {\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n const [isTreeViewVisible, setTreeViewVisible] = useState(false);\n\n const promQLExtension = useMemo(() => {\n return new PromQLExtension().activateLinter(false).setComplete(completeConfig).asExtension();\n }, [completeConfig]);\n\n let queryExpr = useReplaceVariablesInString(rest.value);\n if (queryExpr) {\n // TODO placeholder values for steps to be replaced with actual values\n // Looks like providing proper values involves some refactoring: currently we'd need to rely on the timeseries query context,\n // but these step values are actually computed independently / before the queries are getting fired, so it's useless to fire\n // queries here, so maybe we should extract this part to independant hook(s), to be reused here?\n queryExpr = replacePromBuiltinVariables(queryExpr, 12345, 12345);\n }\n\n const { data: parseQueryResponse, isLoading, error } = useParseQuery(queryExpr ?? '', datasource, isTreeViewVisible);\n\n const handleShowTreeView = (): void => {\n setTreeViewVisible(!isTreeViewVisible);\n };\n\n return (\n <Stack position=\"relative\">\n <InputLabel // reproduce the same kind of input label that regular MUI TextFields have\n shrink\n sx={{\n position: 'absolute',\n top: '-12px',\n left: '10px',\n padding: '0 4px',\n color: theme.palette.text.primary,\n zIndex: 1,\n }}\n >\n PromQL Expression\n </InputLabel>\n <CodeMirror\n {...rest}\n style={{ border: `1px solid ${theme.palette.divider}` }}\n theme={isDarkMode ? 'dark' : 'light'}\n basicSetup={{\n highlightActiveLine: false,\n highlightActiveLineGutter: false,\n foldGutter: false,\n }}\n extensions={[\n EditorView.lineWrapping,\n promQLExtension,\n EditorView.theme({\n '.cm-content': {\n paddingTop: '8px',\n paddingBottom: '8px',\n paddingRight: '40px', // offset for the tree view button\n },\n }),\n ]}\n placeholder=\"Example: sum(rate(http_requests_total[5m]))\"\n />\n {queryExpr && (\n <>\n <Tooltip title={isTreeViewVisible ? treeViewCloseStr : treeViewOpenStr}>\n <IconButton\n aria-label={isTreeViewVisible ? treeViewCloseStr : treeViewOpenStr}\n onClick={handleShowTreeView}\n sx={{ position: 'absolute', right: '5px', top: '5px' }}\n size=\"small\"\n key=\"tree-view-button\"\n >\n <FileTreeIcon sx={{ fontSize: '18px' }} />\n </IconButton>\n </Tooltip>\n {isTreeViewVisible && (\n <div style={{ border: `1px solid ${theme.palette.divider}`, position: 'relative' }}>\n <Tooltip title={treeViewCloseStr}>\n <IconButton\n aria-label={treeViewCloseStr}\n onClick={() => setTreeViewVisible(false)}\n sx={{ position: 'absolute', top: '5px', right: '5px' }}\n size=\"small\"\n key=\"tree-view-close-button\"\n >\n <CloseIcon sx={{ fontSize: '18px' }} />\n </IconButton>\n </Tooltip>\n {error ? (\n // Here the user is able to hide the error alert\n <ErrorAlert\n error={{\n name: `${treeViewStr} not available`,\n message: error.message,\n }}\n />\n ) : (\n <div\n style={{\n padding: `${theme.spacing(1.5)} ${theme.spacing(1.5)} 0 ${theme.spacing(1.5)}`, // let paddingBottom at 0 because nodes have margin-bottom\n overflowX: 'auto',\n backgroundColor: theme.palette.background.default,\n }}\n >\n {isLoading ? (\n <CircularProgress />\n ) : parseQueryResponse?.data ? (\n <TreeNode node={parseQueryResponse.data} reverse={false} childIdx={0} datasource={datasource} />\n ) : null}\n </div>\n )}\n </div>\n )}\n </>\n )}\n </Stack>\n );\n}\n"],"names":["CodeMirror","PromQLExtension","EditorView","useTheme","CircularProgress","InputLabel","Stack","IconButton","Tooltip","FileTreeIcon","useMemo","useState","ErrorAlert","CloseIcon","useReplaceVariablesInString","replacePromBuiltinVariables","useParseQuery","TreeNode","treeViewStr","treeViewOpenStr","treeViewCloseStr","PromQLEditor","completeConfig","datasource","rest","theme","isDarkMode","palette","mode","isTreeViewVisible","setTreeViewVisible","promQLExtension","activateLinter","setComplete","asExtension","queryExpr","value","data","parseQueryResponse","isLoading","error","handleShowTreeView","position","shrink","sx","top","left","padding","color","text","primary","zIndex","style","border","divider","basicSetup","highlightActiveLine","highlightActiveLineGutter","foldGutter","extensions","lineWrapping","paddingTop","paddingBottom","paddingRight","placeholder","title","aria-label","onClick","right","size","fontSize","div","name","message","spacing","overflowX","backgroundColor","background","default","node","reverse","childIdx"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,gBAA0C,wBAAwB;AACzE,SAASC,eAAe,QAA+B,mCAAmC;AAC1F,SAASC,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,QAAQ,EAAEC,gBAAgB,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,EAAEC,OAAO,QAAQ,gBAAgB;AACnG,OAAOC,kBAAkB,2BAA2B;AACpD,SAAuBC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACxD,SAASC,UAAU,QAAQ,yBAAyB;AACpD,OAAOC,eAAe,wBAAwB;AAC9C,SAASC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MAAME,OAAO,CAACkD,UAAU,CAACC,OAAO;gCACnD;0CAECvC,0BACC,KAACnC,wBACCkC,oBAAoBD,qBACtB,KAACpB;oCAAS8D,MAAMzC,mBAAmBD,IAAI;oCAAE2C,SAAS;oCAAOC,UAAU;oCAAG1D,YAAYA;qCAChF;;;;;;;;AAStB"}
@@ -344,8 +344,7 @@ function QueryStatus({ mergedChildState, isFetching, error, resultStats, respons
344
344
  " result",
345
345
  resultStats.numSeries !== 1 && 's',
346
346
  "  –  ",
347
- responseTime,
348
- "ms",
347
+ responseTime ? `${Math.round(responseTime)}ms` : '? ms',
349
348
  resultStats.sortedLabelCards.length > 0 && /*#__PURE__*/ _jsx(_Fragment, {
350
349
  children: "  –"
351
350
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/TreeNode.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/pages/query/TreeNode.tsx\n\nimport { Box, CircularProgress, List, ListItem, Stack, Tooltip, Typography, useTheme } from '@mui/material';\nimport CircleIcon from 'mdi-material-ui/Circle';\nimport { ReactElement, useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';\nimport AlertCircle from 'mdi-material-ui/AlertCircle';\nimport { StatusError } from '@perses-dev/core';\nimport { PrometheusDatasourceSelector } from '../model';\nimport ASTNode, { nodeType } from './promql/ast';\nimport { escapeString, getNodeChildren } from './promql/utils';\nimport { formatNode } from './promql/format';\nimport serializeNode from './promql/serialize';\nimport { functionSignatures } from './promql/functionSignatures';\nimport { useInstantQuery } from './query';\n\n// The indentation factor for each level of the tree.\nconst nodeIndent = 5;\nconst connectorWidth = nodeIndent * 5;\n\n// max number of label names and values to show in the individual query status\nconst maxLabelNames = 10;\nconst maxLabelValues = 10;\n\ntype NodeState = 'waiting' | 'running' | 'error' | 'success';\n\n// mergeChildStates basically returns the \"worst\" state found among the children.\nconst mergeChildStates = (states: NodeState[]): NodeState => {\n if (states.includes('error')) {\n return 'error';\n }\n if (states.includes('waiting')) {\n return 'waiting';\n }\n if (states.includes('running')) {\n return 'running';\n }\n\n return 'success';\n};\n\ninterface TreeNodeProps {\n // The AST node to render.\n node: ASTNode;\n // The parent element of this node.\n parentEl?: HTMLDivElement | null;\n // Used to compute the position of the connector line between this node and its parent.\n reverse: boolean;\n // Datasource used for the node's individual query.\n datasource: PrometheusDatasourceSelector;\n // The index of this node in its parent's children.\n // Used to render the node's individual query.\n childIdx: number;\n // Function to report the node state to the parent.\n // Used to render the node's individual query.\n reportNodeState?: (childIdx: number, state: NodeState) => void;\n}\n\nexport default function TreeNode({\n node,\n parentEl,\n reverse,\n datasource,\n childIdx,\n reportNodeState,\n}: TreeNodeProps): ReactElement {\n const theme = useTheme();\n const children = getNodeChildren(node);\n\n // A normal ref won't work properly here because the ref's `current` property\n // going from `null` to defined won't trigger a re-render of the child\n // component, since it's not a React state update. So we manually have to\n // create a state update using a callback ref. See also\n // https://tkdodo.eu/blog/avoiding-use-effect-with-callback-refs\n const [nodeEl, setNodeEl] = useState<HTMLDivElement | null>(null);\n const nodeRef = useCallback((node: HTMLDivElement) => setNodeEl(node), []);\n\n const [resultStats, setResultStats] = useState<{\n numSeries: number;\n labelExamples: Record<string, Array<{ value: string; count: number }>>;\n sortedLabelCards: Array<[string, number]>;\n }>({\n numSeries: 0,\n labelExamples: {},\n sortedLabelCards: [],\n });\n\n const [connectorStyle, setConnectorStyle] = useState({\n borderColor: theme.palette.grey['500'],\n borderLeftStyle: 'solid',\n borderLeftWidth: 2,\n width: connectorWidth,\n left: -connectorWidth,\n });\n\n const [childStates, setChildStates] = useState<NodeState[]>(children.map(() => 'waiting'));\n const mergedChildState = useMemo(() => mergeChildStates(childStates), [childStates]);\n\n // Optimize range vector selector fetches to give us the info we're looking for\n // more cheaply. E.g. 'foo[7w]' can be expensive to fully fetch, but wrapping it\n // in 'last_over_time(foo[7w])' is cheaper and also gives us all the info we\n // need (number of series and labels).\n let queryNode = node;\n if (queryNode.type === nodeType.matrixSelector) {\n queryNode = {\n type: nodeType.call,\n func: functionSignatures.last_over_time!,\n args: [node],\n };\n }\n\n // Individual query for the current node\n const {\n data: instantQueryResponse,\n isFetching,\n error,\n } = useInstantQuery(serializeNode(queryNode) ?? '', datasource, mergedChildState === 'success');\n\n // report the node state to the parent\n useEffect(() => {\n if (reportNodeState) {\n if (mergedChildState === 'error' || error) {\n reportNodeState(childIdx, 'error');\n } else if (isFetching) {\n reportNodeState(childIdx, 'running');\n }\n }\n }, [mergedChildState, error, isFetching, reportNodeState, childIdx]);\n\n // This function is passed down to the child nodes so they can report their state.\n const childReportNodeState = useCallback(\n (childIdx: number, state: NodeState) => {\n setChildStates((prev) => {\n const newStates = [...prev];\n newStates[childIdx] = state;\n return newStates;\n });\n },\n [setChildStates]\n );\n\n // Update the size and position of tree connector lines based on the node's and its parent's position.\n useLayoutEffect(() => {\n if (parentEl === undefined) {\n // We're the root node.\n return;\n }\n\n if (parentEl === null || nodeEl === null) {\n // Either of the two connected nodes hasn't been rendered yet.\n return;\n }\n\n const parentRect = parentEl.getBoundingClientRect();\n const nodeRect = nodeEl.getBoundingClientRect();\n if (reverse) {\n setConnectorStyle((prevStyle) => ({\n ...prevStyle,\n top: 'calc(50% - 1px)',\n bottom: nodeRect.bottom - parentRect.top,\n borderTopLeftRadius: 10,\n borderTopStyle: 'solid',\n borderBottomLeftRadius: undefined,\n }));\n } else {\n setConnectorStyle((prevStyle) => ({\n ...prevStyle,\n top: parentRect.bottom - nodeRect.top,\n bottom: 'calc(50% - 1px)',\n borderBottomLeftRadius: 10,\n borderBottomStyle: 'solid',\n borderTopLeftRadius: undefined,\n }));\n }\n }, [parentEl, nodeEl, reverse, nodeRef, setConnectorStyle]);\n\n // Update the node info state based on the query result.\n useEffect(() => {\n if (instantQueryResponse?.status !== 'success') {\n return;\n }\n\n if (reportNodeState) {\n reportNodeState(childIdx, 'success');\n }\n\n let resultSeries = 0;\n // labelValuesByName records the number of times each label value appears for each label name.\n const labelValuesByName: Record<string, Record<string, number>> = {};\n const { resultType, result } = instantQueryResponse.data;\n\n if (resultType === 'scalar' || resultType === 'string') {\n resultSeries = 1;\n } else if (result && result.length > 0) {\n resultSeries = result.length;\n result.forEach((s) => {\n Object.entries(s.metric).forEach(([ln, lv]) => {\n // TODO: If we ever want to include __name__ here again, we cannot use the\n // last_over_time(foo[7d]) optimization since that removes the metric name.\n if (ln !== '__name__') {\n labelValuesByName[ln] = labelValuesByName[ln] ?? {};\n labelValuesByName[ln]![lv] = (labelValuesByName[ln]![lv] ?? 0) + 1;\n }\n });\n });\n }\n\n // labelCardinalities records the number of unique label values for each label name.\n const labelCardinalities: Record<string, number> = {};\n // labelExamples records the most common label values for each label name.\n const labelExamples: Record<string, Array<{ value: string; count: number }>> = {};\n Object.entries(labelValuesByName).forEach(([ln, lvs]) => {\n labelCardinalities[ln] = Object.keys(lvs).length;\n // Sort label values by their number of occurrences within this label name.\n labelExamples[ln] = Object.entries(lvs)\n .sort(([, aCnt], [, bCnt]) => bCnt - aCnt)\n .slice(0, maxLabelValues)\n .map(([lv, cnt]) => ({ value: lv, count: cnt }));\n });\n\n setResultStats({\n numSeries: resultSeries,\n sortedLabelCards: Object.entries(labelCardinalities).sort((a, b) => b[1] - a[1]),\n labelExamples,\n });\n }, [instantQueryResponse, reportNodeState, childIdx]);\n\n const innerNode = (\n <Stack direction=\"row\" gap={2}>\n <Box\n ref={nodeRef}\n sx={{\n position: 'relative',\n display: 'inline-block',\n padding: 1,\n marginBottom: 1.5,\n borderRadius: 2,\n backgroundColor: theme.palette.background.code,\n }}\n >\n {parentEl !== undefined && (\n // Connector line between this node and its parent.\n <Box\n sx={{\n position: 'absolute',\n display: 'inline-block',\n ...connectorStyle,\n }}\n />\n )}\n {/* The node (visible box) itself. */}\n {formatNode(node, false, 1)}\n </Box>\n {/* The node's individual query: */}\n <QueryStatus\n mergedChildState={mergedChildState}\n isFetching={isFetching}\n error={error}\n resultStats={resultStats}\n responseTime={instantQueryResponse?.responseTime}\n />\n </Stack>\n );\n\n if (node.type === nodeType.binaryExpr) {\n return (\n <div>\n <Box ml={nodeIndent}>\n <TreeNode\n node={children[0]!}\n parentEl={nodeEl}\n reverse={true}\n datasource={datasource}\n childIdx={0}\n reportNodeState={childReportNodeState}\n />\n </Box>\n {innerNode}\n <Box ml={nodeIndent}>\n <TreeNode\n node={children[1]!}\n parentEl={nodeEl}\n reverse={false}\n datasource={datasource}\n childIdx={1}\n reportNodeState={childReportNodeState}\n />\n </Box>\n </div>\n );\n }\n\n return (\n <div>\n {innerNode}\n {children.map((child, idx) => (\n <Box ml={nodeIndent} key={idx}>\n <TreeNode\n node={child}\n parentEl={nodeEl}\n reverse={false}\n datasource={datasource}\n childIdx={idx}\n reportNodeState={childReportNodeState}\n />\n </Box>\n ))}\n </div>\n );\n}\n\ninterface QueryStatusProps {\n mergedChildState: NodeState;\n isFetching: boolean;\n error: StatusError | null;\n resultStats: {\n numSeries: number;\n labelExamples: Record<string, Array<{ value: string; count: number }>>;\n sortedLabelCards: Array<[string, number]>;\n };\n responseTime?: number;\n}\n\nfunction QueryStatus({\n mergedChildState,\n isFetching,\n error,\n resultStats,\n responseTime,\n}: QueryStatusProps): ReactElement {\n if (mergedChildState === 'waiting') {\n return <ProgressState text=\"Waiting for child query\" />;\n }\n\n if (mergedChildState === 'running') {\n return <ProgressState text=\"Running\" />;\n }\n\n if (mergedChildState === 'error') {\n return (\n <Stack>\n <AlertCircle />\n Blocked on child query error\n </Stack>\n );\n }\n\n if (isFetching) {\n return <ProgressState text=\"Loading\" />;\n }\n\n if (error) {\n return (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n gap={1}\n sx={{ color: (theme) => theme.palette.error.main }}\n marginBottom={1.5}\n >\n <AlertCircle />\n <Typography variant=\"body2\">\n <strong>Error executing query:</strong> {error.message}\n </Typography>\n </Box>\n );\n }\n\n return (\n <Stack direction=\"row\" gap={1} alignItems=\"center\" marginBottom={1.5}>\n <Typography variant=\"body2\" component=\"span\" sx={{ color: (theme) => theme.palette.grey[500] }}>\n {resultStats.numSeries} result{resultStats.numSeries !== 1 && 's'}\n &nbsp;&nbsp;–&nbsp;&nbsp;\n {responseTime}ms\n {resultStats.sortedLabelCards.length > 0 && <>&nbsp;&nbsp;–</>}\n </Typography>\n {resultStats.sortedLabelCards.slice(0, maxLabelNames).map(([ln, cnt]) => (\n <Tooltip\n key={ln}\n title={\n <Box>\n <List dense>\n {resultStats.labelExamples[ln]?.map(({ value, count }) => (\n <ListItem\n key={value}\n sx={{\n display: 'flex',\n gap: 1,\n py: 0,\n px: 0.5,\n }}\n >\n <CircleIcon sx={{ fontSize: 8 }} />\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{\n color: (theme) =>\n theme.palette.mode === 'dark' // TODO we shouldnt have to do that I guess..\n ? theme.palette.warning.dark\n : theme.palette.warning.main,\n fontFamily: 'monospace',\n }}\n >\n {escapeString(value)}\n </Typography>\n <Typography variant=\"body2\" component=\"span\">\n ({count}x)\n </Typography>\n </ListItem>\n ))}\n {cnt > maxLabelValues && (\n <ListItem\n sx={{\n display: 'flex',\n gap: 1,\n py: 0,\n px: 0.5,\n }}\n >\n <CircleIcon sx={{ fontSize: 8 }} />\n <Typography variant=\"body2\">. . .</Typography>\n </ListItem>\n )}\n </List>\n </Box>\n }\n arrow\n >\n <span style={{ cursor: 'pointer', whiteSpace: 'nowrap' }}>\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{ fontFamily: 'monospace', color: (theme) => theme.palette.success.main }}\n >\n {ln}\n </Typography>\n <Typography variant=\"body2\" component=\"span\" sx={{ color: (theme) => theme.palette.grey[500] }}>\n : {cnt}\n </Typography>\n </span>\n </Tooltip>\n ))}\n {resultStats.sortedLabelCards.length > maxLabelNames ? (\n <Typography variant=\"body2\">...{resultStats.sortedLabelCards.length - maxLabelNames} more...</Typography>\n ) : null}\n </Stack>\n );\n}\n\nfunction ProgressState({ text }: { text: string }): ReactElement {\n return (\n <Box display=\"flex\" alignItems=\"center\" gap={1} marginBottom={1.5}>\n <CircularProgress size={16} color=\"secondary\" />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {text}...\n </Typography>\n </Box>\n );\n}\n"],"names":["Box","CircularProgress","List","ListItem","Stack","Tooltip","Typography","useTheme","CircleIcon","useCallback","useEffect","useLayoutEffect","useMemo","useState","AlertCircle","nodeType","escapeString","getNodeChildren","formatNode","serializeNode","functionSignatures","useInstantQuery","nodeIndent","connectorWidth","maxLabelNames","maxLabelValues","mergeChildStates","states","includes","TreeNode","node","parentEl","reverse","datasource","childIdx","reportNodeState","theme","children","nodeEl","setNodeEl","nodeRef","resultStats","setResultStats","numSeries","labelExamples","sortedLabelCards","connectorStyle","setConnectorStyle","borderColor","palette","grey","borderLeftStyle","borderLeftWidth","width","left","childStates","setChildStates","map","mergedChildState","queryNode","type","matrixSelector","call","func","last_over_time","args","data","instantQueryResponse","isFetching","error","childReportNodeState","state","prev","newStates","undefined","parentRect","getBoundingClientRect","nodeRect","prevStyle","top","bottom","borderTopLeftRadius","borderTopStyle","borderBottomLeftRadius","borderBottomStyle","status","resultSeries","labelValuesByName","resultType","result","length","forEach","s","Object","entries","metric","ln","lv","labelCardinalities","lvs","keys","sort","aCnt","bCnt","slice","cnt","value","count","a","b","innerNode","direction","gap","ref","sx","position","display","padding","marginBottom","borderRadius","backgroundColor","background","code","QueryStatus","responseTime","binaryExpr","div","ml","child","idx","ProgressState","text","alignItems","color","main","variant","strong","message","component","title","dense","py","px","fontSize","mode","warning","dark","fontFamily","arrow","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AI,EAAoB;IAC/C,qBACE,MAACnI;QAAIoH,SAAQ;QAAOgB,YAAW;QAASpB,KAAK;QAAGM,cAAc;;0BAC5D,KAACrH;gBAAiByJ,MAAM;gBAAIrB,OAAM;;0BAClC,MAAC/H;gBAAWiI,SAAQ;gBAAQF,OAAM;;oBAC/BF;oBAAK;;;;;AAId"}
1
+ {"version":3,"sources":["../../../src/components/TreeNode.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/pages/query/TreeNode.tsx\n\nimport { Box, CircularProgress, List, ListItem, Stack, Tooltip, Typography, useTheme } from '@mui/material';\nimport CircleIcon from 'mdi-material-ui/Circle';\nimport { ReactElement, useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';\nimport AlertCircle from 'mdi-material-ui/AlertCircle';\nimport { StatusError } from '@perses-dev/core';\nimport { PrometheusDatasourceSelector } from '../model';\nimport ASTNode, { nodeType } from './promql/ast';\nimport { escapeString, getNodeChildren } from './promql/utils';\nimport { formatNode } from './promql/format';\nimport serializeNode from './promql/serialize';\nimport { functionSignatures } from './promql/functionSignatures';\nimport { useInstantQuery } from './query';\n\n// The indentation factor for each level of the tree.\nconst nodeIndent = 5;\nconst connectorWidth = nodeIndent * 5;\n\n// max number of label names and values to show in the individual query status\nconst maxLabelNames = 10;\nconst maxLabelValues = 10;\n\ntype NodeState = 'waiting' | 'running' | 'error' | 'success';\n\n// mergeChildStates basically returns the \"worst\" state found among the children.\nconst mergeChildStates = (states: NodeState[]): NodeState => {\n if (states.includes('error')) {\n return 'error';\n }\n if (states.includes('waiting')) {\n return 'waiting';\n }\n if (states.includes('running')) {\n return 'running';\n }\n\n return 'success';\n};\n\ninterface TreeNodeProps {\n // The AST node to render.\n node: ASTNode;\n // The parent element of this node.\n parentEl?: HTMLDivElement | null;\n // Used to compute the position of the connector line between this node and its parent.\n reverse: boolean;\n // Datasource used for the node's individual query.\n datasource: PrometheusDatasourceSelector;\n // The index of this node in its parent's children.\n // Used to render the node's individual query.\n childIdx: number;\n // Function to report the node state to the parent.\n // Used to render the node's individual query.\n reportNodeState?: (childIdx: number, state: NodeState) => void;\n}\n\nexport default function TreeNode({\n node,\n parentEl,\n reverse,\n datasource,\n childIdx,\n reportNodeState,\n}: TreeNodeProps): ReactElement {\n const theme = useTheme();\n const children = getNodeChildren(node);\n\n // A normal ref won't work properly here because the ref's `current` property\n // going from `null` to defined won't trigger a re-render of the child\n // component, since it's not a React state update. So we manually have to\n // create a state update using a callback ref. See also\n // https://tkdodo.eu/blog/avoiding-use-effect-with-callback-refs\n const [nodeEl, setNodeEl] = useState<HTMLDivElement | null>(null);\n const nodeRef = useCallback((node: HTMLDivElement) => setNodeEl(node), []);\n\n const [resultStats, setResultStats] = useState<{\n numSeries: number;\n labelExamples: Record<string, Array<{ value: string; count: number }>>;\n sortedLabelCards: Array<[string, number]>;\n }>({\n numSeries: 0,\n labelExamples: {},\n sortedLabelCards: [],\n });\n\n const [connectorStyle, setConnectorStyle] = useState({\n borderColor: theme.palette.grey['500'],\n borderLeftStyle: 'solid',\n borderLeftWidth: 2,\n width: connectorWidth,\n left: -connectorWidth,\n });\n\n const [childStates, setChildStates] = useState<NodeState[]>(children.map(() => 'waiting'));\n const mergedChildState = useMemo(() => mergeChildStates(childStates), [childStates]);\n\n // Optimize range vector selector fetches to give us the info we're looking for\n // more cheaply. E.g. 'foo[7w]' can be expensive to fully fetch, but wrapping it\n // in 'last_over_time(foo[7w])' is cheaper and also gives us all the info we\n // need (number of series and labels).\n let queryNode = node;\n if (queryNode.type === nodeType.matrixSelector) {\n queryNode = {\n type: nodeType.call,\n func: functionSignatures.last_over_time!,\n args: [node],\n };\n }\n\n // Individual query for the current node\n const {\n data: instantQueryResponse,\n isFetching,\n error,\n } = useInstantQuery(serializeNode(queryNode) ?? '', datasource, mergedChildState === 'success');\n\n // report the node state to the parent\n useEffect(() => {\n if (reportNodeState) {\n if (mergedChildState === 'error' || error) {\n reportNodeState(childIdx, 'error');\n } else if (isFetching) {\n reportNodeState(childIdx, 'running');\n }\n }\n }, [mergedChildState, error, isFetching, reportNodeState, childIdx]);\n\n // This function is passed down to the child nodes so they can report their state.\n const childReportNodeState = useCallback(\n (childIdx: number, state: NodeState) => {\n setChildStates((prev) => {\n const newStates = [...prev];\n newStates[childIdx] = state;\n return newStates;\n });\n },\n [setChildStates]\n );\n\n // Update the size and position of tree connector lines based on the node's and its parent's position.\n useLayoutEffect(() => {\n if (parentEl === undefined) {\n // We're the root node.\n return;\n }\n\n if (parentEl === null || nodeEl === null) {\n // Either of the two connected nodes hasn't been rendered yet.\n return;\n }\n\n const parentRect = parentEl.getBoundingClientRect();\n const nodeRect = nodeEl.getBoundingClientRect();\n if (reverse) {\n setConnectorStyle((prevStyle) => ({\n ...prevStyle,\n top: 'calc(50% - 1px)',\n bottom: nodeRect.bottom - parentRect.top,\n borderTopLeftRadius: 10,\n borderTopStyle: 'solid',\n borderBottomLeftRadius: undefined,\n }));\n } else {\n setConnectorStyle((prevStyle) => ({\n ...prevStyle,\n top: parentRect.bottom - nodeRect.top,\n bottom: 'calc(50% - 1px)',\n borderBottomLeftRadius: 10,\n borderBottomStyle: 'solid',\n borderTopLeftRadius: undefined,\n }));\n }\n }, [parentEl, nodeEl, reverse, nodeRef, setConnectorStyle]);\n\n // Update the node info state based on the query result.\n useEffect(() => {\n if (instantQueryResponse?.status !== 'success') {\n return;\n }\n\n if (reportNodeState) {\n reportNodeState(childIdx, 'success');\n }\n\n let resultSeries = 0;\n // labelValuesByName records the number of times each label value appears for each label name.\n const labelValuesByName: Record<string, Record<string, number>> = {};\n const { resultType, result } = instantQueryResponse.data;\n\n if (resultType === 'scalar' || resultType === 'string') {\n resultSeries = 1;\n } else if (result && result.length > 0) {\n resultSeries = result.length;\n result.forEach((s) => {\n Object.entries(s.metric).forEach(([ln, lv]) => {\n // TODO: If we ever want to include __name__ here again, we cannot use the\n // last_over_time(foo[7d]) optimization since that removes the metric name.\n if (ln !== '__name__') {\n labelValuesByName[ln] = labelValuesByName[ln] ?? {};\n labelValuesByName[ln]![lv] = (labelValuesByName[ln]![lv] ?? 0) + 1;\n }\n });\n });\n }\n\n // labelCardinalities records the number of unique label values for each label name.\n const labelCardinalities: Record<string, number> = {};\n // labelExamples records the most common label values for each label name.\n const labelExamples: Record<string, Array<{ value: string; count: number }>> = {};\n Object.entries(labelValuesByName).forEach(([ln, lvs]) => {\n labelCardinalities[ln] = Object.keys(lvs).length;\n // Sort label values by their number of occurrences within this label name.\n labelExamples[ln] = Object.entries(lvs)\n .sort(([, aCnt], [, bCnt]) => bCnt - aCnt)\n .slice(0, maxLabelValues)\n .map(([lv, cnt]) => ({ value: lv, count: cnt }));\n });\n\n setResultStats({\n numSeries: resultSeries,\n sortedLabelCards: Object.entries(labelCardinalities).sort((a, b) => b[1] - a[1]),\n labelExamples,\n });\n }, [instantQueryResponse, reportNodeState, childIdx]);\n\n const innerNode = (\n <Stack direction=\"row\" gap={2}>\n <Box\n ref={nodeRef}\n sx={{\n position: 'relative',\n display: 'inline-block',\n padding: 1,\n marginBottom: 1.5,\n borderRadius: 2,\n backgroundColor: theme.palette.background.code,\n }}\n >\n {parentEl !== undefined && (\n // Connector line between this node and its parent.\n <Box\n sx={{\n position: 'absolute',\n display: 'inline-block',\n ...connectorStyle,\n }}\n />\n )}\n {/* The node (visible box) itself. */}\n {formatNode(node, false, 1)}\n </Box>\n {/* The node's individual query: */}\n <QueryStatus\n mergedChildState={mergedChildState}\n isFetching={isFetching}\n error={error}\n resultStats={resultStats}\n responseTime={instantQueryResponse?.responseTime}\n />\n </Stack>\n );\n\n if (node.type === nodeType.binaryExpr) {\n return (\n <div>\n <Box ml={nodeIndent}>\n <TreeNode\n node={children[0]!}\n parentEl={nodeEl}\n reverse={true}\n datasource={datasource}\n childIdx={0}\n reportNodeState={childReportNodeState}\n />\n </Box>\n {innerNode}\n <Box ml={nodeIndent}>\n <TreeNode\n node={children[1]!}\n parentEl={nodeEl}\n reverse={false}\n datasource={datasource}\n childIdx={1}\n reportNodeState={childReportNodeState}\n />\n </Box>\n </div>\n );\n }\n\n return (\n <div>\n {innerNode}\n {children.map((child, idx) => (\n <Box ml={nodeIndent} key={idx}>\n <TreeNode\n node={child}\n parentEl={nodeEl}\n reverse={false}\n datasource={datasource}\n childIdx={idx}\n reportNodeState={childReportNodeState}\n />\n </Box>\n ))}\n </div>\n );\n}\n\ninterface QueryStatusProps {\n mergedChildState: NodeState;\n isFetching: boolean;\n error: StatusError | null;\n resultStats: {\n numSeries: number;\n labelExamples: Record<string, Array<{ value: string; count: number }>>;\n sortedLabelCards: Array<[string, number]>;\n };\n responseTime?: number;\n}\n\nfunction QueryStatus({\n mergedChildState,\n isFetching,\n error,\n resultStats,\n responseTime,\n}: QueryStatusProps): ReactElement {\n if (mergedChildState === 'waiting') {\n return <ProgressState text=\"Waiting for child query\" />;\n }\n\n if (mergedChildState === 'running') {\n return <ProgressState text=\"Running\" />;\n }\n\n if (mergedChildState === 'error') {\n return (\n <Stack>\n <AlertCircle />\n Blocked on child query error\n </Stack>\n );\n }\n\n if (isFetching) {\n return <ProgressState text=\"Loading\" />;\n }\n\n if (error) {\n return (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n gap={1}\n sx={{ color: (theme) => theme.palette.error.main }}\n marginBottom={1.5}\n >\n <AlertCircle />\n <Typography variant=\"body2\">\n <strong>Error executing query:</strong> {error.message}\n </Typography>\n </Box>\n );\n }\n\n return (\n <Stack direction=\"row\" gap={1} alignItems=\"center\" marginBottom={1.5}>\n <Typography variant=\"body2\" component=\"span\" sx={{ color: (theme) => theme.palette.grey[500] }}>\n {resultStats.numSeries} result{resultStats.numSeries !== 1 && 's'}\n &nbsp;&nbsp;–&nbsp;&nbsp;\n {responseTime ? `${Math.round(responseTime)}ms` : '? ms'}\n {resultStats.sortedLabelCards.length > 0 && <>&nbsp;&nbsp;–</>}\n </Typography>\n {resultStats.sortedLabelCards.slice(0, maxLabelNames).map(([ln, cnt]) => (\n <Tooltip\n key={ln}\n title={\n <Box>\n <List dense>\n {resultStats.labelExamples[ln]?.map(({ value, count }) => (\n <ListItem\n key={value}\n sx={{\n display: 'flex',\n gap: 1,\n py: 0,\n px: 0.5,\n }}\n >\n <CircleIcon sx={{ fontSize: 8 }} />\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{\n color: (theme) =>\n theme.palette.mode === 'dark' // TODO we shouldnt have to do that I guess..\n ? theme.palette.warning.dark\n : theme.palette.warning.main,\n fontFamily: 'monospace',\n }}\n >\n {escapeString(value)}\n </Typography>\n <Typography variant=\"body2\" component=\"span\">\n ({count}x)\n </Typography>\n </ListItem>\n ))}\n {cnt > maxLabelValues && (\n <ListItem\n sx={{\n display: 'flex',\n gap: 1,\n py: 0,\n px: 0.5,\n }}\n >\n <CircleIcon sx={{ fontSize: 8 }} />\n <Typography variant=\"body2\">. . .</Typography>\n </ListItem>\n )}\n </List>\n </Box>\n }\n arrow\n >\n <span style={{ cursor: 'pointer', whiteSpace: 'nowrap' }}>\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{ fontFamily: 'monospace', color: (theme) => theme.palette.success.main }}\n >\n {ln}\n </Typography>\n <Typography variant=\"body2\" component=\"span\" sx={{ color: (theme) => theme.palette.grey[500] }}>\n : {cnt}\n </Typography>\n </span>\n </Tooltip>\n ))}\n {resultStats.sortedLabelCards.length > maxLabelNames ? (\n <Typography variant=\"body2\">...{resultStats.sortedLabelCards.length - maxLabelNames} more...</Typography>\n ) : null}\n </Stack>\n );\n}\n\nfunction ProgressState({ text }: { text: string }): ReactElement {\n return (\n <Box display=\"flex\" alignItems=\"center\" gap={1} marginBottom={1.5}>\n <CircularProgress size={16} color=\"secondary\" />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {text}...\n </Typography>\n </Box>\n );\n}\n"],"names":["Box","CircularProgress","List","ListItem","Stack","Tooltip","Typography","useTheme","CircleIcon","useCallback","useEffect","useLayoutEffect","useMemo","useState","AlertCircle","nodeType","escapeString","getNodeChildren","formatNode","serializeNode","functionSignatures","useInstantQuery","nodeIndent","connectorWidth","maxLabelNames","maxLabelValues","mergeChildStates","states","includes","TreeNode","node","parentEl","reverse","datasource","childIdx","reportNodeState","theme","children","nodeEl","setNodeEl","nodeRef","resultStats","setResultStats","numSeries","labelExamples","sortedLabelCards","connectorStyle","setConnectorStyle","borderColor","palette","grey","borderLeftStyle","borderLeftWidth","width","left","childStates","setChildStates","map","mergedChildState","queryNode","type","matrixSelector","call","func","last_over_time","args","data","instantQueryResponse","isFetching","error","childReportNodeState","state","prev","newStates","undefined","parentRect","getBoundingClientRect","nodeRect","prevStyle","top","bottom","borderTopLeftRadius","borderTopStyle","borderBottomLeftRadius","borderBottomStyle","status","resultSeries","labelValuesByName","resultType","result","length","forEach","s","Object","entries","metric","ln","lv","labelCardinalities","lvs","keys","sort","aCnt","bCnt","slice","cnt","value","count","a","b","innerNode","direction","gap","ref","sx","position","display","padding","marginBottom","borderRadius","backgroundColor","background","code","QueryStatus","responseTime","binaryExpr","div","ml","child","idx","ProgressState","text","alignItems","color","main","variant","strong","message","component","Math","round","title","dense","py","px","fontSize","mode","warning","dark","fontFamily","arrow","span","style","cursor","whiteSpace","success","size"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,oJAAoJ;;AA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AQ;gBAAQF,OAAM;;oBAC/BF;oBAAK;;;;;AAId"}
@@ -36,7 +36,7 @@ export function FinderFilters({ datasource, filters, filteredFilters, onDatasour
36
36
  children: [
37
37
  /*#__PURE__*/ _jsx(FormControl, {
38
38
  sx: {
39
- width: 250
39
+ width: 500
40
40
  },
41
41
  children: /*#__PURE__*/ _jsx(DatasourceSelect, {
42
42
  size: "medium",