a)?-1:1})):e}),[m,t,c,d,o]),_=(0,r.useMemo)((function(){return y.some((function(e){return e.copyValue}))}),[y]),b=function(e){return function(){!function(e){h((function(t){return"asc"===t&&c===e?"desc":"asc"})),s(e)}(e)}};return y.length?Vt("div",{className:Pr()({"vm-table-view":!0,"vm-table-view_mobile":a}),children:Vt("table",{className:"vm-table",ref:u,children:[Vt("thead",{className:"vm-table-header",children:Vt("tr",{className:"vm-table__row vm-table__row_header",children:[m.map((function(e,t){return Vt("td",{className:"vm-table-cell vm-table-cell_header vm-table-cell_sort",onClick:b(e.key),children:Vt("div",{className:"vm-table-cell__content",children:[e.key,Vt("div",{className:Pr()({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":c===e.key,"vm-table__sort-icon_desc":"desc"===d&&c===e.key}),children:Vt(er,{})})]})},t)})),Vt("td",{className:"vm-table-cell vm-table-cell_header vm-table-cell_right vm-table-cell_sort",onClick:b("Value"),children:Vt("div",{className:"vm-table-cell__content",children:[Vt("div",{className:Pr()({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":"Value"===c,"vm-table__sort-icon_desc":"desc"===d}),children:Vt(er,{})}),"Value"]})}),_&&Vt("td",{className:"vm-table-cell vm-table-cell_header"})]})}),Vt("tbody",{className:"vm-table-body",children:y.map((function(e,t){return Vt("tr",{className:"vm-table__row",children:[e.metadata.map((function(e,n){return Vt("td",{className:Pr()({"vm-table-cell vm-table-cell_no-wrap":!0,"vm-table-cell_gray":y[t-1]&&y[t-1].metadata[n]===e}),children:e},n)})),Vt("td",{className:"vm-table-cell vm-table-cell_right vm-table-cell_no-wrap",children:e.values.length?e.values.map((function(e){return Vt("p",{children:e},e)})):e.value}),_&&Vt("td",{className:"vm-table-cell vm-table-cell_right",children:e.copyValue&&Vt("div",{className:"vm-table-cell__content",children:Vt(Si,{title:"Copy row",children:Vt(yi,{variant:"text",color:"gray",size:"small",startIcon:Vt(gr,{}),onClick:(n=e.copyValue,$i(ji().mark((function e(){return ji().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i(n,"Row has been copied");case 2:case"end":return e.stop()}}),e)})))),ariaLabel:"copy row"})})})})]},t);var n}))})]})}):Vt(ci,{variant:"warning",children:"No data to show"})},fd=function(e){var t=e.text,n=e.href,r=e.children,i=e.colored,a=void 0===i||i,o=e.underlined,u=void 0!==o&&o,l=e.withIcon,c=void 0!==l&&l;return Vt("a",{href:n,className:Pr()({"vm-link":!0,"vm-link_colored":a,"vm-link_underlined":u,"vm-link_with-icon":c}),target:"_blank",rel:"noreferrer",children:t||r})},dd=Vt(fd,{text:"last_over_time",href:"https://docs.victoriametrics.com/MetricsQL.html#last_over_time",underlined:!0}),hd=Vt(fd,{text:"instant query",href:"https://docs.victoriametrics.com/keyConcepts.html#instant-query",underlined:!0}),md=function(){return Vt("div",{children:[Vt("p",{children:["This tab shows ",hd," results for the last 5 minutes ending at the selected time range."]}),Vt("p",{children:["Please wrap the query into ",dd," if you need results over arbitrary lookbehind interval."]})]})},pd=function(){var e=Jr(),t=e.displayType,n=e.isTracingEnabled,i=jn().query,a=On().period,o=Ln(),u=ui().isMobile;!function(){var e=Ut().tenantId,t=Jr().displayType,n=jn().query,i=On(),a=i.duration,o=i.relativeTime,u=i.period,l=u.date,c=u.step,s=ri().customStep,f=v(ot(),2)[1],d=function(){var r={};n.forEach((function(n,i){var u,f="g".concat(i);r["".concat(f,".expr")]=n,r["".concat(f,".range_input")]=a,r["".concat(f,".end_input")]=l,r["".concat(f,".tab")]=(null===(u=Yr.find((function(e){return e.value===t})))||void 0===u?void 0:u.prometheusCode)||0,r["".concat(f,".relative_time")]=o,r["".concat(f,".tenantID")]=e,c!==s&&s&&(r["".concat(f,".step_input")]=s)})),f(od(r))};(0,r.useEffect)(d,[e,t,n,a,o,l,c,s]),(0,r.useEffect)(d,[])}();var l=v((0,r.useState)(),2),c=l[0],s=l[1],f=v((0,r.useState)([]),2),d=f[0],h=f[1],m=v((0,r.useState)([]),2),p=m[0],g=m[1],y=v((0,r.useState)(!i[0]),2),b=y[0],w=y[1],D=_i(!1),k=D.value,x=D.setTrue,C=D.setFalse,S=ri(),E=S.customStep,A=S.yaxis,N=ii(),M=Wf({visible:!0,customStep:E,hideQuery:p,showAllSeries:k}),F=M.isLoading,T=M.liveData,O=M.graphData,L=M.error,P=M.queryErrors,I=M.setQueryErrors,R=M.queryStats,B=M.warning,z=M.traces,j=M.isHistogram,H=function(e){N({type:"SET_YAXIS_LIMITS",payload:e})},$=(0,r.useMemo)((function(){return ud(T||[]).map((function(e){return e.key}))}),[T]),V=Jr().tableCompact,Y=Xr();return Hr("popstate",(function(){return window.location.reload()})),(0,r.useEffect)((function(){z&&h([].concat(_(d),_(z)))}),[z]),(0,r.useEffect)((function(){h([])}),[t]),(0,r.useEffect)(C,[i]),(0,r.useEffect)((function(){N({type:"SET_IS_HISTOGRAM",payload:j})}),[O]),Vt("div",{className:Pr()({"vm-custom-panel":!0,"vm-custom-panel_mobile":u}),children:[Vt(jf,{queryErrors:b?[]:P,setQueryErrors:I,setHideError:w,stats:R,onHideQuery:function(e){g(e)},onRunQuery:function(){w(!1)}}),n&&Vt("div",{className:"vm-custom-panel__trace",children:Vt(nd,{traces:d,onDeleteClick:function(e){var t=d.filter((function(t){return t.idValue!==e.idValue}));h(_(t))}})}),F&&Vt(Jf,{}),!b&&L&&Vt(ci,{variant:"error",children:L}),!(null!==T&&void 0!==T&&T.length)&&"chart"!==t&&Vt(ci,{variant:"info",children:Vt(md,{})}),B&&Vt(ci,{variant:"warning",children:Vt("div",{className:Pr()({"vm-custom-panel__warning":!0,"vm-custom-panel__warning_mobile":u}),children:[Vt("p",{children:B}),Vt(yi,{color:"warning",variant:"outlined",onClick:x,children:"Show all"})]})}),Vt("div",{className:Pr()({"vm-custom-panel-body":!0,"vm-custom-panel-body_mobile":u,"vm-block":!0,"vm-block_mobile":u}),children:[Vt("div",{className:"vm-custom-panel-body-header",children:[Vt(Ur,{}),"chart"===t&&Vt("div",{className:"vm-custom-panel-body-header__left",children:[Vt(Fi,{}),Vt(Kf,{yaxis:A,setYaxisLimits:H,toggleEnableLimits:function(){N({type:"TOGGLE_ENABLE_YAXIS_LIMITS"})}})]}),"table"===t&&Vt(ad,{columns:$,defaultColumns:c,onChangeColumns:s,tableCompact:V,toggleTableCompact:function(){Y({type:"TOGGLE_TABLE_COMPACT"})}})]}),O&&a&&"chart"===t&&Vt(xs,{data:O,period:a,customStep:E,query:i,yaxis:A,setYaxisLimits:H,setPeriod:function(e){var t=e.from,n=e.to;o({type:"SET_PERIOD",payload:{from:t,to:n}})},height:u?.5*window.innerHeight:500,isHistogram:j}),T&&"code"===t&&Vt(Zf,{data:T}),T&&"table"===t&&Vt(sd,{data:T,displayColumns:c})]})]})},vd=function(e){var t=e.title,n=e.description,i=e.unit,a=e.expr,o=e.showLegend,u=e.filename,l=e.alias,c=ui().isMobile,s=On().period,f=ri().customStep,d=Ln(),h=(0,r.useRef)(null),m=v((0,r.useState)(!1),2),p=m[0],g=m[1],y=v((0,r.useState)({limits:{enable:!1,range:{1:[0,0]}}}),2),_=y[0],b=y[1],w=(0,r.useMemo)((function(){return Array.isArray(a)&&a.every((function(e){return e}))}),[a]),D=Wf({predefinedQuery:w?a:[],display:"chart",visible:p,customStep:f}),k=D.isLoading,x=D.graphData,C=D.error,S=D.warning,E=function(e){var t=st({},_);t.limits.range=e,b(t)};return(0,r.useEffect)((function(){var e=new IntersectionObserver((function(e){e.forEach((function(e){return g(e.isIntersecting)}))}),{threshold:.1});return h.current&&e.observe(h.current),function(){h.current&&e.unobserve(h.current)}}),[h]),w?Vt("div",{className:"vm-predefined-panel",ref:h,children:[Vt("div",{className:"vm-predefined-panel-header",children:[Vt(Si,{title:Vt((function(){return Vt("div",{className:"vm-predefined-panel-header__description vm-default-styles",children:[n&&Vt(Ht.HY,{children:[Vt("div",{children:[Vt("span",{children:"Description:"}),Vt("div",{dangerouslySetInnerHTML:{__html:wf.parse(n)}})]}),Vt("hr",{})]}),Vt("div",{children:[Vt("span",{children:"Queries:"}),Vt("div",{children:a.map((function(e,t){return Vt("div",{children:e},"".concat(t,"_").concat(e))}))})]})]})}),{}),children:Vt("div",{className:"vm-predefined-panel-header__info",children:Vt(Zn,{})})}),Vt("h3",{className:"vm-predefined-panel-header__title",children:t||""}),Vt(Kf,{yaxis:_,setYaxisLimits:E,toggleEnableLimits:function(){var e=st({},_);e.limits.enable=!e.limits.enable,b(e)}})]}),Vt("div",{className:"vm-predefined-panel-body",children:[k&&Vt(Jf,{}),C&&Vt(ci,{variant:"error",children:C}),S&&Vt(ci,{variant:"warning",children:S}),x&&Vt(xs,{data:x,period:s,customStep:f,query:a,yaxis:_,unit:i,alias:l,showLegend:o,setYaxisLimits:E,setPeriod:function(e){var t=e.from,n=e.to;d({type:"SET_PERIOD",payload:{from:t,to:n}})},fullWidth:!1,height:c?.5*window.innerHeight:500})]})]}):Vt(ci,{variant:"error",children:[Vt("code",{children:'"expr"'})," not found. Check the configuration file ",Vt("b",{children:u}),"."]})},gd=function(e){var t=e.index,n=e.title,i=e.panels,a=e.filename,o=$r(),u=(0,r.useMemo)((function(){return o.width/12}),[o]),l=v((0,r.useState)(!t),2),c=l[0],s=l[1],f=v((0,r.useState)([]),2),d=f[0],h=f[1];(0,r.useEffect)((function(){h(i&&i.map((function(e){return e.width||12})))}),[i]);var m=v((0,r.useState)({start:0,target:0,enable:!1}),2),p=m[0],g=m[1],y=(0,r.useCallback)((function(e){if(p.enable){var t=p.start,n=Math.ceil((t-e.clientX)/u);if(!(Math.abs(n)>=12)){var r=d.map((function(e,t){return e-(t===p.target?n:0)}));h(r)}}}),[p,u]),_=(0,r.useCallback)((function(){g(st(st({},p),{},{enable:!1}))}),[p]),b=function(e){return function(t){!function(e,t){g({start:e.clientX,target:t,enable:!0})}(t,e)}};return Hr("mousemove",y),Hr("mouseup",_),Vt("div",{className:"vm-predefined-dashboard",children:Vt(Ca,{defaultExpanded:c,onChange:function(e){return s(e)},title:Vt((function(){return Vt("div",{className:Pr()({"vm-predefined-dashboard-header":!0,"vm-predefined-dashboard-header_open":c}),children:[(n||a)&&Vt("span",{className:"vm-predefined-dashboard-header__title",children:n||"".concat(t+1,". ").concat(a)}),i&&Vt("span",{className:"vm-predefined-dashboard-header__count",children:["(",i.length," panels)"]})]})}),{}),children:Vt("div",{className:"vm-predefined-dashboard-panels",children:Array.isArray(i)&&i.length?i.map((function(e,t){return Vt("div",{className:"vm-predefined-dashboard-panels-panel vm-block vm-block_empty-padding",style:{gridColumn:"span ".concat(d[t])},children:[Vt(vd,{title:e.title,description:e.description,unit:e.unit,expr:e.expr,alias:e.alias,filename:a,showLegend:e.showLegend}),Vt("button",{className:"vm-predefined-dashboard-panels-panel__resizer",onMouseDown:b(t),"aria-label":"resize the panel"})]},t)})):Vt("div",{className:"vm-predefined-dashboard-panels-panel__alert",children:Vt(ci,{variant:"error",children:[Vt("code",{children:'"panels"'})," not found. Check the configuration file ",Vt("b",{children:a}),"."]})})})})})},yd=function(){!function(){var e=On(),t=e.duration,n=e.relativeTime,i=e.period.date,a=ri().customStep,o=ga().setSearchParamsFromKeys,u=function(){var e,r=od((lt(e={},"g0.range_input",t),lt(e,"g0.end_input",i),lt(e,"g0.step_input",a),lt(e,"g0.relative_time",n),e));o(r)};(0,r.useEffect)(u,[t,n,i,a]),(0,r.useEffect)(u,[])}();var e=ui().isMobile,t=mi(),n=t.dashboardsSettings,i=t.dashboardsLoading,a=t.dashboardsError,o=v((0,r.useState)(0),2),u=o[0],l=o[1],c=(0,r.useMemo)((function(){return n.map((function(e,t){return{label:e.title||"",value:t}}))}),[n]),s=(0,r.useMemo)((function(){return n[u]||{}}),[n,u]),f=(0,r.useMemo)((function(){return null===s||void 0===s?void 0:s.rows}),[s]),d=(0,r.useMemo)((function(){return s.title||s.filename||""}),[s]),h=(0,r.useMemo)((function(){return Array.isArray(f)&&!!f.length}),[f]),m=function(e){return function(){!function(e){l(e)}(e)}};return Vt("div",{className:"vm-predefined-panels",children:[i&&Vt(Jf,{}),!n.length&&a&&Vt(ci,{variant:"error",children:a}),!n.length&&Vt(ci,{variant:"info",children:"Dashboards not found"}),c.length>1&&Vt("div",{className:Pr()({"vm-predefined-panels-tabs":!0,"vm-predefined-panels-tabs_mobile":e}),children:c.map((function(e){return Vt("div",{className:Pr()({"vm-predefined-panels-tabs__tab":!0,"vm-predefined-panels-tabs__tab_active":e.value==u}),onClick:m(e.value),children:e.label},e.value)}))}),Vt("div",{className:"vm-predefined-panels__dashboards",children:[h&&f.map((function(e,t){return Vt(gd,{index:t,filename:d,title:e.title,panels:e.panels},"".concat(u,"_").concat(t))})),!!n.length&&!h&&Vt(ci,{variant:"error",children:[Vt("code",{children:'"rows"'})," not found. Check the configuration file ",Vt("b",{children:d}),"."]})]})]})},_d=function(e,t){var n=t.match?"&match[]="+encodeURIComponent(t.match):"",r=t.focusLabel?"&focusLabel="+encodeURIComponent(t.focusLabel):"";return"".concat(e,"/api/v1/status/tsdb?topN=").concat(t.topN,"&date=").concat(t.date).concat(n).concat(r)},bd=function(){function e(){b(this,e),this.tsdbStatus=void 0,this.tabsNames=void 0,this.isPrometheus=void 0,this.tsdbStatus=this.defaultTSDBStatus,this.tabsNames=["table","graph"],this.isPrometheus=!1,this.getDefaultState=this.getDefaultState.bind(this)}return x(e,[{key:"tsdbStatusData",get:function(){return this.tsdbStatus},set:function(e){this.isPrometheus=!(null===e||void 0===e||!e.headStats),this.tsdbStatus=e}},{key:"defaultTSDBStatus",get:function(){return{totalSeries:0,totalSeriesPrev:0,totalSeriesByAll:0,totalLabelValuePairs:0,seriesCountByMetricName:[],seriesCountByLabelName:[],seriesCountByFocusLabelValue:[],seriesCountByLabelValuePair:[],labelValueCountByLabelName:[]}}},{key:"isPrometheusData",get:function(){return this.isPrometheus}},{key:"keys",value:function(e,t){var n=e&&/__name__=".+"/.test(e),r=e&&/{.+=".+"}/g.test(e),i=e&&/__name__=".+", .+!=""/g.test(e),a=[];return a=t||i?a.concat("seriesCountByFocusLabelValue"):n?a.concat("labelValueCountByLabelName"):r?a.concat("seriesCountByMetricName","seriesCountByLabelName"):a.concat("seriesCountByMetricName","seriesCountByLabelName","seriesCountByLabelValuePair","labelValueCountByLabelName"),a}},{key:"getDefaultState",value:function(e,t){var n=this;return this.keys(e,t).reduce((function(e,t){return st(st({},e),{},{tabs:st(st({},e.tabs),{},lt({},t,n.tabsNames)),containerRefs:st(st({},e.containerRefs),{},lt({},t,(0,r.useRef)(null)))})}),{tabs:{},containerRefs:{}})}},{key:"sectionsTitles",value:function(e){return{seriesCountByMetricName:"Metric names with the highest number of series",seriesCountByLabelName:"Labels with the highest number of series",seriesCountByFocusLabelValue:'Values for "'.concat(e,'" label with the highest number of series'),seriesCountByLabelValuePair:"Label=value pairs with the highest number of series",labelValueCountByLabelName:"Labels with the highest number of unique values"}}},{key:"sectionsTips",get:function(){return{seriesCountByMetricName:"\n \n This table returns a list of metrics with the highest cardinality.\n The cardinality of a metric is the number of time series associated with that metric,\n where each time series is defined as a unique combination of key-value label pairs.\n
\n \n When looking to reduce the number of active series in your data source,\n you can start by inspecting individual metrics with high cardinality\n (i.e. that have lots of active time series associated with them),\n since that single metric contributes a large fraction of the series that make up your total series count.\n
",seriesCountByLabelName:"\n \n This table returns a list of the labels with the highest number of series.\n
\n \n Use this table to identify labels that are storing dimensions with high cardinality\n (many different label values).\n
\n \n It is recommended to choose labels such that they have a finite set of values,\n since every unique combination of key-value label pairs creates a new time series\n and therefore can dramatically increase the number of time series in your system.\n
",seriesCountByFocusLabelValue:"\n \n This table returns a list of unique label values per selected label.\n
\n \n Use this table to identify label values that are storing per each selected series.\n
",labelValueCountByLabelName:"\n \n This table returns a list of labels with the highest number of the unique values.\n
\n ",seriesCountByLabelValuePair:"\n \n This table returns a list of the label values pairs with the highest number of series.\n
\n \n Use this table to identify unique label values pairs. This helps to identify same labels \n is applied to count timeseries in your system, since every unique combination of key-value label pairs \n creates a new time series and therefore can dramatically increase the number of time series in your system\n
"}}},{key:"tablesHeaders",get:function(){return{seriesCountByMetricName:wd,seriesCountByLabelName:Dd,seriesCountByFocusLabelValue:kd,seriesCountByLabelValuePair:xd,labelValueCountByLabelName:Cd}}},{key:"totalSeries",value:function(e){return"labelValueCountByLabelName"===e?-1:arguments.length>1&&void 0!==arguments[1]&&arguments[1]?this.tsdbStatus.totalSeriesPrev:this.tsdbStatus.totalSeries}}]),e}(),wd=[{id:"name",label:"Metric name"},{id:"value",label:"Number of series"},{id:"percentage",label:"Share in total",info:"Shows the share of a metric to the total number of series"},{id:"action",label:""}],Dd=[{id:"name",label:"Label name"},{id:"value",label:"Number of series"},{id:"percentage",label:"Share in total",info:"Shows the share of the label to the total number of series"},{id:"action",label:""}],kd=[{id:"name",label:"Label value"},{id:"value",label:"Number of series"},{id:"percentage",label:"Share in total"},{disablePadding:!1,id:"action",label:"",numeric:!1}],xd=[{id:"name",label:"Label=value pair"},{id:"value",label:"Number of series"},{id:"percentage",label:"Share in total",info:"Shows the share of the label value pair to the total number of series"},{id:"action",label:""}],Cd=[{id:"name",label:"Label name"},{id:"value",label:"Number of unique values"},{id:"action",label:""}],Sd={seriesCountByMetricName:function(e){var t=e.query;return Ed("__name__",t)},seriesCountByLabelName:function(e){var t=e.query;return"{".concat(t,'!=""}')},seriesCountByFocusLabelValue:function(e){var t=e.query,n=e.focusLabel;return Ed(n,t)},seriesCountByLabelValuePair:function(e){var t=e.query.split("="),n=t[0],r=t.slice(1).join("=");return Ed(n,r)},labelValueCountByLabelName:function(e){var t=e.query,n=e.match;return""===n?"{".concat(t,'!=""}'):"".concat(n.replace("}",""),", ").concat(t,'!=""}')}},Ed=function(e,t){return e?"{"+e+"="+JSON.stringify(t)+"}":""},Ad=function(e){var t,n=e.totalSeries,r=void 0===n?0:n,i=e.totalSeriesPrev,a=void 0===i?0:i,o=e.totalSeriesAll,u=void 0===o?0:o,l=e.seriesCountByMetricName,c=void 0===l?[]:l,s=e.isPrometheus,f=ui().isMobile,d=v(ot(),1)[0],h=d.get("match"),m=d.get("focusLabel"),p=/__name__/.test(h||""),g=(null===(t=c[0])||void 0===t?void 0:t.value)/u*100,y=r-a,_=Math.abs(y)/a*100,b=[{title:"Total series",value:r.toLocaleString("en-US"),dynamic:r&&a&&!s?"".concat(_.toFixed(2),"%"):"",display:!m,info:'The total number of active time series. \n A time series is uniquely identified by its name plus a set of its labels. \n For example, temperature{city="NY",country="US"} and temperature{city="SF",country="US"} \n are two distinct series, since they differ by the city label.'},{title:"Percentage from total",value:isNaN(g)?"-":"".concat(g.toFixed(2),"%"),display:p,info:"The share of these series in the total number of time series."}].filter((function(e){return e.display}));return b.length?Vt("div",{className:Pr()({"vm-cardinality-totals":!0,"vm-cardinality-totals_mobile":f}),children:b.map((function(e){var t=e.title,n=e.value,r=e.info,i=e.dynamic;return Vt("div",{className:"vm-cardinality-totals-card",children:[Vt("h4",{className:"vm-cardinality-totals-card__title",children:[t,r&&Vt(Si,{title:Vt("p",{className:"vm-cardinality-totals-card__tooltip",children:r}),children:Vt("div",{className:"vm-cardinality-totals-card__info-icon",children:Vt(Zn,{})})})]}),Vt("span",{className:"vm-cardinality-totals-card__value",children:n}),!!i&&Vt(Si,{title:"in relation to the previous day: ".concat(a.toLocaleString("en-US")),children:Vt("span",{className:Pr()({"vm-dynamic-number":!0,"vm-dynamic-number_positive vm-dynamic-number_down":y<0,"vm-dynamic-number_negative vm-dynamic-number_up":y>0}),children:i})})]},t)}))}):null},Nd=function(e,t){var n=v(ot(),1)[0],i=n.get(t)?n.get(t):e,a=v((0,r.useState)(i),2),o=a[0],u=a[1];return(0,r.useEffect)((function(){i!==o&&u(i)}),[i]),[o,u]},Md=["isPrometheus","isCluster"],Fd=function(e){var t=e.isPrometheus,n=e.isCluster,i=Ir(e,Md),a=ui().isMobile,o=v(ot(),1)[0],u=ga().setSearchParamsFromKeys,l=o.get("tips")||"",c=v(Nd("","match"),2),s=c[0],f=c[1],d=v(Nd("","focusLabel"),2),h=d[0],m=d[1],p=v(Nd(10,"topN"),2),g=p[0],y=p[1],_=(0,r.useMemo)((function(){return g<0?"Number must be bigger than zero":""}),[g]),b=function(){u({match:s,topN:g,focusLabel:h})};return(0,r.useEffect)((function(){var e=o.get("match"),t=+(o.get("topN")||10),n=o.get("focusLabel");e!==s&&f(e||""),t!==g&&y(t),n!==h&&m(n||"")}),[o]),Vt("div",{className:Pr()({"vm-cardinality-configurator":!0,"vm-cardinality-configurator_mobile":a,"vm-block":!0,"vm-block_mobile":a}),children:[Vt("div",{className:"vm-cardinality-configurator-controls",children:[Vt("div",{className:"vm-cardinality-configurator-controls__query",children:Vt(Gi,{label:"Time series selector",type:"string",value:s,onChange:f,onEnter:b})}),Vt("div",{className:"vm-cardinality-configurator-controls__item",children:Vt(Gi,{label:"Focus label",type:"text",value:h||"",onChange:m,onEnter:b,endIcon:Vt(Si,{title:Vt("div",{children:Vt("p",{children:"To identify values with the highest number of series for the selected label."})}),children:Vt(Dr,{})})})}),Vt("div",{className:"vm-cardinality-configurator-controls__item vm-cardinality-configurator-controls__item_limit",children:Vt(Gi,{label:"Limit entries",type:"number",value:t?10:g,error:_,disabled:t,helperText:t?"not available for Prometheus":"",onChange:function(e){var t=+e;y(isNaN(t)?0:t)},onEnter:b})})]}),Vt("div",{className:"vm-cardinality-configurator-bottom",children:[Vt(Ad,st({isPrometheus:t,isCluster:n},i)),n&&Vt("div",{className:"vm-cardinality-configurator-bottom-helpful",children:Vt(fd,{href:"https://docs.victoriametrics.com/#cardinality-explorer-statistic-inaccurancy",withIcon:!0,children:[Vt(br,{}),"Statistic inaccuracy explanation"]})}),Vt("div",{className:"vm-cardinality-configurator-bottom-helpful",children:Vt(fd,{href:"https://docs.victoriametrics.com/#cardinality-explorer",withIcon:!0,children:[Vt(br,{}),"Documentation"]})}),Vt("div",{className:"vm-cardinality-configurator-bottom__execute",children:[Vt(Si,{title:l?"Hide tips":"Show tips",children:Vt(yi,{variant:"text",color:l?"warning":"gray",startIcon:Vt(Sr,{}),onClick:function(){var e=o.get("tips")||"";u({tips:e?"":"true"})},ariaLabel:"visibility tips"})}),Vt(yi,{variant:"text",startIcon:Vt(Wn,{}),onClick:function(){u({match:"",focusLabel:""})},children:"Reset"}),Vt(yi,{startIcon:Vt(ar,{}),onClick:b,children:"Execute Query"})]})]})]})};function Td(e){var t=e.order,n=e.orderBy,r=e.onRequestSort,i=e.headerCells;return Vt("thead",{className:"vm-table-header vm-cardinality-panel-table__header",children:Vt("tr",{className:"vm-table__row vm-table__row_header",children:i.map((function(e){return Vt("th",{className:Pr()({"vm-table-cell vm-table-cell_header":!0,"vm-table-cell_sort":"action"!==e.id&&"percentage"!==e.id,"vm-table-cell_right":"action"===e.id}),onClick:(i=e.id,function(e){r(e,i)}),children:Vt("div",{className:"vm-table-cell__content",children:[e.info?Vt(Si,{title:e.info,children:[Vt("div",{className:"vm-metrics-content-header__tip-icon",children:Vt(Zn,{})}),e.label]}):Vt(Ht.HY,{children:e.label}),"action"!==e.id&&"percentage"!==e.id&&Vt("div",{className:Pr()({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":n===e.id,"vm-table__sort-icon_desc":"desc"===t&&n===e.id}),children:Vt(er,{})})]})},e.id);var i}))})})}function Od(e,t,n){return t[n]e[n]?1:0}function Ld(e,t){return"desc"===e?function(e,n){return Od(e,n,t)}:function(e,n){return-Od(e,n,t)}}function Pd(e,t){var n=e.map((function(e,t){return[e,t]}));return n.sort((function(e,n){var r=t(e[0],n[0]);return 0!==r?r:e[1]-n[1]})),n.map((function(e){return e[0]}))}var Id=function(e){var t=e.rows,n=e.headerCells,i=e.defaultSortColumn,a=e.tableCells,o=v((0,r.useState)("desc"),2),u=o[0],l=o[1],c=v((0,r.useState)(i),2),s=c[0],f=c[1],d=Pd(t,Ld(u,s));return Vt("table",{className:"vm-table vm-cardinality-panel-table",children:[Vt(Td,{order:u,orderBy:s,onRequestSort:function(e,t){l(s===t&&"asc"===u?"desc":"asc"),f(t)},rowCount:t.length,headerCells:n}),Vt("tbody",{className:"vm-table-header",children:d.map((function(e){return Vt("tr",{className:"vm-table__row",children:a(e)},e.name)}))})]})},Rd=function(e){var t=e.row,n=e.totalSeries,r=e.totalSeriesPrev,i=e.onActionClick,a=n>0?t.value/n*100:-1,o=r>0?t.valuePrev/r*100:-1,u=[a,o].some((function(e){return-1===e})),l=a-o,c=u?"":"".concat(l.toFixed(2),"%"),s=function(){i(t.name)};return Vt(Ht.HY,{children:[Vt("td",{className:"vm-table-cell",children:Vt("span",{className:"vm-link vm-link_colored",onClick:s,children:t.name})},t.name),Vt("td",{className:"vm-table-cell",children:[t.value,!!t.diff&&Vt(Si,{title:"in relation to the previous day: ".concat(t.valuePrev),children:Vt("span",{className:Pr()({"vm-dynamic-number":!0,"vm-dynamic-number_positive":t.diff<0,"vm-dynamic-number_negative":t.diff>0}),children:["\xa0",t.diff>0?"+":"",t.diff]})})]},t.value),a>0&&Vt("td",{className:"vm-table-cell",children:Vt("div",{className:"vm-cardinality-panel-table__progress",children:[Vt(Xf,{value:a}),c&&Vt(Si,{title:"in relation to the previous day",children:Vt("span",{className:Pr()({"vm-dynamic-number":!0,"vm-dynamic-number_positive vm-dynamic-number_down":l<0,"vm-dynamic-number_negative vm-dynamic-number_up":l>0}),children:c})})]})},t.progressValue),Vt("td",{className:"vm-table-cell vm-table-cell_right",children:Vt("div",{className:"vm-table-cell__content",children:Vt(Si,{title:"Filter by ".concat(t.name),children:Vt(yi,{variant:"text",size:"small",onClick:s,children:Vt(or,{})})})})},"action")]})},Bd=function(e){var t=e.data,n=v((0,r.useState)([]),2),i=n[0],a=n[1],o=v((0,r.useState)([0,0]),2),u=o[0],l=o[1];return(0,r.useEffect)((function(){var e=t.sort((function(e,t){return t.value-e.value})),n=function(e){var t=e.map((function(e){return e.value})),n=Math.ceil(t[0]||1),r=n/9;return new Array(11).fill(n+r).map((function(e,t){return Math.round(e-r*t)}))}(e);l(n),a(e.map((function(e){return st(st({},e),{},{percentage:e.value/n[0]*100})})))}),[t]),Vt("div",{className:"vm-simple-bar-chart",children:[Vt("div",{className:"vm-simple-bar-chart-y-axis",children:u.map((function(e){return Vt("div",{className:"vm-simple-bar-chart-y-axis__tick",children:e},e)}))}),Vt("div",{className:"vm-simple-bar-chart-data",children:i.map((function(e){var t=e.name,n=e.value,r=e.percentage;return Vt(Si,{title:"".concat(t,": ").concat(n),placement:"top-center",children:Vt("div",{className:"vm-simple-bar-chart-data-item",style:{maxHeight:"".concat(r||0,"%")}})},"".concat(t,"_").concat(n))}))})]})},zd=function(e){var t=e.rows,n=e.tabs,i=void 0===n?[]:n,a=e.chartContainer,o=e.totalSeries,u=e.totalSeriesPrev,l=e.onActionClick,c=e.sectionTitle,s=e.tip,f=e.tableHeaderCells,d=e.isPrometheus,h=ui().isMobile,m=v((0,r.useState)("table"),2),p=m[0],g=m[1],y=d&&!t.length,_=(0,r.useMemo)((function(){return i.map((function(e,t){return{value:e,label:e,icon:Vt(0===t?lr:ur,{})}}))}),[i]);return Vt("div",{className:Pr()({"vm-metrics-content":!0,"vm-metrics-content_mobile":h,"vm-block":!0,"vm-block_mobile":h}),children:[Vt("div",{className:"vm-metrics-content-header vm-section-header",children:[Vt("h5",{className:Pr()({"vm-metrics-content-header__title":!0,"vm-section-header__title":!0,"vm-section-header__title_mobile":h}),children:[!h&&s&&Vt(Si,{title:Vt("p",{dangerouslySetInnerHTML:{__html:s},className:"vm-metrics-content-header__tip"}),children:Vt("div",{className:"vm-metrics-content-header__tip-icon",children:Vt(Zn,{})})}),c]}),Vt("div",{className:"vm-section-header__tabs",children:Vt(Vr,{activeItem:p,items:_,onChange:g})})]}),y&&Vt("div",{className:"vm-metrics-content-prom-data",children:[Vt("div",{className:"vm-metrics-content-prom-data__icon",children:Vt(Zn,{})}),Vt("h3",{className:"vm-metrics-content-prom-data__title",children:"Prometheus Data Limitation"}),Vt("p",{className:"vm-metrics-content-prom-data__text",children:["Due to missing data from your Prometheus source, some tables may appear empty.",Vt("br",{}),"This does not indicate an issue with your system or our tool."]})]}),!y&&"table"===p&&Vt("div",{ref:a,className:Pr()({"vm-metrics-content__table":!0,"vm-metrics-content__table_mobile":h}),children:Vt(Id,{rows:t,headerCells:f,defaultSortColumn:"value",tableCells:function(e){return Vt(Rd,{row:e,totalSeries:o,totalSeriesPrev:u,onActionClick:l})}})}),!y&&"graph"===p&&Vt("div",{className:"vm-metrics-content__chart",children:Vt(Bd,{data:t.map((function(e){return{name:e.name,value:e.value}}))})})]})},jd=function(e){var t=e.title,n=e.children;return Vt("div",{className:"vm-cardinality-tip",children:[Vt("div",{className:"vm-cardinality-tip-header",children:[Vt("div",{className:"vm-cardinality-tip-header__tip-icon",children:Vt(Sr,{})}),Vt("h4",{className:"vm-cardinality-tip-header__title",children:t||"Tips"})]}),Vt("p",{className:"vm-cardinality-tip__description",children:n})]})},Hd=function(){return Vt(jd,{title:"Metrics with a high number of series",children:Vt("ul",{children:[Vt("li",{children:["Identify and eliminate labels with frequently changed values to reduce their\xa0",Vt(fd,{href:"https://docs.victoriametrics.com/FAQ.html#what-is-high-cardinality",children:"cardinality"}),"\xa0and\xa0",Vt(fd,{href:"https://docs.victoriametrics.com/FAQ.html#what-is-high-churn-rate",children:"high churn rate"})]}),Vt("li",{children:["Find unused time series and\xa0",Vt(fd,{href:"https://docs.victoriametrics.com/relabeling.html",children:"drop entire metrics"})]}),Vt("li",{children:["Aggregate time series before they got ingested into the database via\xa0",Vt(fd,{href:"https://docs.victoriametrics.com/stream-aggregation.html",children:"streaming aggregation"})]})]})})},$d=function(){return Vt(jd,{title:"Labels with a high number of unique values",children:Vt("ul",{children:[Vt("li",{children:"Decrease the number of unique label values to reduce cardinality"}),Vt("li",{children:["Drop the label entirely via\xa0",Vt(fd,{href:"https://docs.victoriametrics.com/relabeling.html",children:"relabeling"})]}),Vt("li",{children:"For volatile label values (such as URL path, user session, etc.) consider printing them to the log file instead of adding to time series"})]})})},Vd=function(){return Vt(jd,{title:"Dashboard of a single metric",children:[Vt("p",{children:"This dashboard helps to understand the cardinality of a single metric."}),Vt("p",{children:"Each time series is a unique combination of key-value label pairs. Therefore a label key with many values can create a lot of time series for a particular metric. If you\u2019re trying to decrease the cardinality of a metric, start by looking at the labels with the highest number of values."}),Vt("p",{children:"Use the series selector at the top of the page to apply additional filters."})]})},Yd=function(){return Vt(jd,{title:"Dashboard of a label",children:[Vt("p",{children:"This dashboard helps you understand the count of time series per label."}),Vt("p",{children:"Use the selector at the top of the page to pick a label name you\u2019d like to inspect. For the selected label name, you\u2019ll see the label values that have the highest number of series associated with them. So if you\u2019ve chosen `instance` as your label name, you may see that `657` time series have value \u201chost-1\u201d attached to them and `580` time series have value `host-2` attached to them."}),Vt("p",{children:"This can be helpful in allowing you to determine where the bulk of your time series are coming from. If the label \u201cinstance=host-1\u201d was applied to 657 series and the label \u201cinstance=host-2\u201d was only applied to 580 series, you\u2019d know, for example, that host-01 was responsible for sending the majority of the time series."})]})},Ud=function(){var e=ui().isMobile,t=v(ot(),1)[0],n=ga().setSearchParamsFromKeys,i=t.get("tips")||"",o=t.get("match")||"",u=t.get("focusLabel")||"",l=function(){var e=new bd,t=v(ot(),1)[0],n=t.get("match"),i=t.get("focusLabel"),o=+(t.get("topN")||10),u=t.get("date")||a()().tz().format(Zt),l=Ut().serverUrl,c=v((0,r.useState)(!1),2),s=c[0],f=c[1],d=v((0,r.useState)(),2),h=d[0],m=d[1],p=v((0,r.useState)(e.defaultTSDBStatus),2),g=p[0],y=p[1],_=v((0,r.useState)(!1),2),b=_[0],w=_[1],D=function(){var e=$i(ji().mark((function e(t){var n;return ji().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t);case 2:if(!(n=e.sent).ok){e.next=7;break}return e.next=6,n.json();case 6:return e.abrupt("return",e.sent);case 7:throw new Error("Request failed with status ".concat(n.status));case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),k=function(e,t){Object.keys(e).forEach((function(n){var r=n,i=e[r],a=t[r];Array.isArray(i)&&Array.isArray(a)&&i.forEach((function(e){var t,n=null===(t=a.find((function(t){return t.name===e.name})))||void 0===t?void 0:t.value;e.diff=n?e.value-n:0,e.valuePrev=n||0}))}))},x=function(){var t=$i(ji().mark((function t(r){var i,o,u,c,s,d,h,p,g,_,b,w,x,C,S,E,A,N,M,F,T,O;return ji().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(l){t.next=2;break}return t.abrupt("return");case 2:return m(""),f(!0),y(e.defaultTSDBStatus),i=st(st({},r),{},{date:r.date,topN:0,match:"",focusLabel:""}),o=st(st({},r),{},{date:a()(r.date).subtract(1,"day").tz().format(Zt)}),u=[_d(l,r),_d(l,o),_d(l,i)],t.prev=8,t.next=11,Promise.all(u.map(D));case 11:C=t.sent,S=v(C,3),E=S[0],A=S[1],N=S[2],M=st({},A.data),F=N.data,T=st(st({},E.data),{},{totalSeries:(null===(c=E.data)||void 0===c?void 0:c.totalSeries)||(null===(s=E.data)||void 0===s||null===(d=s.headStats)||void 0===d?void 0:d.numSeries)||0,totalLabelValuePairs:(null===(h=E.data)||void 0===h?void 0:h.totalLabelValuePairs)||(null===(p=E.data)||void 0===p||null===(g=p.headStats)||void 0===g?void 0:g.numLabelValuePairs)||0,seriesCountByLabelName:(null===(_=E.data)||void 0===_?void 0:_.seriesCountByLabelName)||[],seriesCountByFocusLabelValue:(null===(b=E.data)||void 0===b?void 0:b.seriesCountByFocusLabelValue)||[],totalSeriesByAll:(null===F||void 0===F?void 0:F.totalSeries)||(null===F||void 0===F||null===(w=F.headStats)||void 0===w?void 0:w.numSeries)||0,totalSeriesPrev:(null===M||void 0===M?void 0:M.totalSeries)||(null===M||void 0===M||null===(x=M.headStats)||void 0===x?void 0:x.numSeries)||0}),O=null===n||void 0===n?void 0:n.replace(/[{}"]/g,""),T.seriesCountByLabelValuePair=T.seriesCountByLabelValuePair.filter((function(e){return e.name!==O})),k(T,M),y(T),f(!1),t.next=30;break;case 26:t.prev=26,t.t0=t.catch(8),f(!1),t.t0 instanceof Error&&m("".concat(t.t0.name,": ").concat(t.t0.message));case 30:case"end":return t.stop()}}),t,null,[[8,26]])})));return function(e){return t.apply(this,arguments)}}();return(0,r.useEffect)((function(){x({topN:o,match:n,date:u,focusLabel:i})}),[l,n,i,o,u]),(0,r.useEffect)((function(){h&&(y(e.defaultTSDBStatus),f(!1))}),[h]),(0,r.useEffect)((function(){var e=bt(l);w(!!e)}),[l]),e.tsdbStatusData=g,{isLoading:s,appConfigurator:e,error:h,isCluster:b}}(),c=l.isLoading,s=l.appConfigurator,f=l.error,d=l.isCluster,h=s.tsdbStatusData,m=s.getDefaultState,p=s.tablesHeaders,g=s.sectionsTips,y=m(o,u);return Vt("div",{className:Pr()({"vm-cardinality-panel":!0,"vm-cardinality-panel_mobile":e}),children:[c&&Vt(Jf,{message:"Please wait while cardinality stats is calculated. \n This may take some time if the db contains big number of time series."}),Vt(Fd,{isPrometheus:s.isPrometheusData,totalSeries:h.totalSeries,totalSeriesPrev:h.totalSeriesPrev,totalSeriesAll:h.totalSeriesByAll,totalLabelValuePairs:h.totalLabelValuePairs,seriesCountByMetricName:h.seriesCountByMetricName,isCluster:d}),i&&Vt("div",{className:"vm-cardinality-panel-tips",children:[!o&&!u&&Vt(Hd,{}),o&&!u&&Vt(Vd,{}),!o&&!u&&Vt($d,{}),u&&Vt(Yd,{})]}),f&&Vt(ci,{variant:"error",children:f}),s.keys(o,u).map((function(e){return Vt(zd,{sectionTitle:s.sectionsTitles(u)[e],tip:g[e],rows:h[e],onActionClick:(t=e,function(e){var r={match:Sd[t]({query:e,focusLabel:u,match:o})};"labelValueCountByLabelName"!==t&&"seriesCountByLabelName"!=t||(r.focusLabel=e),"seriesCountByFocusLabelValue"==t&&(r.focusLabel=""),n(r)}),tabs:y.tabs[e],chartContainer:y.containerRefs[e],totalSeriesPrev:s.totalSeries(e,!0),totalSeries:s.totalSeries(e),tableHeaderCells:p[e],isPrometheus:s.isPrometheusData},e);var t}))]})},qd=function(e){return["topByAvgDuration","topByCount","topBySumDuration"].forEach((function(t){var n=e[t];Array.isArray(n)&&n.forEach((function(e){var t=vn(1e3*e.timeRangeSeconds);e.url=function(e,t){var n,r=e.query,i=e.timeRangeSeconds,a=["g0.expr=".concat(encodeURIComponent(r))],o=null===(n=yn.find((function(e){return e.duration===t})))||void 0===n?void 0:n.id;return o&&a.push("g0.relative_time=".concat(o)),i&&a.push("g0.range_input=".concat(t)),"".concat(pt.home,"?").concat(a.join("&"))}(e,t),e.timeRange=t}))})),e},Wd=function(e){var t=e.topN,n=e.maxLifetime,i=Ut().serverUrl,a=ga().setSearchParamsFromKeys,o=v((0,r.useState)(null),2),u=o[0],l=o[1],c=v((0,r.useState)(!1),2),s=c[0],f=c[1],d=v((0,r.useState)(),2),h=d[0],m=d[1],p=(0,r.useMemo)((function(){return function(e,t,n){return"".concat(e,"/api/v1/status/top_queries?topN=").concat(t||"","&maxLifetime=").concat(n||"")}(i,t,n)}),[i,t,n]),g=function(){var e=$i(ji().mark((function e(){var r,i;return ji().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f(!0),a({topN:t,maxLifetime:n}),e.prev=2,e.next=5,fetch(p);case 5:return r=e.sent,e.next=8,r.json();case 8:i=e.sent,l(r.ok?qd(i):null),m(String(i.error||"")),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(2),e.t0 instanceof Error&&"AbortError"!==e.t0.name&&m("".concat(e.t0.name,": ").concat(e.t0.message));case 16:f(!1);case 17:case"end":return e.stop()}}),e,null,[[2,13]])})));return function(){return e.apply(this,arguments)}}();return{data:u,error:h,loading:s,fetch:g}},Zd=function(e){var t=e.rows,n=e.columns,i=e.defaultOrderBy,a=gs(),o=v((0,r.useState)(i||"count"),2),u=o[0],l=o[1],c=v((0,r.useState)("desc"),2),s=c[0],f=c[1],d=(0,r.useMemo)((function(){return Pd(t,Ld(s,u))}),[t,u,s]),h=function(e){return function(){var t;t=e,f((function(e){return"asc"===e&&u===t?"desc":"asc"})),l(t)}},m=function(e){var t=e.query;return $i(ji().mark((function e(){return ji().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a(t,"Query has been copied");case 2:case"end":return e.stop()}}),e)})))};return Vt("table",{className:"vm-table",children:[Vt("thead",{className:"vm-table-header",children:Vt("tr",{className:"vm-table__row vm-table__row_header",children:[n.map((function(e){return Vt("th",{className:"vm-table-cell vm-table-cell_header vm-table-cell_sort",onClick:h(e.sortBy||e.key),children:Vt("div",{className:"vm-table-cell__content",children:[e.title||e.key,Vt("div",{className:Pr()({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":u===e.key,"vm-table__sort-icon_desc":"desc"===s&&u===e.key}),children:Vt(er,{})})]})},e.key)})),Vt("th",{className:"vm-table-cell vm-table-cell_header"})," "]})}),Vt("tbody",{className:"vm-table-body",children:d.map((function(e,t){return Vt("tr",{className:"vm-table__row",children:[n.map((function(t){return Vt("td",{className:"vm-table-cell",children:e[t.key]||"-"},t.key)})),Vt("td",{className:"vm-table-cell vm-table-cell_no-padding",children:Vt("div",{className:"vm-top-queries-panels__table-actions",children:[e.url&&Vt(Si,{title:"Execute query",children:Vt(nt,{to:e.url,target:"_blank",rel:"noreferrer","aria-disabled":!0,children:Vt(yi,{variant:"text",size:"small",startIcon:Vt(or,{}),ariaLabel:"execute query"})})}),Vt(Si,{title:"Copy query",children:Vt(yi,{variant:"text",size:"small",startIcon:Vt(gr,{}),onClick:m(e),ariaLabel:"copy query"})})]})})]},t)}))})]})},Qd=["table","JSON"].map((function(e,t){return{value:String(t),label:e,icon:Vt(0===t?lr:cr,{})}})),Gd=function(e){var t=e.rows,n=e.title,i=e.columns,a=e.defaultOrderBy,o=ui().isMobile,u=v((0,r.useState)(0),2),l=u[0],c=u[1];return Vt("div",{className:Pr()({"vm-top-queries-panel":!0,"vm-block":!0,"vm-block_mobile":o}),children:[Vt("div",{className:Pr()({"vm-top-queries-panel-header":!0,"vm-section-header":!0,"vm-top-queries-panel-header_mobile":o}),children:[Vt("h5",{className:Pr()({"vm-section-header__title":!0,"vm-section-header__title_mobile":o}),children:n}),Vt("div",{className:"vm-section-header__tabs",children:Vt(Vr,{activeItem:String(l),items:Qd,onChange:function(e){c(+e)}})})]}),Vt("div",{className:Pr()({"vm-top-queries-panel__table":!0,"vm-top-queries-panel__table_mobile":o}),children:[0===l&&Vt(Zd,{rows:t,columns:i,defaultOrderBy:a}),1===l&&Vt(Zf,{data:t})]})]})},Kd=function(){var e=ui().isMobile,t=v(Nd(10,"topN"),2),n=t[0],i=t[1],o=v(Nd("10m","maxLifetime"),2),u=o[0],l=o[1],c=Wd({topN:n,maxLifetime:u}),s=c.data,f=c.error,d=c.loading,h=c.fetch,m=(0,r.useMemo)((function(){var e=u.trim().split(" ").reduce((function(e,t){var n=sn(t);return n?st(st({},e),n):st({},e)}),{});return!!a().duration(e).asMilliseconds()}),[u]),p=(0,r.useMemo)((function(){return!!n&&n<1}),[n]),g=(0,r.useMemo)((function(){return p?"Number must be bigger than zero":""}),[p]),y=(0,r.useMemo)((function(){return m?"":"Invalid duration value"}),[m]),_=function(e){if(!s)return e;var t=s[e];return"number"===typeof t?Lc(t,t,t):t||e},b=function(e){"Enter"===e.key&&h()};return(0,r.useEffect)((function(){s&&(n||i(+s.topN),u||l(s.maxLifetime))}),[s]),(0,r.useEffect)((function(){return h(),window.addEventListener("popstate",h),function(){window.removeEventListener("popstate",h)}}),[]),Vt("div",{className:Pr()({"vm-top-queries":!0,"vm-top-queries_mobile":e}),children:[d&&Vt(Jf,{containerStyles:{height:"500px"}}),Vt("div",{className:Pr()({"vm-top-queries-controls":!0,"vm-block":!0,"vm-block_mobile":e}),children:[Vt("div",{className:"vm-top-queries-controls-fields",children:[Vt("div",{className:"vm-top-queries-controls-fields__item",children:Vt(Gi,{label:"Max lifetime",value:u,error:y,helperText:"For example ".concat("30ms, 15s, 3d4h, 1y2w"),onChange:function(e){l(e)},onKeyDown:b})}),Vt("div",{className:"vm-top-queries-controls-fields__item",children:Vt(Gi,{label:"Number of returned queries",type:"number",value:n||"",error:g,onChange:function(e){i(+e)},onKeyDown:b})})]}),Vt("div",{className:Pr()({"vm-top-queries-controls-bottom":!0,"vm-top-queries-controls-bottom_mobile":e}),children:[Vt("div",{className:"vm-top-queries-controls-bottom__info",children:["VictoriaMetrics tracks the last\xa0",Vt(Si,{title:"search.queryStats.lastQueriesCount",children:Vt("b",{children:_("search.queryStats.lastQueriesCount")})}),"\xa0queries with durations at least\xa0",Vt(Si,{title:"search.queryStats.minQueryDuration",children:Vt("b",{children:_("search.queryStats.minQueryDuration")})})]}),Vt("div",{className:"vm-top-queries-controls-bottom__button",children:Vt(yi,{startIcon:Vt(ar,{}),onClick:h,children:"Execute"})})]})]}),f&&Vt(ci,{variant:"error",children:f}),s&&Vt(Ht.HY,{children:Vt("div",{className:"vm-top-queries-panels",children:[Vt(Gd,{rows:s.topByCount,title:"Most frequently executed queries",columns:[{key:"query"},{key:"timeRange",sortBy:"timeRangeSeconds",title:"query time interval"},{key:"count"}]}),Vt(Gd,{rows:s.topByAvgDuration,title:"Most heavy queries",columns:[{key:"query"},{key:"avgDurationSeconds",title:"avg duration, sec"},{key:"timeRange",sortBy:"timeRangeSeconds",title:"query time interval"},{key:"count"}],defaultOrderBy:"avgDurationSeconds"}),Vt(Gd,{rows:s.topBySumDuration,title:"Queries with most summary time to execute",columns:[{key:"query"},{key:"sumDurationSeconds",title:"sum duration, sec"},{key:"timeRange",sortBy:"timeRangeSeconds",title:"query time interval"},{key:"count"}],defaultOrderBy:"sumDurationSeconds"})]})})]})},Jd={"color-primary":"#589DF6","color-secondary":"#316eca","color-error":"#e5534b","color-warning":"#c69026","color-info":"#539bf5","color-success":"#57ab5a","color-background-body":"#22272e","color-background-block":"#2d333b","color-background-tooltip":"rgba(22, 22, 22, 0.8)","color-text":"#cdd9e5","color-text-secondary":"#768390","color-text-disabled":"#636e7b","box-shadow":"rgba(0, 0, 0, 0.16) 1px 2px 6px","box-shadow-popper":"rgba(0, 0, 0, 0.2) 0px 2px 8px 0px","border-divider":"1px solid rgba(99, 110, 123, 0.5)","color-hover-black":"rgba(0, 0, 0, 0.12)"},Xd={"color-primary":"#3F51B5","color-secondary":"#E91E63","color-error":"#FD080E","color-warning":"#FF8308","color-info":"#03A9F4","color-success":"#4CAF50","color-background-body":"#FEFEFF","color-background-block":"#FFFFFF","color-background-tooltip":"rgba(80,80,80,0.9)","color-text":"#110f0f","color-text-secondary":"#706F6F","color-text-disabled":"#A09F9F","box-shadow":"rgba(0, 0, 0, 0.08) 1px 2px 6px","box-shadow-popper":"rgba(0, 0, 0, 0.1) 0px 2px 8px 0px","border-divider":"1px solid rgba(0, 0, 0, 0.15)","color-hover-black":"rgba(0, 0, 0, 0.06)"},eh=function(){var e=v((0,r.useState)(Rt()),2),t=e[0],n=e[1],i=function(e){n(e.matches)};return(0,r.useEffect)((function(){var e=window.matchMedia("(prefers-color-scheme: dark)");return e.addEventListener("change",i),function(){return e.removeEventListener("change",i)}}),[]),t},th=["primary","secondary","error","warning","info","success"],nh=function(e){var t,n=e.onLoaded,i=gt(),a=vt().palette,o=void 0===a?{}:a,u=Ut().theme,l=eh(),c=qt(),s=$r(),f=v((0,r.useState)((lt(t={},Lt.dark,Jd),lt(t,Lt.light,Xd),lt(t,Lt.system,Rt()?Jd:Xd),t)),2),d=f[0],h=f[1],m=function(){var e=window,t=e.innerWidth,n=e.innerHeight,r=document.documentElement,i=r.clientWidth,a=r.clientHeight;It("scrollbar-width","".concat(t-i,"px")),It("scrollbar-height","".concat(n-a,"px")),It("vh","".concat(.01*n,"px"))},p=function(){th.forEach((function(e,t){var r=function(e){var t=e.replace("#","").trim();if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6!==t.length)throw new Error("Invalid HEX color.");return(299*parseInt(t.slice(0,2),16)+587*parseInt(t.slice(2,4),16)+114*parseInt(t.slice(4,6),16))/1e3>=128?"#000000":"#FFFFFF"}(Pt("color-".concat(e)));It("".concat(e,"-text"),r),t===th.length-1&&(c({type:"SET_DARK_THEME"}),n(!0))}))},g=function(){var e=Ft("THEME")||Lt.system,t=d[e];Object.entries(t).forEach((function(e){var t=v(e,2),n=t[0],r=t[1];It(n,r)})),p(),i&&(th.forEach((function(e){var t=o[e];t&&It("color-".concat(e),t)})),p())};return(0,r.useEffect)((function(){m(),g()}),[d]),(0,r.useEffect)(m,[s]),(0,r.useEffect)((function(){var e=Rt()?Jd:Xd;d[Lt.system]!==e?h((function(t){return st(st({},t),{},lt({},Lt.system,e))})):g()}),[u,l]),(0,r.useEffect)((function(){i&&c({type:"SET_THEME",payload:Lt.light})}),[]),null},rh=function(){var e=v((0,r.useState)([]),2),t=e[0],n=e[1],i=v((0,r.useState)(!1),2),a=i[0],o=i[1],u=(0,r.useRef)(document.body),l=function(e){e.preventDefault(),e.stopPropagation(),"dragenter"===e.type||"dragover"===e.type?o(!0):"dragleave"===e.type&&o(!1)};return Hr("dragenter",l,u),Hr("dragleave",l,u),Hr("dragover",l,u),Hr("drop",(function(e){var t;e.preventDefault(),e.stopPropagation(),o(!1),null!==e&&void 0!==e&&null!==(t=e.dataTransfer)&&void 0!==t&&t.files&&e.dataTransfer.files[0]&&function(e){var t=Array.from(e||[]);n(t)}(e.dataTransfer.files)}),u),Hr("paste",(function(e){var t,r=null===(t=e.clipboardData)||void 0===t?void 0:t.items;if(r){var i=Array.from(r).filter((function(e){return"application/json"===e.type})).map((function(e){return e.getAsFile()})).filter((function(e){return null!==e}));n(i)}}),u),{files:t,dragging:a}},ih=function(e){var t=e.onOpenModal,n=e.onChange;return Vt("div",{className:"vm-trace-page-controls",children:[Vt(yi,{variant:"outlined",onClick:t,children:"Paste JSON"}),Vt(Si,{title:"The file must contain tracing information in JSON format",children:Vt(yi,{children:["Upload Files",Vt("input",{id:"json",type:"file",accept:"application/json",multiple:!0,title:" ",onChange:n})]})})]})},ah=function(){var e=v((0,r.useState)([]),2),t=e[0],n=e[1],i=v((0,r.useState)([]),2),a=i[0],o=i[1],u=(0,r.useMemo)((function(){return!!t.length}),[t]),l=_i(!1),c=l.value,s=l.setTrue,f=l.setFalse,d=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";o((function(n){return[{filename:t,text:": ".concat(e.message)}].concat(_(n))}))},h=function(e,t){try{var r=JSON.parse(e),i=r.trace||r;if(!i.duration_msec)return void d(new Error(Ot.traceNotFound),t);var a=new qf(i,t);n((function(e){return[a].concat(_(e))}))}catch(o){o instanceof Error&&d(o,t)}},m=function(e){e.map((function(e){var t=new FileReader,n=(null===e||void 0===e?void 0:e.name)||"";t.onload=function(e){var t,r=String(null===(t=e.target)||void 0===t?void 0:t.result);h(r,n)},t.readAsText(e)}))},p=function(e){o([]);var t=Array.from(e.target.files||[]);m(t),e.target.value=""},g=function(e){return function(){!function(e){o((function(t){return t.filter((function(t,n){return n!==e}))}))}(e)}},y=rh(),b=y.files,w=y.dragging;return(0,r.useEffect)((function(){m(b)}),[b]),Vt("div",{className:"vm-trace-page",children:[Vt("div",{className:"vm-trace-page-header",children:[Vt("div",{className:"vm-trace-page-header-errors",children:a.map((function(e,t){return Vt("div",{className:"vm-trace-page-header-errors-item",children:[Vt(ci,{variant:"error",children:[Vt("b",{className:"vm-trace-page-header-errors-item__filename",children:e.filename}),Vt("span",{children:e.text})]}),Vt(yi,{className:"vm-trace-page-header-errors-item__close",startIcon:Vt(qn,{}),variant:"text",color:"error",onClick:g(t)})]},"".concat(e,"_").concat(t))}))}),Vt("div",{children:u&&Vt(ih,{onOpenModal:s,onChange:p})})]}),u&&Vt("div",{children:Vt(nd,{jsonEditor:!0,traces:t,onDeleteClick:function(e){var r=t.filter((function(t){return t.idValue!==e.idValue}));n(_(r))}})}),!u&&Vt("div",{className:"vm-trace-page-preview",children:[Vt("p",{className:"vm-trace-page-preview__text",children:["Please, upload file with JSON response content.","\n","The file must contain tracing information in JSON format.","\n","In order to use tracing please refer to the doc:\xa0",Vt("a",{className:"vm-link vm-link_colored",href:"https://docs.victoriametrics.com/#query-tracing",target:"_blank",rel:"help noreferrer",children:"https://docs.victoriametrics.com/#query-tracing"}),"\n","Tracing graph will be displayed after file upload.","\n","Attach files by dragging & dropping, selecting or pasting them."]}),Vt(ih,{onOpenModal:s,onChange:p})]}),c&&Vt(Ci,{title:"Paste JSON",onClose:f,children:Vt(td,{editable:!0,displayTitle:!0,defaultTile:"JSON ".concat(t.length+1),onClose:f,onUpload:h})}),w&&Vt("div",{className:"vm-trace-page__dropzone"})]})},oh=function(e){var t=Ut().serverUrl,n=On().period,i=v((0,r.useState)([]),2),a=i[0],o=i[1],u=v((0,r.useState)(!1),2),l=u[0],c=u[1],s=v((0,r.useState)(),2),f=s[0],d=s[1],h=(0,r.useMemo)((function(){return function(e,t,n){var r="{job=".concat(JSON.stringify(n),"}");return"".concat(e,"/api/v1/label/instance/values?match[]=").concat(encodeURIComponent(r),"&start=").concat(t.start,"&end=").concat(t.end)}(t,n,e)}),[t,n,e]);return(0,r.useEffect)((function(){if(e){var t=function(){var e=$i(ji().mark((function e(){var t,n,r;return ji().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c(!0),e.prev=1,e.next=4,fetch(h);case 4:return t=e.sent,e.next=7,t.json();case 7:n=e.sent,r=n.data||[],o(r.sort((function(e,t){return e.localeCompare(t)}))),t.ok?d(void 0):d("".concat(n.errorType,"\r\n").concat(null===n||void 0===n?void 0:n.error)),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),e.t0 instanceof Error&&d("".concat(e.t0.name,": ").concat(e.t0.message));case 16:c(!1);case 17:case"end":return e.stop()}}),e,null,[[1,13]])})));return function(){return e.apply(this,arguments)}}();t().catch(console.error)}}),[h]),{instances:a,isLoading:l,error:f}},uh=function(e,t){var n=Ut().serverUrl,i=On().period,a=v((0,r.useState)([]),2),o=a[0],u=a[1],l=v((0,r.useState)(!1),2),c=l[0],s=l[1],f=v((0,r.useState)(),2),d=f[0],h=f[1],m=(0,r.useMemo)((function(){return function(e,t,n,r){var i=Object.entries({job:n,instance:r}).filter((function(e){return e[1]})).map((function(e){var t=v(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(JSON.stringify(r))})).join(","),a="{".concat(i,"}");return"".concat(e,"/api/v1/label/__name__/values?match[]=").concat(encodeURIComponent(a),"&start=").concat(t.start,"&end=").concat(t.end)}(n,i,e,t)}),[n,i,e,t]);return(0,r.useEffect)((function(){if(e){var t=function(){var e=$i(ji().mark((function e(){var t,n,r;return ji().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s(!0),e.prev=1,e.next=4,fetch(m);case 4:return t=e.sent,e.next=7,t.json();case 7:n=e.sent,r=n.data||[],u(r.sort((function(e,t){return e.localeCompare(t)}))),t.ok?h(void 0):h("".concat(n.errorType,"\r\n").concat(null===n||void 0===n?void 0:n.error)),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),e.t0 instanceof Error&&h("".concat(e.t0.name,": ").concat(e.t0.message));case 16:s(!1);case 17:case"end":return e.stop()}}),e,null,[[1,13]])})));return function(){return e.apply(this,arguments)}}();t().catch(console.error)}}),[m]),{names:o,isLoading:c,error:d}},lh=function(e){var t=e.name,n=e.job,i=e.instance,a=e.rateEnabled,o=e.isBucket,u=e.height,l=ui().isMobile,c=ri(),s=c.customStep,f=c.yaxis,d=On().period,h=ii(),m=Ln(),p=dn(d.end-d.start),g=fn(s),y=vn(10*g*1e3),_=v((0,r.useState)(!1),2),b=_[0],w=_[1],D=b&&s===p?y:s,k=_i(!1),x=k.value,C=k.setTrue,S=(0,r.useMemo)((function(){var e=Object.entries({job:n,instance:i}).filter((function(e){return e[1]})).map((function(e){var t=v(e,2),n=t[0],r=t[1];return"".concat(n,"=").concat(JSON.stringify(r))}));e.push("__name__=".concat(JSON.stringify(t))),"node_cpu_seconds_total"==t&&e.push('mode!="idle"');var r="{".concat(e.join(","),"}");if(o)return"sum(rate(".concat(r,")) by (vmrange, le)");var u=a?"rollup_rate(".concat(r,")"):"rollup(".concat(r,")");return"\nwith (q = ".concat(u,') (\n alias(min(label_match(q, "rollup", "min")), "min"),\n alias(max(label_match(q, "rollup", "max")), "max"),\n alias(avg(label_match(q, "rollup", "avg")), "avg"),\n)')}),[t,n,i,a,o]),E=Wf({predefinedQuery:[S],visible:!0,customStep:D,showAllSeries:x}),A=E.isLoading,N=E.graphData,M=E.error,F=E.warning,T=E.isHistogram;return(0,r.useEffect)((function(){w(T)}),[T]),Vt("div",{className:Pr()({"vm-explore-metrics-graph":!0,"vm-explore-metrics-graph_mobile":l}),children:[A&&Vt(Jf,{}),M&&Vt(ci,{variant:"error",children:M}),F&&Vt(ci,{variant:"warning",children:Vt("div",{className:"vm-explore-metrics-graph__warning",children:[Vt("p",{children:F}),Vt(yi,{color:"warning",variant:"outlined",onClick:C,children:"Show all"})]})}),N&&d&&Vt(xs,{data:N,period:d,customStep:D,query:[S],yaxis:f,setYaxisLimits:function(e){h({type:"SET_YAXIS_LIMITS",payload:e})},setPeriod:function(e){var t=e.from,n=e.to;m({type:"SET_PERIOD",payload:{from:t,to:n}})},showLegend:!1,height:u,isHistogram:T})]})},ch=function(e){var t=e.name,n=e.index,r=e.length,i=e.isBucket,a=e.rateEnabled,o=e.onChangeRate,u=e.onRemoveItem,l=e.onChangeOrder,c=ui().isMobile,s=_i(!1),f=s.value,d=s.setTrue,h=s.setFalse,m=function(){u(t)},p=function(){l(t,n,n+1)},v=function(){l(t,n,n-1)};return Vt("div",c?{className:"vm-explore-metrics-item-header vm-explore-metrics-item-header_mobile",children:[Vt("div",{className:"vm-explore-metrics-item-header__name",children:t}),Vt(yi,{variant:"text",size:"small",startIcon:Vt(xr,{}),onClick:d,ariaLabel:"open panel settings"}),f&&Vt(Ci,{title:t,onClose:h,children:Vt("div",{className:"vm-explore-metrics-item-header-modal",children:[Vt("div",{className:"vm-explore-metrics-item-header-modal-order",children:[Vt(yi,{startIcon:Vt(dr,{}),variant:"outlined",onClick:v,disabled:0===n,ariaLabel:"move graph up"}),Vt("p",{children:["position:",Vt("span",{className:"vm-explore-metrics-item-header-modal-order__index",children:["#",n+1]})]}),Vt(yi,{endIcon:Vt(fr,{}),variant:"outlined",onClick:p,disabled:n===r-1,ariaLabel:"move graph down"})]}),!i&&Vt("div",{className:"vm-explore-metrics-item-header-modal__rate",children:[Vt(Ff,{label:Vt("span",{children:["enable ",Vt("code",{children:"rate()"})]}),value:a,onChange:o,fullWidth:!0}),Vt("p",{children:"calculates the average per-second speed of metrics change"})]}),Vt(yi,{startIcon:Vt(qn,{}),color:"error",variant:"outlined",onClick:m,fullWidth:!0,children:"Remove graph"})]})})]}:{className:"vm-explore-metrics-item-header",children:[Vt("div",{className:"vm-explore-metrics-item-header-order",children:[Vt(Si,{title:"move graph up",children:Vt(yi,{className:"vm-explore-metrics-item-header-order__up",startIcon:Vt(Xn,{}),variant:"text",color:"gray",size:"small",onClick:v,ariaLabel:"move graph up"})}),Vt("div",{className:"vm-explore-metrics-item-header__index",children:["#",n+1]}),Vt(Si,{title:"move graph down",children:Vt(yi,{className:"vm-explore-metrics-item-header-order__down",startIcon:Vt(Xn,{}),variant:"text",color:"gray",size:"small",onClick:p,ariaLabel:"move graph down"})})]}),Vt("div",{className:"vm-explore-metrics-item-header__name",children:t}),!i&&Vt("div",{className:"vm-explore-metrics-item-header__rate",children:Vt(Si,{title:"calculates the average per-second speed of metric's change",children:Vt(Ff,{label:Vt("span",{children:["enable ",Vt("code",{children:"rate()"})]}),value:a,onChange:o})})}),Vt("div",{className:"vm-explore-metrics-item-header__close",children:Vt(Si,{title:"close graph",children:Vt(yi,{startIcon:Vt(qn,{}),variant:"text",color:"gray",size:"small",onClick:m,ariaLabel:"close graph"})})})]})},sh=function(e){var t=e.name,n=e.job,i=e.instance,a=e.index,o=e.length,u=e.size,l=e.onRemoveItem,c=e.onChangeOrder,s=(0,r.useMemo)((function(){return/_sum?|_total?|_count?/.test(t)}),[t]),f=(0,r.useMemo)((function(){return/_bucket?/.test(t)}),[t]),d=v((0,r.useState)(s),2),h=d[0],m=d[1],p=$r(),g=(0,r.useMemo)(u.height,[u,p]);return(0,r.useEffect)((function(){m(s)}),[n]),Vt("div",{className:"vm-explore-metrics-item vm-block vm-block_empty-padding",children:[Vt(ch,{name:t,index:a,length:o,isBucket:f,rateEnabled:h,size:u.id,onChangeRate:m,onRemoveItem:l,onChangeOrder:c}),Vt(lh,{name:t,job:n,instance:i,rateEnabled:h,isBucket:f,height:g},"".concat(t,"_").concat(n,"_").concat(i,"_").concat(h))]})},fh=function(e){var t=e.values,n=e.onRemoveItem,r=ui().isMobile;return r?Vt("span",{className:"vm-select-input-content__counter",children:["selected ",t.length]}):Vt(Ht.HY,{children:t.map((function(e){return Vt("div",{className:"vm-select-input-content__selected",children:[Vt("span",{children:e}),Vt("div",{onClick:(t=e,function(e){n(t),e.stopPropagation()}),children:Vt(qn,{})})]},e);var t}))})},dh=function(e){var t=e.value,n=e.list,i=e.label,a=e.placeholder,o=e.noOptionsText,u=e.clearable,l=void 0!==u&&u,c=e.searchable,s=void 0!==c&&c,f=e.autofocus,d=e.onChange,h=Ut().isDarkTheme,m=ui().isMobile,p=v((0,r.useState)(""),2),g=p[0],y=p[1],_=(0,r.useRef)(null),b=v((0,r.useState)(!1),2),w=b[0],D=b[1],k=(0,r.useRef)(null),x=Array.isArray(t),C=Array.isArray(t)?t:void 0,S=m&&x&&!(null===C||void 0===C||!C.length),E=(0,r.useMemo)((function(){return w?g:Array.isArray(t)?"":t}),[t,g,w,x]),A=(0,r.useMemo)((function(){return w?g||"(.+)":""}),[g,w]),N=function(){k.current&&k.current.blur()},M=function(e){d(e),x||(D(!1),N()),x&&k.current&&k.current.focus()};return(0,r.useEffect)((function(){y(""),w&&k.current&&k.current.focus(),w||N()}),[w,k]),(0,r.useEffect)((function(){f&&k.current&&!m&&k.current.focus()}),[f,k]),Hr("keyup",(function(e){k.current!==e.target&&D(!1)})),Vt("div",{className:Pr()({"vm-select":!0,"vm-select_dark":h}),children:[Vt("div",{className:"vm-select-input",onClick:function(e){e.target instanceof HTMLInputElement||D((function(e){return!e}))},ref:_,children:[Vt("div",{className:"vm-select-input-content",children:[!(null===C||void 0===C||!C.length)&&Vt(fh,{values:C,onRemoveItem:M}),!S&&Vt("input",{value:E,type:"text",placeholder:a,onInput:function(e){y(e.target.value)},onFocus:function(){D(!0)},ref:k,readOnly:m||!s})]}),i&&Vt("span",{className:"vm-text-field__label",children:i}),l&&t&&Vt("div",{className:"vm-select-input__icon",onClick:function(e){return function(t){M(e),t.stopPropagation()}}(""),children:Vt(qn,{})}),Vt("div",{className:Pr()({"vm-select-input__icon":!0,"vm-select-input__icon_open":w}),children:Vt(er,{})})]}),Vt(Ss,{label:i,value:A,options:n.map((function(e){return{value:e}})),anchor:_,selected:C,minLength:1,fullWidth:!0,noOptionsText:o,onSelect:M,onOpenAutocomplete:D})]})},hh=Et.map((function(e){return e.id})),mh=function(e){var t=e.jobs,n=e.instances,i=e.names,a=e.job,o=e.instance,u=e.size,l=e.selectedMetrics,c=e.onChangeJob,s=e.onChangeInstance,f=e.onToggleMetric,d=e.onChangeSize,h=(0,r.useMemo)((function(){return a?"":"No instances. Please select job"}),[a]),m=(0,r.useMemo)((function(){return a?"":"No metric names. Please select job"}),[a]),p=ui().isMobile,v=_i("false"!==Ft("EXPLORE_METRICS_TIPS")),g=v.value,y=v.toggle,_=v.setFalse;return(0,r.useEffect)((function(){Mt("EXPLORE_METRICS_TIPS","".concat(g))}),[g]),Vt(Ht.HY,{children:[Vt("div",{className:Pr()({"vm-explore-metrics-header":!0,"vm-explore-metrics-header_mobile":p,"vm-block":!0,"vm-block_mobile":p}),children:[Vt("div",{className:"vm-explore-metrics-header__job",children:Vt(dh,{value:a,list:t,label:"Job",placeholder:"Please select job",onChange:c,autofocus:!a,searchable:!0})}),Vt("div",{className:"vm-explore-metrics-header__instance",children:Vt(dh,{value:o,list:n,label:"Instance",placeholder:"Please select instance",onChange:s,noOptionsText:h,clearable:!0,searchable:!0})}),Vt("div",{className:"vm-explore-metrics-header__size",children:[Vt(dh,{label:"Size graphs",value:u,list:hh,onChange:d}),Vt(Si,{title:"".concat(g?"Hide":"Show"," tip"),children:Vt(yi,{variant:"text",color:g?"warning":"gray",startIcon:Vt(Sr,{}),onClick:y,ariaLabel:"visibility tips"})})]}),Vt("div",{className:"vm-explore-metrics-header-metrics",children:Vt(dh,{label:"Metrics",value:l,list:i,placeholder:"Search metric name",onChange:f,noOptionsText:m,clearable:!0,searchable:!0})})]}),g&&Vt(ci,{variant:"warning",children:Vt("div",{className:"vm-explore-metrics-header-description",children:[Vt("p",{children:["Please note: this page is solely designed for exploring Prometheus metrics. Prometheus metrics always contain ",Vt("code",{children:"job"})," and ",Vt("code",{children:"instance"})," labels (see ",Vt("a",{className:"vm-link vm-link_colored",href:"https://prometheus.io/docs/concepts/jobs_instances/",children:"these docs"}),"), and this page relies on them as filters. ",Vt("br",{}),"Please use this page for Prometheus metrics only, in accordance with their naming conventions."]}),Vt(yi,{variant:"text",size:"small",startIcon:Vt(qn,{}),onClick:_,ariaLabel:"close tips"})]})})]})},ph=Nt("job",""),vh=Nt("instance",""),gh=Nt("metrics",""),yh=Nt("size",""),_h=Et.find((function(e){return yh?e.id===yh:e.isDefault}))||Et[0],bh=function(){var e=v((0,r.useState)(ph),2),t=e[0],n=e[1],i=v((0,r.useState)(vh),2),a=i[0],o=i[1],u=v((0,r.useState)(gh?gh.split("&"):[]),2),l=u[0],c=u[1],s=v((0,r.useState)(_h),2),f=s[0],d=s[1];!function(e){var t=e.job,n=e.instance,i=e.metrics,a=e.size,o=On(),u=o.duration,l=o.relativeTime,c=o.period.date,s=ri().customStep,f=ga().setSearchParamsFromKeys,d=function(){var e,r=od((lt(e={},"g0.range_input",u),lt(e,"g0.end_input",c),lt(e,"g0.step_input",s),lt(e,"g0.relative_time",l),lt(e,"size",a),lt(e,"job",t),lt(e,"instance",n),lt(e,"metrics",i),e));f(r)};(0,r.useEffect)(d,[u,l,c,s,t,n,i,a]),(0,r.useEffect)(d,[])}({job:t,instance:a,metrics:l.join("&"),size:f.id});var h=function(){var e=Ut().serverUrl,t=On().period,n=v((0,r.useState)([]),2),i=n[0],a=n[1],o=v((0,r.useState)(!1),2),u=o[0],l=o[1],c=v((0,r.useState)(),2),s=c[0],f=c[1],d=(0,r.useMemo)((function(){return function(e,t){return"".concat(e,"/api/v1/label/job/values?start=").concat(t.start,"&end=").concat(t.end)}(e,t)}),[e,t]);return(0,r.useEffect)((function(){var e=function(){var e=$i(ji().mark((function e(){var t,n,r;return ji().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l(!0),e.prev=1,e.next=4,fetch(d);case 4:return t=e.sent,e.next=7,t.json();case 7:n=e.sent,r=n.data||[],a(r.sort((function(e,t){return e.localeCompare(t)}))),t.ok?f(void 0):f("".concat(n.errorType,"\r\n").concat(null===n||void 0===n?void 0:n.error)),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),e.t0 instanceof Error&&f("".concat(e.t0.name,": ").concat(e.t0.message));case 16:l(!1);case 17:case"end":return e.stop()}}),e,null,[[1,13]])})));return function(){return e.apply(this,arguments)}}();e().catch(console.error)}),[d]),{jobs:i,isLoading:u,error:s}}(),m=h.jobs,p=h.isLoading,g=h.error,y=oh(t),b=y.instances,w=y.isLoading,D=y.error,k=uh(t,a),x=k.names,C=k.isLoading,S=k.error,E=(0,r.useMemo)((function(){return p||w||C}),[p,w,C]),A=(0,r.useMemo)((function(){return g||D||S}),[g,D,S]),N=function(e){c(e?function(t){return t.includes(e)?t.filter((function(t){return t!==e})):[].concat(_(t),[e])}:[])},M=function(e,t,n){var r=n>l.length-1;n<0||r||c((function(e){var r=_(e),i=v(r.splice(t,1),1)[0];return r.splice(n,0,i),r}))};return(0,r.useEffect)((function(){a&&b.length&&!b.includes(a)&&o("")}),[b,a]),Vt("div",{className:"vm-explore-metrics",children:[Vt(mh,{jobs:m,instances:b,names:x,job:t,size:f.id,instance:a,selectedMetrics:l,onChangeJob:n,onChangeSize:function(e){var t=Et.find((function(t){return t.id===e}));t&&d(t)},onChangeInstance:o,onToggleMetric:N}),E&&Vt(Jf,{}),A&&Vt(ci,{variant:"error",children:A}),!t&&Vt(ci,{variant:"info",children:"Please select job to see list of metric names."}),t&&!l.length&&Vt(ci,{variant:"info",children:"Please select metric names to see the graphs."}),Vt("div",{className:"vm-explore-metrics-body",children:l.map((function(e,n){return Vt(sh,{name:e,job:t,instance:a,index:n,length:l.length,size:f,onRemoveItem:N,onChangeOrder:M},e)}))})]})},wh=function(){var t=gs();return Vt("div",{className:"vm-preview-icons",children:Object.entries(e).map((function(e){var n,r=v(e,2),i=r[0],a=r[1];return Vt("div",{className:"vm-preview-icons-item",onClick:(n=i,$i(ji().mark((function e(){return ji().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t("<".concat(n,"/>"),"<".concat(n,"/> has been copied"));case 2:case"end":return e.stop()}}),e)})))),children:[Vt("div",{className:"vm-preview-icons-item__svg",children:a()}),Vt("div",{className:"vm-preview-icons-item__name",children:"<".concat(i,"/>")})]},i)}))})},Dh=function(e){return e.copy="Copy",e.copied="Copied",e}(Dh||{}),kh=function(e){var t=e.code,n=v((0,r.useState)(Dh.copy),2),i=n[0],a=n[1];return(0,r.useEffect)((function(){var e=null;return i===Dh.copied&&(e=setTimeout((function(){return a(Dh.copy)}),1e3)),function(){e&&clearTimeout(e)}}),[i]),Vt("code",{className:"vm-code-example",children:[t,Vt("div",{className:"vm-code-example__copy",children:Vt(Si,{title:i,children:Vt(yi,{size:"small",variant:"text",onClick:function(){navigator.clipboard.writeText(t),a(Dh.copied)},startIcon:Vt(gr,{}),ariaLabel:"close"})})})]})},xh=function(){return Vt("a",{className:"vm-link vm-link_colored",href:"https://docs.victoriametrics.com/MetricsQL.html",target:"_blank",rel:"help noreferrer",children:"MetricsQL"})},Ch=function(){return Vt("a",{className:"vm-link vm-link_colored",href:"https://grafana.com/grafana/dashboards/1860-node-exporter-full/",target:"_blank",rel:"help noreferrer",children:"Node Exporter Full"})},Sh=function(){return Vt("section",{className:"vm-with-template-tutorial",children:[Vt("h2",{className:"vm-with-template-tutorial__title",children:["Tutorial for WITH expressions in ",Vt(xh,{})]}),Vt("div",{className:"vm-with-template-tutorial-section",children:[Vt("p",{className:"vm-with-template-tutorial-section__text",children:["Let's look at the following real query from ",Vt(Ch,{})," dashboard:"]}),Vt(kh,{code:'(\n (\n node_memory_MemTotal_bytes{instance=~"$node:$port", job=~"$job"}\n -\n node_memory_MemFree_bytes{instance=~"$node:$port", job=~"$job"}\n )\n /\n node_memory_MemTotal_bytes{instance=~"$node:$port", job=~"$job"}\n) * 100'}),Vt("p",{className:"vm-with-template-tutorial-section__text",children:"It is clear the query calculates the percentage of used memory for the given $node, $port and $job. Isn't it? :)"})]}),Vt("div",{className:"vm-with-template-tutorial-section",children:[Vt("p",{className:"vm-with-template-tutorial-section__text",children:"What's wrong with this query? Copy-pasted label filters for distinct timeseries which makes it easy to mistype these filters during modification. Let's simplify the query with WITH expressions:"}),Vt(kh,{code:'WITH (\n commonFilters = {instance=~"$node:$port",job=~"$job"}\n)\n(\n node_memory_MemTotal_bytes{commonFilters}\n -\n node_memory_MemFree_bytes{commonFilters}\n)\n /\nnode_memory_MemTotal_bytes{commonFilters} * 100'})]}),Vt("div",{className:"vm-with-template-tutorial-section",children:[Vt("p",{className:"vm-with-template-tutorial-section__text",children:["Now label filters are located in a single place instead of three distinct places. The query mentions node_memory_MemTotal_bytes metric twice and ","{commonFilters}"," three times. WITH expressions may improve this:"]}),Vt(kh,{code:'WITH (\n my_resource_utilization(free, limit, filters) = (limit{filters} - free{filters}) / limit{filters} * 100\n)\nmy_resource_utilization(\n node_memory_MemFree_bytes,\n node_memory_MemTotal_bytes,\n {instance=~"$node:$port",job=~"$job"},\n)'}),Vt("p",{className:"vm-with-template-tutorial-section__text",children:"Now the template function my_resource_utilization() may be used for monitoring arbitrary resources - memory, CPU, network, storage, you name it."})]}),Vt("div",{className:"vm-with-template-tutorial-section",children:[Vt("p",{className:"vm-with-template-tutorial-section__text",children:["Let's take another nice query from ",Vt(Ch,{})," dashboard:"]}),Vt(kh,{code:'(\n (\n (\n count(\n count(node_cpu_seconds_total{instance=~"$node:$port",job=~"$job"}) by (cpu)\n )\n )\n -\n avg(\n sum by (mode) (rate(node_cpu_seconds_total{mode=\'idle\',instance=~"$node:$port",job=~"$job"}[5m]))\n )\n )\n *\n 100\n)\n /\ncount(\n count(node_cpu_seconds_total{instance=~"$node:$port",job=~"$job"}) by (cpu)\n)'}),Vt("p",{className:"vm-with-template-tutorial-section__text",children:"Do you understand what does this mess do? Is it manageable? :) WITH expressions are happy to help in a few iterations."})]}),Vt("div",{className:"vm-with-template-tutorial-section",children:[Vt("p",{className:"vm-with-template-tutorial-section__text",children:"1. Extract common filters used in multiple places into a commonFilters variable:"}),Vt(kh,{code:'WITH (\n commonFilters = {instance=~"$node:$port",job=~"$job"}\n)\n(\n (\n (\n count(\n count(node_cpu_seconds_total{commonFilters}) by (cpu)\n )\n )\n -\n avg(\n sum by (mode) (rate(node_cpu_seconds_total{mode=\'idle\',commonFilters}[5m]))\n )\n )\n *\n 100\n)\n /\ncount(\n count(node_cpu_seconds_total{commonFilters}) by (cpu)\n)'})]}),Vt("div",{className:"vm-with-template-tutorial-section",children:[Vt("p",{className:"vm-with-template-tutorial-section__text",children:'2. Extract "count(count(...) by (cpu))" into cpuCount variable:'}),Vt(kh,{code:'WITH (\n commonFilters = {instance=~"$node:$port",job=~"$job"},\n cpuCount = count(count(node_cpu_seconds_total{commonFilters}) by (cpu))\n)\n(\n (\n cpuCount\n -\n avg(\n sum by (mode) (rate(node_cpu_seconds_total{mode=\'idle\',commonFilters}[5m]))\n )\n )\n *\n 100\n) / cpuCount'})]}),Vt("div",{className:"vm-with-template-tutorial-section",children:[Vt("p",{className:"vm-with-template-tutorial-section__text",children:"3. Extract rate(...) part into cpuIdle variable, since it is clear now that this part calculates the number of idle CPUs:"}),Vt(kh,{code:'WITH (\n commonFilters = {instance=~"$node:$port",job=~"$job"},\n cpuCount = count(count(node_cpu_seconds_total{commonFilters}) by (cpu)),\n cpuIdle = sum(rate(node_cpu_seconds_total{mode=\'idle\',commonFilters}[5m]))\n)\n((cpuCount - cpuIdle) * 100) / cpuCount'})]}),Vt("div",{className:"vm-with-template-tutorial-section",children:[Vt("p",{className:"vm-with-template-tutorial-section__text",children:["4. Put node_cpu_seconds_total","{commonFilters}"," into its own varialbe with the name cpuSeconds:"]}),Vt(kh,{code:'WITH (\n cpuSeconds = node_cpu_seconds_total{instance=~"$node:$port",job=~"$job"},\n cpuCount = count(count(cpuSeconds) by (cpu)),\n cpuIdle = sum(rate(cpuSeconds{mode=\'idle\'}[5m]))\n)\n((cpuCount - cpuIdle) * 100) / cpuCount'}),Vt("p",{className:"vm-with-template-tutorial-section__text",children:"Now the query became more clear comparing to the initial query."})]}),Vt("div",{className:"vm-with-template-tutorial-section",children:[Vt("p",{className:"vm-with-template-tutorial-section__text",children:"WITH expressions may be nested and may be put anywhere. Try expanding the following query:"}),Vt(kh,{code:"WITH (\n f(a, b) = WITH (\n f1(x) = b-x,\n f2(x) = x+x\n ) f1(a)*f2(b)\n) f(foo, with(x=bar) x)"})]})]})},Eh=function(e,t){return"".concat(e,"/expand-with-exprs?query=").concat(encodeURIComponent(t),"&format=json")},Ah=function(){var e=v(ot(),1)[0],t=function(){var e=Ut().serverUrl,t=v(ot(),2),n=t[0],i=t[1],a=v((0,r.useState)(""),2),o=a[0],u=a[1],l=v((0,r.useState)(!1),2),c=l[0],s=l[1],f=v((0,r.useState)(),2),d=f[0],h=f[1],m=function(){var t=$i(ji().mark((function t(r){var a,o,l;return ji().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n.set("expr",r),i(n),a=Eh(e,r),s(!0),t.prev=4,t.next=7,fetch(a);case 7:return o=t.sent,t.next=10,o.json();case 10:l=t.sent,u((null===l||void 0===l?void 0:l.expr)||""),h(String(l.error||"")),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(4),t.t0 instanceof Error&&"AbortError"!==t.t0.name&&h("".concat(t.t0.name,": ").concat(t.t0.message));case 18:s(!1);case 19:case"end":return t.stop()}}),t,null,[[4,15]])})));return function(e){return t.apply(this,arguments)}}();return{data:o,error:d,loading:c,expand:m}}(),n=t.data,i=t.loading,a=t.error,o=t.expand,u=v((0,r.useState)(e.get("expr")||""),2),l=u[0],c=u[1],s=function(){o(l)};return(0,r.useEffect)((function(){l&&o(l)}),[]),Vt("section",{className:"vm-with-template",children:[i&&Vt(Jf,{}),Vt("div",{className:"vm-with-template-body vm-block",children:[Vt("div",{className:"vm-with-template-body__expr",children:Vt(Gi,{type:"textarea",label:"MetricsQL query with optional WITH expressions",value:l,error:a,autofocus:!0,onEnter:s,onChange:function(e){c(e)}})}),Vt("div",{className:"vm-with-template-body__result",children:Vt(Gi,{type:"textarea",label:"MetricsQL query after expanding WITH expressions and applying other optimizations",value:n,disabled:!0})}),Vt("div",{className:"vm-with-template-body-top",children:Vt(yi,{variant:"contained",onClick:s,startIcon:Vt(ar,{}),children:"Expand"})})]}),Vt("div",{className:"vm-block",children:Vt(Sh,{})})]})},Nh=function(e,t,n){var r=["format=json","relabel_configs=".concat(encodeURIComponent(t)),"metric=".concat(encodeURIComponent(n))];return"".concat(e,"/metric-relabel-debug?").concat(r.join("&"))},Mh='- if: \'{bar_label=~"b.*"}\'\n source_labels: [foo_label, bar_label]\n separator: "_"\n target_label: foobar\n- action: labeldrop\n regex: "foo_.*"\n- target_label: job\n replacement: "my-application-2"',Fh='{__name__="my_metric", bar_label="bar", foo_label="foo", job="my-application", instance="192.168.0.1"}',Th=function(){var e=v(ot(),2),t=e[0],n=e[1],i=function(){var e=Ut().serverUrl,t=v((0,r.useState)(null),2),n=t[0],i=t[1],a=v((0,r.useState)(!1),2),o=a[0],u=a[1],l=v((0,r.useState)(),2),c=l[0],s=l[1],f=function(){var t=$i(ji().mark((function t(n,r){var a,o,l;return ji().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=Nh(e,n,r),u(!0),t.prev=2,t.next=5,fetch(a);case 5:return o=t.sent,t.next=8,o.json();case 8:l=t.sent,i(l.error?null:l),s(String(l.error||"")),t.next=16;break;case 13:t.prev=13,t.t0=t.catch(2),t.t0 instanceof Error&&"AbortError"!==t.t0.name&&s("".concat(t.t0.name,": ").concat(t.t0.message));case 16:u(!1);case 17:case"end":return t.stop()}}),t,null,[[2,13]])})));return function(e,n){return t.apply(this,arguments)}}();return{data:n,error:c,loading:o,fetchData:f}}(),a=i.data,o=i.loading,u=i.error,l=i.fetchData,c=v(Nd("","config"),2),s=c[0],f=c[1],d=v(Nd("","labels"),2),h=d[0],m=d[1],p=(0,r.useCallback)((function(){l(s,h),t.set("config",s),t.set("labels",h),n(t)}),[s,h]);return(0,r.useEffect)((function(){var e=t.get("config")||"",n=t.get("labels")||"";(n||e)&&(l(e,n),f(e),m(n))}),[]),Vt("section",{className:"vm-relabeling",children:[o&&Vt(Jf,{}),Vt("div",{className:"vm-relabeling-header vm-block",children:[Vt("div",{className:"vm-relabeling-header-configs",children:Vt(Gi,{type:"textarea",label:"Relabel configs",value:s,autofocus:!0,onChange:function(e){f(e||"")},onEnter:p})}),Vt("div",{className:"vm-relabeling-header__labels",children:Vt(Gi,{type:"textarea",label:"Labels",value:h,onChange:function(e){m(e||"")},onEnter:p})}),Vt("div",{className:"vm-relabeling-header-bottom",children:[Vt("a",{className:"vm-link vm-link_with-icon",target:"_blank",href:"https://docs.victoriametrics.com/relabeling.html",rel:"help noreferrer",children:[Vt(Zn,{}),"Relabeling cookbook"]}),Vt("a",{className:"vm-link vm-link_with-icon",target:"_blank",href:"https://docs.victoriametrics.com/vmagent.html#relabeling",rel:"help noreferrer",children:[Vt(br,{}),"Documentation"]}),Vt(yi,{variant:"text",onClick:function(){var e=Mh,r=Fh;f(e),m(r),l(e,r),t.set("config",e),t.set("labels",r),n(t)},children:"Try example"}),Vt(yi,{variant:"contained",onClick:p,startIcon:Vt(ar,{}),children:"Submit"})]})]}),u&&Vt(ci,{variant:"error",children:u}),a&&Vt("div",{className:"vm-relabeling-steps vm-block",children:[a.originalLabels&&Vt("div",{className:"vm-relabeling-steps-item",children:Vt("div",{className:"vm-relabeling-steps-item__row",children:[Vt("span",{children:"Original labels:"}),Vt("code",{dangerouslySetInnerHTML:{__html:a.originalLabels}})]})}),a.steps.map((function(e,t){return Vt("div",{className:"vm-relabeling-steps-item",children:[Vt("div",{className:"vm-relabeling-steps-item__row",children:[Vt("span",{children:"Step:"}),t+1]}),Vt("div",{className:"vm-relabeling-steps-item__row",children:[Vt("span",{children:"Relabeling Rule:"}),Vt("code",{children:Vt("pre",{children:e.rule})})]}),Vt("div",{className:"vm-relabeling-steps-item__row",children:[Vt("span",{children:"Input Labels:"}),Vt("code",{children:Vt("pre",{dangerouslySetInnerHTML:{__html:e.inLabels}})})]}),Vt("div",{className:"vm-relabeling-steps-item__row",children:[Vt("span",{children:"Output labels:"}),Vt("code",{children:Vt("pre",{dangerouslySetInnerHTML:{__html:e.outLabels}})})]})]},t)})),a.resultingLabels&&Vt("div",{className:"vm-relabeling-steps-item",children:Vt("div",{className:"vm-relabeling-steps-item__row",children:[Vt("span",{children:"Resulting labels:"}),Vt("code",{dangerouslySetInnerHTML:{__html:a.resultingLabels}})]})})]})]})},Oh=function(e){var t=e.rows,n=e.columns,i=e.defaultOrderBy,a=e.copyToClipboard,o=e.paginationOffset,u=v((0,r.useState)(i),2),l=u[0],c=u[1],s=v((0,r.useState)("desc"),2),f=s[0],d=s[1],h=v((0,r.useState)(null),2),m=h[0],p=h[1],g=(0,r.useMemo)((function(){var e=o.startIndex,n=o.endIndex;return Pd(t,Ld(f,l)).slice(e,n)}),[t,l,f,o]),y=function(e,t){return $i(ji().mark((function n(){return ji().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(m!==t){n.next=2;break}return n.abrupt("return");case 2:return n.prev=2,n.next=5,navigator.clipboard.writeText(String(e));case 5:p(t),n.next=11;break;case 8:n.prev=8,n.t0=n.catch(2),console.error(n.t0);case 11:case"end":return n.stop()}}),n,null,[[2,8]])})))};return(0,r.useEffect)((function(){if(null!==m){var e=setTimeout((function(){return p(null)}),2e3);return function(){return clearTimeout(e)}}}),[m]),Vt("table",{className:"vm-table",children:[Vt("thead",{className:"vm-table-header",children:Vt("tr",{className:"vm-table__row vm-table__row_header",children:[n.map((function(e){return Vt("th",{className:"vm-table-cell vm-table-cell_header vm-table-cell_sort",onClick:(t=e.key,function(){d((function(e){return"asc"===e&&l===t?"desc":"asc"})),c(t)}),children:Vt("div",{className:"vm-table-cell__content",children:[Vt("div",{children:String(e.title||e.key)}),Vt("div",{className:Pr()({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":l===e.key,"vm-table__sort-icon_desc":"desc"===f&&l===e.key}),children:Vt(er,{})})]})},String(e.key));var t})),a&&Vt("th",{className:"vm-table-cell vm-table-cell_header"})]})}),Vt("tbody",{className:"vm-table-body",children:g.map((function(e,t){return Vt("tr",{className:"vm-table__row",children:[n.map((function(t){return Vt("td",{className:Pr()(lt({"vm-table-cell":!0},"".concat(t.className),t.className)),children:e[t.key]||"-"},String(t.key))})),a&&Vt("td",{className:"vm-table-cell vm-table-cell_right",children:e[a]&&Vt("div",{className:"vm-table-cell__content",children:Vt(Si,{title:m===t?"Copied":"Copy row",children:Vt(yi,{variant:"text",color:m===t?"success":"gray",size:"small",startIcon:Vt(m===t?hr:gr,{}),onClick:y(e[a],t),ariaLabel:"copy row"})})})})]},t)}))})]})},Lh=function(){var e=ui().isMobile,t=On().timezone,n=function(){var e=Ut().serverUrl,t=v((0,r.useState)([]),2),n=t[0],i=t[1],o=v((0,r.useState)(a()().format(Gt)),2),u=o[0],l=o[1],c=v((0,r.useState)(!1),2),s=c[0],f=c[1],d=v((0,r.useState)(),2),h=d[0],m=d[1],p=(0,r.useMemo)((function(){return"".concat(e,"/api/v1/status/active_queries")}),[e]),g=function(){var e=$i(ji().mark((function e(){var t,n;return ji().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f(!0),e.prev=1,e.next=4,fetch(p);case 4:return t=e.sent,e.next=7,t.json();case 7:n=e.sent,i(n.data),l(a()().format("HH:mm:ss:SSS")),t.ok?m(void 0):m("".concat(n.errorType,"\r\n").concat(null===n||void 0===n?void 0:n.error)),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),e.t0 instanceof Error&&m("".concat(e.t0.name,": ").concat(e.t0.message));case 16:f(!1);case 17:case"end":return e.stop()}}),e,null,[[1,13]])})));return function(){return e.apply(this,arguments)}}();return(0,r.useEffect)((function(){g().catch(console.error)}),[p]),{data:n,lastUpdated:u,isLoading:s,error:h,fetchData:g}}(),i=n.data,o=n.lastUpdated,u=n.isLoading,l=n.error,c=n.fetchData,s=(0,r.useMemo)((function(){return i.map((function(e){var t=a()(e.start).tz().format(Qt),n=a()(e.end).tz().format(Qt);return{duration:e.duration,remote_addr:e.remote_addr,query:e.query,args:"".concat(t," to ").concat(n,", step=").concat(cn(e.step)),data:JSON.stringify(e,null,2)}}))}),[i,t]),f=(0,r.useMemo)((function(){if(null===s||void 0===s||!s.length)return[];var e=Object.keys(s[0]),t={remote_addr:"client address"},n=["data"];return e.filter((function(e){return!n.includes(e)})).map((function(e){return{key:e,title:t[e]||e}}))}),[s]),d=function(){var e=$i(ji().mark((function e(){return ji().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:c().catch(console.error);case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return Vt("div",{className:"vm-active-queries",children:[u&&Vt(Jf,{}),Vt("div",{className:"vm-active-queries-header",children:[!s.length&&!l&&Vt(ci,{variant:"info",children:"There are currently no active queries running"}),l&&Vt(ci,{variant:"error",children:l}),Vt("div",{className:"vm-active-queries-header-controls",children:[Vt(yi,{variant:"contained",onClick:d,startIcon:Vt(Jn,{}),children:"Update"}),Vt("div",{className:"vm-active-queries-header__update-msg",children:["Last updated: ",o]})]})]}),!!s.length&&Vt("div",{className:Pr()({"vm-block":!0,"vm-block_mobile":e}),children:Vt(Oh,{rows:s,columns:f,defaultOrderBy:"duration",copyToClipboard:"data",paginationOffset:{startIndex:0,endIndex:1/0}})})]})},Ph=function(){var e=v((0,r.useState)(!1),2),t=e[0],n=e[1];return Vt(Ht.HY,{children:Vt(Xe,{children:Vt(pi,{children:Vt(Ht.HY,{children:[Vt(nh,{onLoaded:n}),t&&Vt(Ye,{children:Vt($e,{path:"/",element:Vt(Oa,{}),children:[Vt($e,{path:pt.home,element:Vt(pd,{})}),Vt($e,{path:pt.metrics,element:Vt(bh,{})}),Vt($e,{path:pt.cardinality,element:Vt(Ud,{})}),Vt($e,{path:pt.topQueries,element:Vt(Kd,{})}),Vt($e,{path:pt.trace,element:Vt(ah,{})}),Vt($e,{path:pt.dashboards,element:Vt(yd,{})}),Vt($e,{path:pt.withTemplate,element:Vt(Ah,{})}),Vt($e,{path:pt.relabel,element:Vt(Th,{})}),Vt($e,{path:pt.activeQueries,element:Vt(Lh,{})}),Vt($e,{path:pt.icons,element:Vt(wh,{})})]})})]})})})})},Ih=function(e){e&&n.e(522).then(n.bind(n,522)).then((function(t){var n=t.getCLS,r=t.getFID,i=t.getFCP,a=t.getLCP,o=t.getTTFB;n(e),r(e),i(e),a(e),o(e)}))},Rh=document.getElementById("root");Rh&&(0,r.render)(Vt(Ph,{}),Rh),Ih()}()}();
\ No newline at end of file
diff --git a/app/vmselect/vmui/static/js/main.dbf8fb4f.js.LICENSE.txt b/app/vmselect/vmui/static/js/main.70434a4f.js.LICENSE.txt
similarity index 100%
rename from app/vmselect/vmui/static/js/main.dbf8fb4f.js.LICENSE.txt
rename to app/vmselect/vmui/static/js/main.70434a4f.js.LICENSE.txt
diff --git a/app/vmselect/vmui/static/js/main.dbf8fb4f.js b/app/vmselect/vmui/static/js/main.dbf8fb4f.js
deleted file mode 100644
index 34cf1a4eb..000000000
--- a/app/vmselect/vmui/static/js/main.dbf8fb4f.js
+++ /dev/null
@@ -1,2 +0,0 @@
-/*! For license information please see main.dbf8fb4f.js.LICENSE.txt */
-!function(){var e={680:function(e,t,n){"use strict";var r=n(476),i=n(962),a=i(r("String.prototype.indexOf"));e.exports=function(e,t){var n=r(e,!!t);return"function"===typeof n&&a(e,".prototype.")>-1?i(n):n}},962:function(e,t,n){"use strict";var r=n(199),i=n(476),a=i("%Function.prototype.apply%"),o=i("%Function.prototype.call%"),u=i("%Reflect.apply%",!0)||r.call(o,a),l=i("%Object.getOwnPropertyDescriptor%",!0),c=i("%Object.defineProperty%",!0),s=i("%Math.max%");if(c)try{c({},"a",{value:1})}catch(d){c=null}e.exports=function(e){var t=u(r,o,arguments);l&&c&&(l(t,"length").configurable&&c(t,"length",{value:1+s(0,e.length-(arguments.length-1))}));return t};var f=function(){return u(r,a,arguments)};c?c(e.exports,"apply",{value:f}):e.exports.apply=f},123:function(e,t){var n;!function(){"use strict";var r={}.hasOwnProperty;function i(){for(var e=[],t=0;t=t?e:""+Array(t+1-r.length).join(n)+e},y={s:g,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?"+":"-")+g(r,2,"0")+":"+g(i,2,"0")},m:function e(t,n){if(t.date()1)return e(o[0])}else{var u=t.name;b[u]=t,i=u}return!r&&i&&(_=i),i||!r&&_},k=function(e,t){if(w(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new C(n)},x=y;x.l=D,x.i=w,x.w=function(e,t){return k(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var C=function(){function v(e){this.$L=D(e.locale,null,!0),this.parse(e)}var g=v.prototype;return g.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(x.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(m);if(r){var i=r[2]-1||0,a=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.$x=e.x||{},this.init()},g.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},g.$utils=function(){return x},g.isValid=function(){return!(this.$d.toString()===h)},g.isSame=function(e,t){var n=k(e);return this.startOf(t)<=n&&n<=this.endOf(t)},g.isAfter=function(e,t){return k(e)=0&&(a[f]=parseInt(s,10))}var d=a[3],h=24===d?0:d,m=a[0]+"-"+a[1]+"-"+a[2]+" "+h+":"+a[4]+":"+a[5]+":000",p=+t;return(i.utc(m).valueOf()-(p-=p%1e3))/6e4},l=r.prototype;l.tz=function(e,t){void 0===e&&(e=a);var n=this.utcOffset(),r=this.toDate(),o=r.toLocaleString("en-US",{timeZone:e}),u=Math.round((r-new Date(o))/1e3/60),l=i(o).$set("millisecond",this.$ms).utcOffset(15*-Math.round(r.getTimezoneOffset()/15)-u,!0);if(t){var c=l.utcOffset();l=l.add(n-c,"minute")}return l.$x.$timezone=e,l},l.offsetName=function(e){var t=this.$x.$timezone||i.tz.guess(),n=o(this.valueOf(),t,{timeZoneName:e}).find((function(e){return"timezonename"===e.type.toLowerCase()}));return n&&n.value};var c=l.startOf;l.startOf=function(e,t){if(!this.$x||!this.$x.$timezone)return c.call(this,e,t);var n=i(this.format("YYYY-MM-DD HH:mm:ss:SSS"));return c.call(n,e,t).tz(this.$x.$timezone,!0)},i.tz=function(e,t,n){var r=n&&t,o=n||t||a,l=u(+i(),o);if("string"!=typeof e)return i(e).tz(o);var c=function(e,t,n){var r=e-60*t*1e3,i=u(r,n);if(t===i)return[r,t];var a=u(r-=60*(i-t)*1e3,n);return i===a?[r,i]:[e-60*Math.min(i,a)*1e3,Math.max(i,a)]}(i.utc(e,r).valueOf(),l,o),s=c[0],f=c[1],d=i(s).utcOffset(f);return d.$x.$timezone=o,d},i.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},i.tz.setDefault=function(e){a=e}}}()},635:function(e){e.exports=function(){"use strict";var e="minute",t=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(r,i,a){var o=i.prototype;a.utc=function(e){return new i({date:e,utc:!0,args:arguments})},o.utc=function(t){var n=a(this.toDate(),{locale:this.$L,utc:!0});return t?n.add(this.utcOffset(),e):n},o.local=function(){return a(this.toDate(),{locale:this.$L,utc:!1})};var u=o.parse;o.parse=function(e){e.utc&&(this.$u=!0),this.$utils().u(e.$offset)||(this.$offset=e.$offset),u.call(this,e)};var l=o.init;o.init=function(){if(this.$u){var e=this.$d;this.$y=e.getUTCFullYear(),this.$M=e.getUTCMonth(),this.$D=e.getUTCDate(),this.$W=e.getUTCDay(),this.$H=e.getUTCHours(),this.$m=e.getUTCMinutes(),this.$s=e.getUTCSeconds(),this.$ms=e.getUTCMilliseconds()}else l.call(this)};var c=o.utcOffset;o.utcOffset=function(r,i){var a=this.$utils().u;if(a(r))return this.$u?0:a(this.$offset)?c.call(this):this.$offset;if("string"==typeof r&&(r=function(e){void 0===e&&(e="");var r=e.match(t);if(!r)return null;var i=(""+r[0]).match(n)||["-",0,0],a=i[0],o=60*+i[1]+ +i[2];return 0===o?0:"+"===a?o:-o}(r),null===r))return this;var o=Math.abs(r)<=16?60*r:r,u=this;if(i)return u.$offset=o,u.$u=0===r,u;if(0!==r){var l=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(u=this.local().add(o+l,e)).$offset=o,u.$x.$localOffset=l}else u=this.utc();return u};var s=o.format;o.format=function(e){var t=e||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return s.call(this,t)},o.valueOf=function(){var e=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*e},o.isUTC=function(){return!!this.$u},o.toISOString=function(){return this.toDate().toISOString()},o.toString=function(){return this.toDate().toUTCString()};var f=o.toDate;o.toDate=function(e){return"s"===e&&this.$offset?a(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():f.call(this)};var d=o.diff;o.diff=function(e,t,n){if(e&&this.$u===e.$u)return d.call(this,e,t,n);var r=this.local(),i=a(e).local();return d.call(r,i,t,n)}}}()},781:function(e){"use strict";var t=Array.prototype.slice,n=Object.prototype.toString;e.exports=function(e){var r=this;if("function"!==typeof r||"[object Function]"!==n.call(r))throw new TypeError("Function.prototype.bind called on incompatible "+r);for(var i,a=t.call(arguments,1),o=Math.max(0,r.length-a.length),u=[],l=0;l