An error occurred:"+Ss(r.message+"",!0)+"
";throw r}},nf.Parser=tf,nf.parser=tf.parse,nf.Renderer=Ks,nf.TextRenderer=Xs,nf.Lexer=Zs,nf.lexer=Zs.lex,nf.Tokenizer=qs,nf.Slugger=ef,nf.parse=nf;nf.options,nf.setOptions,nf.use,nf.walkTokens,nf.parseInline,tf.parse,Zs.lex;var rf=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=Hr().isMobile,s=wn().period,f=Lr().customStep,d=kn(),h=(0,r.useRef)(null),p=v((0,r.useState)(!1),2),m=p[0],g=p[1],y=v((0,r.useState)({limits:{enable:!1,range:{1:[0,0]}}}),2),_=y[0],b=y[1],D=(0,r.useMemo)((function(){return Array.isArray(a)&&a.every((function(e){return e}))}),[a]),w=Uc({predefinedQuery:D?a:[],display:"chart",visible:m,customStep:f}),k=w.isLoading,x=w.graphData,C=w.error,E=w.warning,S=function(e){var t=ot({},_);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]),D?Lt("div",{className:"vm-predefined-panel",ref:h,children:[Lt("div",{className:"vm-predefined-panel-header",children:[Lt(ai,{title:Lt((function(){return Lt("div",{className:"vm-predefined-panel-header__description vm-default-styles",children:[n&&Lt(Ot.HY,{children:[Lt("div",{children:[Lt("span",{children:"Description:"}),Lt("div",{dangerouslySetInnerHTML:{__html:nf.parse(n)}})]}),Lt("hr",{})]}),Lt("div",{children:[Lt("span",{children:"Queries:"}),Lt("div",{children:a.map((function(e,t){return Lt("div",{children:e},"".concat(t,"_").concat(e))}))})]})]})}),{}),children:Lt("div",{className:"vm-predefined-panel-header__info",children:Lt(In,{})})}),Lt("h3",{className:"vm-predefined-panel-header__title",children:t||""}),Lt(Gc,{yaxis:_,setYaxisLimits:S,toggleEnableLimits:function(){var e=ot({},_);e.limits.enable=!e.limits.enable,b(e)}})]}),Lt("div",{className:"vm-predefined-panel-body",children:[k&&Lt(Jc,{}),C&&Lt(Vr,{variant:"error",children:C}),E&&Lt(Vr,{variant:"warning",children:E}),x&&Lt(Fc,{data:x,period:s,customStep:f,query:a,yaxis:_,unit:i,alias:l,showLegend:o,setYaxisLimits:S,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})]})]}):Lt(Vr,{variant:"error",children:[Lt("code",{children:'"expr"'})," not found. Check the configuration file ",Lt("b",{children:u}),"."]})},af=function(e){var t=e.index,n=e.title,i=e.panels,a=e.filename,o=hr(document.body),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 p=v((0,r.useState)({start:0,target:0,enable:!1}),2),m=p[0],g=p[1],y=function(e){if(m.enable){var t=m.start,n=Math.ceil((t-e.clientX)/u);if(!(Math.abs(n)>=12)){var r=d.map((function(e,t){return e-(t===m.target?n:0)}));h(r)}}},_=function(){g(ot(ot({},m),{},{enable:!1}))},b=function(e){return function(t){!function(e,t){g({start:e.clientX,target:t,enable:!0})}(t,e)}};return(0,r.useEffect)((function(){return window.addEventListener("mousemove",y),window.addEventListener("mouseup",_),function(){window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",_)}}),[m]),Lt("div",{className:"vm-predefined-dashboard",children:Lt(Ri,{defaultExpanded:c,onChange:function(e){return s(e)},title:Lt((function(){return Lt("div",{className:mr()({"vm-predefined-dashboard-header":!0,"vm-predefined-dashboard-header_open":c}),children:[(n||a)&&Lt("span",{className:"vm-predefined-dashboard-header__title",children:n||"".concat(t+1,". ").concat(a)}),i&&Lt("span",{className:"vm-predefined-dashboard-header__count",children:["(",i.length," panels)"]})]})}),{}),children:Lt("div",{className:"vm-predefined-dashboard-panels",children:Array.isArray(i)&&i.length?i.map((function(e,t){return Lt("div",{className:"vm-predefined-dashboard-panels-panel vm-block vm-block_empty-padding",style:{gridColumn:"span ".concat(d[t])},children:[Lt(rf,{title:e.title,description:e.description,unit:e.unit,expr:e.expr,alias:e.alias,filename:a,showLegend:e.showLegend}),Lt("button",{className:"vm-predefined-dashboard-panels-panel__resizer",onMouseDown:b(t)})]},t)})):Lt("div",{className:"vm-predefined-dashboard-panels-panel__alert",children:Lt(Vr,{variant:"error",children:[Lt("code",{children:'"panels"'})," not found. Check the configuration file ",Lt("b",{children:a}),"."]})})})})})},of=function(){!function(){var e=wn(),t=e.duration,n=e.relativeTime,i=e.period.date,a=Lr().customStep,o=v(nt(),2)[1],u=function(){var e,r=as((it(e={},"g0.range_input",t),it(e,"g0.end_input",i),it(e,"g0.step_input",a),it(e,"g0.relative_time",n),e));o(r)};(0,r.useEffect)(u,[t,n,i,a]),(0,r.useEffect)(u,[])}();var e=Hr().isMobile,t=Jr(),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]),p=function(e){return function(){!function(e){l(e)}(e)}};return Lt("div",{className:"vm-predefined-panels",children:[i&&Lt(Jc,{}),!n.length&&a&&Lt(Vr,{variant:"error",children:a}),!n.length&&Lt(Vr,{variant:"info",children:"Dashboards not found"}),c.length>1&&Lt("div",{className:mr()({"vm-predefined-panels-tabs":!0,"vm-predefined-panels-tabs_mobile":e}),children:c.map((function(e){return Lt("div",{className:mr()({"vm-predefined-panels-tabs__tab":!0,"vm-predefined-panels-tabs__tab_active":e.value==u}),onClick:p(e.value),children:e.label},e.value)}))}),Lt("div",{className:"vm-predefined-panels__dashboards",children:[h&&f.map((function(e,t){return Lt(af,{index:t,filename:d,title:e.title,panels:e.panels},"".concat(u,"_").concat(t))})),!!n.length&&!h&&Lt(Vr,{variant:"error",children:[Lt("code",{children:'"rows"'})," not found. Check the configuration file ",Lt("b",{children:d}),"."]})]})]})},uf=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)},lf=function(){function e(){b(this,e),this.tsdbStatus=void 0,this.tabsNames=void 0,this.tsdbStatus=this.defaultTSDBStatus,this.tabsNames=["table","graph"],this.getDefaultState=this.getDefaultState.bind(this)}return x(e,[{key:"tsdbStatusData",get:function(){return this.tsdbStatus},set:function(e){this.tsdbStatus=e}},{key:"defaultTSDBStatus",get:function(){return{totalSeries:0,totalLabelValuePairs:0,totalSeriesByAll:0,seriesCountByMetricName:[],seriesCountByLabelName:[],seriesCountByFocusLabelValue:[],seriesCountByLabelValuePair:[],labelValueCountByLabelName:[]}}},{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"),a}},{key:"getDefaultState",value:function(e,t){var n=this;return this.keys(e,t).reduce((function(e,t){return ot(ot({},e),{},{tabs:ot(ot({},e.tabs),{},it({},t,n.tabsNames)),containerRefs:ot(ot({},e.containerRefs),{},it({},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:"",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:cf,seriesCountByLabelName:sf,seriesCountByFocusLabelValue:ff,seriesCountByLabelValuePair:df,labelValueCountByLabelName:hf}}},{key:"totalSeries",value:function(e){return"labelValueCountByLabelName"===e?-1:this.tsdbStatus.totalSeries}}]),e}(),cf=[{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:""}],sf=[{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:""}],ff=[{id:"name",label:"Label value"},{id:"value",label:"Number of series"},{id:"percentage",label:"Share in total"},{disablePadding:!1,id:"action",label:"",numeric:!1}],df=[{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:""}],hf=[{id:"name",label:"Label name"},{id:"value",label:"Number of unique values"},{id:"action",label:""}],pf={seriesCountByMetricName:function(e){var t=e.query;return mf("__name__",t)},seriesCountByLabelName:function(e){var t=e.query;return"{".concat(t,'!=""}')},seriesCountByFocusLabelValue:function(e){var t=e.query,n=e.focusLabel;return mf(n,t)},seriesCountByLabelValuePair:function(e){var t=e.query.split("="),n=t[0],r=t.slice(1).join("=");return mf(n,r)},labelValueCountByLabelName:function(e){var t=e.query,n=e.match;return"".concat(n.replace("}",""),", ").concat(t,'!=""}')}},mf=function(e,t){return e?"{"+e+"="+JSON.stringify(t)+"}":""},vf=function(e){var t,n=e.totalSeries,r=e.totalSeriesAll,i=e.seriesCountByMetricName,a=Hr().isMobile,o=v(nt(),1)[0],u=o.get("match"),l=o.get("focusLabel"),c=/__name__/.test(u||""),s=(null===(t=i[0])||void 0===t?void 0:t.value)/r*100,f=[{title:"Total series",value:n.toLocaleString("en-US"),display:!l,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(s)?"-":"".concat(s.toFixed(2),"%"),display:c,info:"The share of these series in the total number of time series."}].filter((function(e){return e.display}));return f.length?Lt("div",{className:mr()({"vm-cardinality-totals":!0,"vm-cardinality-totals_mobile":a}),children:f.map((function(e){var t=e.title,n=e.value,r=e.info;return Lt("div",{className:"vm-cardinality-totals-card",children:[Lt("div",{className:"vm-cardinality-totals-card-header",children:[r&&Lt(ai,{title:Lt("p",{className:"vm-cardinality-totals-card-header__tooltip",children:r}),children:Lt("div",{className:"vm-cardinality-totals-card-header__info-icon",children:Lt(In,{})})}),Lt("h4",{className:"vm-cardinality-totals-card-header__title",children:t})]}),Lt("span",{className:"vm-cardinality-totals-card__value",children:n})]},t)}))}):null},gf=function(e){var t=Hr().isMobile,n=v(nt(),2),i=n[0],a=n[1],o=i.get("tips")||"",u=v((0,r.useState)(i.get("match")||""),2),l=u[0],c=u[1],s=v((0,r.useState)(i.get("focusLabel")||""),2),f=s[0],d=s[1],h=v((0,r.useState)(+(i.get("topN")||10)),2),p=h[0],m=h[1],g=(0,r.useMemo)((function(){return p<0?"Number must be bigger than zero":""}),[p]),y=function(){i.set("match",l),i.set("topN",p.toString()),i.set("focusLabel",f),a(i)};return(0,r.useEffect)((function(){var e=i.get("match"),t=+(i.get("topN")||10),n=i.get("focusLabel");e!==l&&c(e||""),t!==p&&m(t),n!==f&&d(n||"")}),[i]),Lt("div",{className:mr()({"vm-cardinality-configurator":!0,"vm-cardinality-configurator_mobile":t,"vm-block":!0,"vm-block_mobile":t}),children:[Lt("div",{className:"vm-cardinality-configurator-controls",children:[Lt("div",{className:"vm-cardinality-configurator-controls__query",children:Lt(di,{label:"Time series selector",type:"string",value:l,onChange:c,onEnter:y})}),Lt("div",{className:"vm-cardinality-configurator-controls__item",children:Lt(di,{label:"Focus label",type:"text",value:f||"",onChange:d,onEnter:y,endIcon:Lt(ai,{title:Lt("div",{children:Lt("p",{children:"To identify values with the highest number of series for the selected label."})}),children:Lt(lr,{})})})}),Lt("div",{className:"vm-cardinality-configurator-controls__item vm-cardinality-configurator-controls__item_limit",children:Lt(di,{label:"Limit entries",type:"number",value:p,error:g,onChange:function(e){var t=+e;m(isNaN(t)?0:t)},onEnter:y})})]}),Lt("div",{className:"vm-cardinality-configurator-bottom",children:[Lt(vf,ot({},e)),Lt("div",{className:"vm-cardinality-configurator-bottom-helpful",children:Lt("a",{className:"vm-link vm-link_with-icon",target:"_blank",href:"https://docs.victoriametrics.com/#cardinality-explorer",rel:"help noreferrer",children:[Lt(or,{}),"Documentation"]})}),Lt("div",{className:"vm-cardinality-configurator-bottom__execute",children:[Lt(ai,{title:o?"Hide tips":"Show tips",children:Lt(ei,{variant:"text",color:o?"warning":"gray",startIcon:Lt(dr,{}),onClick:function(){i.get("tips")||""?i.delete("tips"):i.set("tips","true"),a(i)}})}),Lt(ei,{variant:"text",startIcon:Lt(Ln,{}),onClick:function(){i.set("match",""),i.set("focusLabel",""),a(i)},children:"Reset"}),Lt(ei,{startIcon:Lt(qn,{}),onClick:y,children:"Execute Query"})]})]})]})};function yf(e){var t=e.order,n=e.orderBy,r=e.onRequestSort,i=e.headerCells;return Lt("thead",{className:"vm-table-header",children:Lt("tr",{className:"vm-table__row vm-table__row_header",children:i.map((function(e){return Lt("th",{className:mr()({"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:Lt("div",{className:"vm-table-cell__content",children:[e.info?Lt(ai,{title:e.info,children:[Lt("div",{className:"vm-metrics-content-header__tip-icon",children:Lt(In,{})}),e.label]}):Lt(Ot.HY,{children:e.label}),"action"!==e.id&&"percentage"!==e.id&&Lt("div",{className:mr()({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":n===e.id,"vm-table__sort-icon_desc":"desc"===t&&n===e.id}),children:Lt($n,{})})]})},e.id);var i}))})})}function _f(e,t,n){return t[n]e[n]?1:0}function bf(e,t){return"desc"===e?function(e,n){return _f(e,n,t)}:function(e,n){return-_f(e,n,t)}}function Df(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 wf=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=Df(t,bf(u,s));return Lt("table",{className:"vm-table",children:[Lt(yf,{order:u,orderBy:s,onRequestSort:function(e,t){l(s===t&&"asc"===u?"desc":"asc"),f(t)},rowCount:t.length,headerCells:n}),Lt("tbody",{className:"vm-table-header",children:d.map((function(e){return Lt("tr",{className:"vm-table__row",children:a(e)},e.name)}))})]})},kf=function(e){var t=e.row,n=e.totalSeries,r=e.onActionClick,i=n>0?t.value/n*100:-1,a=function(){r(t.name)};return Lt(Ot.HY,{children:[Lt("td",{className:"vm-table-cell",children:Lt("span",{className:"vm-link vm-link_colored",onClick:a,children:t.name})},t.name),Lt("td",{className:"vm-table-cell",children:t.value},t.value),i>0&&Lt("td",{className:"vm-table-cell",children:Lt(Zc,{value:i})},t.progressValue),Lt("td",{className:"vm-table-cell vm-table-cell_right",children:Lt("div",{className:"vm-table-cell__content",children:Lt(ai,{title:"Filter by ".concat(t.name),children:Lt(ei,{variant:"text",size:"small",onClick:a,children:Lt(Wn,{})})})})},"action")]})},xf=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 ot(ot({},e),{},{percentage:e.value/n[0]*100})})))}),[t]),Lt("div",{className:"vm-simple-bar-chart",children:[Lt("div",{className:"vm-simple-bar-chart-y-axis",children:u.map((function(e){return Lt("div",{className:"vm-simple-bar-chart-y-axis__tick",children:e},e)}))}),Lt("div",{className:"vm-simple-bar-chart-data",children:i.map((function(e){var t=e.name,n=e.value,r=e.percentage;return Lt(ai,{title:"".concat(t,": ").concat(n),placement:"top-center",children:Lt("div",{className:"vm-simple-bar-chart-data-item",style:{maxHeight:"".concat(r||0,"%")}})},"".concat(t,"_").concat(n))}))})]})},Cf=function(e){var t=e.rows,n=e.tabs,i=void 0===n?[]:n,a=e.chartContainer,o=e.totalSeries,u=e.onActionClick,l=e.sectionTitle,c=e.tip,s=e.tableHeaderCells,f=Hr().isMobile,d=v((0,r.useState)("table"),2),h=d[0],p=d[1],m=(0,r.useMemo)((function(){return i.map((function(e,t){return{value:e,label:e,icon:Lt(0===t?Gn:Qn,{})}}))}),[i]);return Lt("div",{className:mr()({"vm-metrics-content":!0,"vm-metrics-content_mobile":f,"vm-block":!0,"vm-block_mobile":f}),children:[Lt("div",{className:"vm-metrics-content-header vm-section-header",children:[Lt("h5",{className:mr()({"vm-metrics-content-header__title":!0,"vm-section-header__title":!0,"vm-section-header__title_mobile":f}),children:[!f&&c&&Lt(ai,{title:Lt("p",{dangerouslySetInnerHTML:{__html:c},className:"vm-metrics-content-header__tip"}),children:Lt("div",{className:"vm-metrics-content-header__tip-icon",children:Lt(In,{})})}),l]}),Lt("div",{className:"vm-section-header__tabs",children:Lt(br,{activeItem:h,items:m,onChange:p})})]}),"table"===h&&Lt("div",{ref:a,className:mr()({"vm-metrics-content__table":!0,"vm-metrics-content__table_mobile":f}),children:Lt(wf,{rows:t,headerCells:s,defaultSortColumn:"value",tableCells:function(e){return Lt(kf,{row:e,totalSeries:o,onActionClick:u})}})}),"graph"===h&&Lt("div",{className:"vm-metrics-content__chart",children:Lt(xf,{data:t.map((function(e){return{name:e.name,value:e.value}}))})})]})},Ef=function(e){var t=e.title,n=e.children;return Lt("div",{className:"vm-cardinality-tip",children:[Lt("div",{className:"vm-cardinality-tip-header",children:[Lt("div",{className:"vm-cardinality-tip-header__tip-icon",children:Lt(dr,{})}),Lt("h4",{className:"vm-cardinality-tip-header__title",children:t||"Tips"})]}),Lt("p",{className:"vm-cardinality-tip__description",children:n})]})},Sf=function(){return Lt(Ef,{title:"Metrics with a high number of series",children:Lt("ul",{children:[Lt("li",{children:["Identify and eliminate labels with frequently changed values to reduce their\xa0",Lt(ps,{href:"https://docs.victoriametrics.com/FAQ.html#what-is-high-cardinality",children:"cardinality"}),"\xa0and\xa0",Lt(ps,{href:"https://docs.victoriametrics.com/FAQ.html#what-is-high-churn-rate",children:"high churn rate"})]}),Lt("li",{children:["Find unused time series and\xa0",Lt(ps,{href:"https://docs.victoriametrics.com/relabeling.html",children:"drop entire metrics"})]}),Lt("li",{children:["Aggregate time series before they got ingested into the database via\xa0",Lt(ps,{href:"https://docs.victoriametrics.com/stream-aggregation.html",children:"streaming aggregation"})]})]})})},Af=function(){return Lt(Ef,{title:"Labels with a high number of unique values",children:Lt("ul",{children:[Lt("li",{children:"Decrease the number of unique label values to reduce cardinality"}),Lt("li",{children:["Drop the label entirely via\xa0",Lt(ps,{href:"https://docs.victoriametrics.com/relabeling.html",children:"relabeling"})]}),Lt("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"})]})})},Nf=function(){return Lt(Ef,{title:"Dashboard of a single metric",children:[Lt("p",{children:"This dashboard helps to understand the cardinality of a single metric."}),Lt("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."}),Lt("p",{children:"Use the series selector at the top of the page to apply additional filters."})]})},Mf=function(){return Lt(Ef,{title:"Dashboard of a label",children:[Lt("p",{children:"This dashboard helps you understand the count of time series per label."}),Lt("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."}),Lt("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."})]})},Ff=function(){var e=Hr().isMobile,t=v(nt(),2),n=t[0],i=t[1],o=n.get("tips")||"",u=n.get("match")||"",l=n.get("focusLabel")||"",c=function(){var e=new lf,t=v(nt(),1)[0],n=t.get("match"),i=t.get("focusLabel"),o=+(t.get("topN")||10),u=t.get("date")||a()().tz().format(zt),l=Bt().serverUrl,c=v((0,r.useState)(!1),2),s=c[0],f=c[1],d=v((0,r.useState)(),2),h=d[0],p=d[1],m=v((0,r.useState)(e.defaultTSDBStatus),2),g=m[0],y=m[1],_=function(){var t=Wi(Ui().mark((function t(r){var i,a,o,u,c,s,d,h,m,v,g;return Ui().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(l){t.next=2;break}return t.abrupt("return");case 2:return p(""),f(!0),y(e.defaultTSDBStatus),i={date:r.date,topN:0,match:"",focusLabel:""},a=uf(l,r),o=uf(l,i),t.prev=8,t.next=11,fetch(a);case 11:return u=t.sent,t.next=14,u.json();case 14:return c=t.sent,t.next=17,fetch(o);case 17:return s=t.sent,t.next=20,s.json();case 20:d=t.sent,u.ok?(h=c.data,m=d.data.totalSeries,(v=ot({},h)).totalSeriesByAll=m,g=null===n||void 0===n?void 0:n.replace(/[{}"]/g,""),v.seriesCountByLabelValuePair=v.seriesCountByLabelValuePair.filter((function(e){return e.name!==g})),y(v),f(!1)):(p(c.error),y(e.defaultTSDBStatus),f(!1)),t.next=28;break;case 24:t.prev=24,t.t0=t.catch(8),f(!1),t.t0 instanceof Error&&p("".concat(t.t0.name,": ").concat(t.t0.message));case 28:case"end":return t.stop()}}),t,null,[[8,24]])})));return function(e){return t.apply(this,arguments)}}();return(0,r.useEffect)((function(){_({topN:o,match:n,date:u,focusLabel:i})}),[l,n,i,o,u]),(0,r.useEffect)((function(){h&&(y(e.defaultTSDBStatus),f(!1))}),[h]),e.tsdbStatusData=g,{isLoading:s,appConfigurator:e,error:h}}(),s=c.isLoading,f=c.appConfigurator,d=c.error,h=f.tsdbStatusData,p=f.getDefaultState,m=f.tablesHeaders,g=f.sectionsTips,y=p(u,l);return Lt("div",{className:mr()({"vm-cardinality-panel":!0,"vm-cardinality-panel_mobile":e}),children:[s&&Lt(Jc,{message:"Please wait while cardinality stats is calculated. \n This may take some time if the db contains big number of time series."}),Lt(gf,{totalSeries:h.totalSeries,totalSeriesAll:h.totalSeriesByAll,totalLabelValuePairs:h.totalLabelValuePairs,seriesCountByMetricName:h.seriesCountByMetricName}),o&&Lt("div",{className:"vm-cardinality-panel-tips",children:[!u&&!l&&Lt(Sf,{}),u&&!l&&Lt(Nf,{}),!u&&!l&&Lt(Af,{}),l&&Lt(Mf,{})]}),d&&Lt(Vr,{variant:"error",children:d}),f.keys(u,l).map((function(e){return Lt(Cf,{sectionTitle:f.sectionsTitles(l)[e],tip:g[e],rows:h[e],onActionClick:(t=e,function(e){var r=pf[t]({query:e,focusLabel:l,match:u});n.set("match",r),"labelValueCountByLabelName"!==t&&"seriesCountByLabelName"!=t||n.set("focusLabel",e),"seriesCountByFocusLabelValue"==t&&n.set("focusLabel",""),i(n)}),tabs:y.tabs[e],chartContainer:y.containerRefs[e],totalSeries:f.totalSeries(e),tableHeaderCells:m[e]},e);var t}))]})},Of=function(e){var t=e.rows,n=e.columns,i=e.defaultOrderBy,a=v((0,r.useState)(i||"count"),2),o=a[0],u=a[1],l=v((0,r.useState)("desc"),2),c=l[0],s=l[1],f=(0,r.useMemo)((function(){return Df(t,bf(c,o))}),[t,o,c]),d=function(e){return function(){var t;t=e,s((function(e){return"asc"===e&&o===t?"desc":"asc"})),u(t)}};return Lt("table",{className:"vm-table",children:[Lt("thead",{className:"vm-table-header",children:Lt("tr",{className:"vm-table__row vm-table__row_header",children:n.map((function(e){return Lt("th",{className:"vm-table-cell vm-table-cell_header vm-table-cell_sort",onClick:d(e.key),children:Lt("div",{className:"vm-table-cell__content",children:[e.title||e.key,Lt("div",{className:mr()({"vm-table__sort-icon":!0,"vm-table__sort-icon_active":o===e.key,"vm-table__sort-icon_desc":"desc"===c&&o===e.key}),children:Lt($n,{})})]})},e.key)}))})}),Lt("tbody",{className:"vm-table-body",children:f.map((function(e,t){return Lt("tr",{className:"vm-table__row",children:n.map((function(t){return Lt("td",{className:"vm-table-cell",children:e[t.key]||"-"},t.key)}))},t)}))})]})},Tf=["table","JSON"].map((function(e,t){return{value:String(t),label:e,icon:Lt(0===t?Gn:Jn,{})}})),Lf=function(e){var t=e.rows,n=e.title,i=e.columns,a=e.defaultOrderBy,o=Hr().isMobile,u=v((0,r.useState)(0),2),l=u[0],c=u[1];return Lt("div",{className:mr()({"vm-top-queries-panel":!0,"vm-block":!0,"vm-block_mobile":o}),children:[Lt("div",{className:mr()({"vm-top-queries-panel-header":!0,"vm-section-header":!0,"vm-top-queries-panel-header_mobile":o}),children:[Lt("h5",{className:mr()({"vm-section-header__title":!0,"vm-section-header__title_mobile":o}),children:n}),Lt("div",{className:"vm-section-header__tabs",children:Lt(br,{activeItem:String(l),items:Tf,onChange:function(e){c(+e)}})})]}),Lt("div",{className:mr()({"vm-top-queries-panel__table":!0,"vm-top-queries-panel__table_mobile":o}),children:[0===l&&Lt(Of,{rows:t,columns:i,defaultOrderBy:a}),1===l&&Lt(qc,{data:t})]})]})},If=function(){var e=Hr().isMobile,t=function(){var e=Bt().serverUrl,t=zr(),n=t.topN,i=t.maxLifetime,a=t.runQuery,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],p=d[1],m=(0,r.useMemo)((function(){return function(e,t,n){return"".concat(e,"/api/v1/status/top_queries?topN=").concat(t||"","&maxLifetime=").concat(n||"")}(e,n,i)}),[e,n,i]),g=function(){var e=Wi(Ui().mark((function e(){var t,n;return Ui().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f(!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,t.ok&&["topByAvgDuration","topByCount","topBySumDuration"].forEach((function(e){var t=n[e];Array.isArray(t)&&t.forEach((function(e){return e.timeRangeHours=+(e.timeRangeSeconds/3600).toFixed(2)}))})),l(t.ok?n:null),p(String(n.error||"")),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),e.t0 instanceof Error&&"AbortError"!==e.t0.name&&p("".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()}),[a]),{data:u,error:h,loading:s}}(),n=t.data,i=t.error,o=t.loading,u=zr(),l=u.topN,c=u.maxLifetime,s=(0,r.useContext)(Rr).dispatch;!function(){var e=zr(),t=e.topN,n=e.maxLifetime,i=v(nt(),2)[1],a=function(){var e=as({topN:String(t),maxLifetime:n});i(e)};(0,r.useEffect)(a,[t,n]),(0,r.useEffect)(a,[])}();var f=(0,r.useMemo)((function(){var e=c.trim().split(" ").reduce((function(e,t){var n=Kt(t);return n?ot(ot({},e),n):ot({},e)}),{});return!!a().duration(e).asMilliseconds()}),[c]),d=(0,r.useMemo)((function(){return!!l&&l<1}),[l]),h=(0,r.useMemo)((function(){return d?"Number must be bigger than zero":""}),[d]),p=(0,r.useMemo)((function(){return f?"":"Invalid duration value"}),[f]),m=function(e){if(!n)return e;var t=n[e];return"number"===typeof t?Xl(t,t,t):t||e},g=function(){s({type:"SET_RUN_QUERY"})},y=function(e){"Enter"===e.key&&g()};return(0,r.useEffect)((function(){n&&(l||s({type:"SET_TOP_N",payload:+n.topN}),c||s({type:"SET_MAX_LIFE_TIME",payload:n.maxLifetime}))}),[n]),Lt("div",{className:mr()({"vm-top-queries":!0,"vm-top-queries_mobile":e}),children:[o&&Lt(Jc,{containerStyles:{height:"500px"}}),Lt("div",{className:mr()({"vm-top-queries-controls":!0,"vm-block":!0,"vm-block_mobile":e}),children:[Lt("div",{className:"vm-top-queries-controls-fields",children:[Lt("div",{className:"vm-top-queries-controls-fields__item",children:Lt(di,{label:"Max lifetime",value:c,error:p,helperText:"For example ".concat("30ms, 15s, 3d4h, 1y2w"),onChange:function(e){s({type:"SET_MAX_LIFE_TIME",payload:e})},onKeyDown:y})}),Lt("div",{className:"vm-top-queries-controls-fields__item",children:Lt(di,{label:"Number of returned queries",type:"number",value:l||"",error:h,onChange:function(e){s({type:"SET_TOP_N",payload:+e})},onKeyDown:y})})]}),Lt("div",{className:mr()({"vm-top-queries-controls-bottom":!0,"vm-top-queries-controls-bottom_mobile":e}),children:[Lt("div",{className:"vm-top-queries-controls-bottom__info",children:["VictoriaMetrics tracks the last\xa0",Lt(ai,{title:"search.queryStats.lastQueriesCount",children:Lt("b",{children:m("search.queryStats.lastQueriesCount")})}),"\xa0queries with durations at least\xa0",Lt(ai,{title:"search.queryStats.minQueryDuration",children:Lt("b",{children:m("search.queryStats.minQueryDuration")})})]}),Lt("div",{className:"vm-top-queries-controls-bottom__button",children:Lt(ei,{startIcon:Lt(qn,{}),onClick:g,children:"Execute"})})]})]}),i&&Lt(Vr,{variant:"error",children:i}),n&&Lt(Ot.HY,{children:Lt("div",{className:"vm-top-queries-panels",children:[Lt(Lf,{rows:n.topByCount,title:"Most frequently executed queries",columns:[{key:"query"},{key:"timeRangeHours",title:"time range, hours"},{key:"count"}]}),Lt(Lf,{rows:n.topByAvgDuration,title:"Most heavy queries",columns:[{key:"query"},{key:"avgDurationSeconds",title:"avg duration, seconds"},{key:"timeRangeHours",title:"time range, hours"},{key:"count"}],defaultOrderBy:"avgDurationSeconds"}),Lt(Lf,{rows:n.topBySumDuration,title:"Queries with most summary time to execute",columns:[{key:"query"},{key:"sumDurationSeconds",title:"sum duration, seconds"},{key:"timeRangeHours",title:"time range, hours"},{key:"count"}],defaultOrderBy:"sumDurationSeconds"})]})})]})},Bf={"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)"},Pf={"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(97,97,97, 0.92)","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)"},Rf=function(){var e=v((0,r.useState)(At()),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},zf=["primary","secondary","error","warning","info","success"],jf=function(e){var t,n=e.onLoaded,i=pt(),a=ht().palette,o=void 0===a?{}:a,u=Bt().theme,l=Rf(),c=Pt(),s=hr(document.body),f=v((0,r.useState)((it(t={},lt.dark,Bf),it(t,lt.light,Pf),it(t,lt.system,At()?Bf:Pf),t)),2),d=f[0],h=f[1],p=function(){var e=window,t=e.innerWidth,n=e.innerHeight,r=document.documentElement,i=r.clientWidth,a=r.clientHeight;St("scrollbar-width","".concat(t-i,"px")),St("scrollbar-height","".concat(n-a,"px")),St("vh","".concat(.01*n,"px"))},m=function(){zf.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"}(Et("color-".concat(e)));St("".concat(e,"-text"),r),t===zf.length-1&&(c({type:"SET_DARK_THEME"}),n(!0))}))},g=function(){var e=xt("THEME")||lt.system,t=d[e];Object.entries(t).forEach((function(e){var t=v(e,2),n=t[0],r=t[1];St(n,r)})),m(),i&&(zf.forEach((function(e){var t=o[e];t&&St("color-".concat(e),t)})),m())};return(0,r.useEffect)((function(){p(),g()}),[d]),(0,r.useEffect)(p,[s]),(0,r.useEffect)((function(){var e=At()?Bf:Pf;d[lt.system]!==e?h((function(t){return ot(ot({},t),{},it({},lt.system,e))})):g()}),[u,l]),(0,r.useEffect)((function(){i&&c({type:"SET_THEME",payload:lt.light})}),[]),null},$f=function(e){var t=v((0,r.useState)([]),2),n=t[0],i=t[1],a=v((0,r.useState)(!1),2),o=a[0],u=a[1],l=function(e){e.preventDefault(),e.stopPropagation(),"dragenter"===e.type||"dragover"===e.type?u(!0):"dragleave"===e.type&&u(!1)},c=function(e){var t;e.preventDefault(),e.stopPropagation(),u(!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||[]);i(t)}(e.dataTransfer.files)},s=function(e){var t,n=null===(t=e.clipboardData)||void 0===t?void 0:t.items;if(n){var r=Array.from(n).filter((function(e){return"application/json"===e.type})).map((function(e){return e.getAsFile()})).filter((function(e){return null!==e}));i(r)}};return(0,r.useEffect)((function(){return null===e||void 0===e||e.addEventListener("dragenter",l),null===e||void 0===e||e.addEventListener("dragleave",l),null===e||void 0===e||e.addEventListener("dragover",l),null===e||void 0===e||e.addEventListener("drop",c),null===e||void 0===e||e.addEventListener("paste",s),function(){null===e||void 0===e||e.removeEventListener("dragenter",l),null===e||void 0===e||e.removeEventListener("dragleave",l),null===e||void 0===e||e.removeEventListener("dragover",l),null===e||void 0===e||e.removeEventListener("drop",c),null===e||void 0===e||e.removeEventListener("paste",s)}}),[e]),{files:n,dragging:o}},Hf=function(e){var t=e.onOpenModal,n=e.onChange;return Lt("div",{className:"vm-trace-page-controls",children:[Lt(ei,{variant:"outlined",onClick:t,children:"Paste JSON"}),Lt(ai,{title:"The file must contain tracing information in JSON format",children:Lt(ei,{children:["Upload Files",Lt("input",{id:"json",type:"file",accept:"application/json",multiple:!0,title:" ",onChange:n})]})})]})},Yf=function(){var e=v((0,r.useState)(!1),2),t=e[0],n=e[1],i=v((0,r.useState)([]),2),a=i[0],o=i[1],u=v((0,r.useState)([]),2),l=u[0],c=u[1],s=(0,r.useMemo)((function(){return!!a.length}),[a]),f=v(nt(),2)[1],d=function(){n(!0)},h=function(){n(!1)},p=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";c((function(n){return[{filename:t,text:": ".concat(e.message)}].concat(_(n))}))},m=function(e,t){try{var n=JSON.parse(e),r=n.trace||n;if(!r.duration_msec)return void p(new Error(ut.traceNotFound),t);var i=new Vc(r,t);o((function(e){return[i].concat(_(e))}))}catch(a){a instanceof Error&&p(a,t)}},g=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);m(r,n)},t.readAsText(e)}))},y=function(e){c([]);var t=Array.from(e.target.files||[]);g(t),e.target.value=""},b=function(e){return function(){!function(e){c((function(t){return t.filter((function(t,n){return n!==e}))}))}(e)}};(0,r.useEffect)((function(){f({})}),[]);var D=$f(document.body),w=D.files,k=D.dragging;return(0,r.useEffect)((function(){g(w)}),[w]),Lt("div",{className:"vm-trace-page",children:[Lt("div",{className:"vm-trace-page-header",children:[Lt("div",{className:"vm-trace-page-header-errors",children:l.map((function(e,t){return Lt("div",{className:"vm-trace-page-header-errors-item",children:[Lt(Vr,{variant:"error",children:[Lt("b",{className:"vm-trace-page-header-errors-item__filename",children:e.filename}),Lt("span",{children:e.text})]}),Lt(ei,{className:"vm-trace-page-header-errors-item__close",startIcon:Lt(Tn,{}),variant:"text",color:"error",onClick:b(t)})]},"".concat(e,"_").concat(t))}))}),Lt("div",{children:s&&Lt(Hf,{onOpenModal:d,onChange:y})})]}),s&&Lt("div",{children:Lt(es,{jsonEditor:!0,traces:a,onDeleteClick:function(e){var t=a.filter((function(t){return t.idValue!==e.idValue}));o(_(t))}})}),!s&&Lt("div",{className:"vm-trace-page-preview",children:[Lt("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",Lt("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."]}),Lt(Hf,{onOpenModal:d,onChange:y})]}),t&&Lt(ii,{title:"Paste JSON",onClose:h,children:Lt(Xc,{editable:!0,displayTitle:!0,defaultTile:"JSON ".concat(a.length+1),onClose:h,onUpload:m})}),k&&Lt("div",{className:"vm-trace-page__dropzone"})]})},Vf=function(e){var t=Bt().serverUrl,n=wn().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=Wi(Ui().mark((function e(){var t,n,r;return Ui().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}},Uf=function(e,t){var n=Bt().serverUrl,i=wn().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],p=(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=Wi(Ui().mark((function e(){var t,n,r;return Ui().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s(!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,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)}}),[p]),{names:o,isLoading:c,error:d}},qf=function(e){var t=e.name,n=e.job,i=e.instance,a=e.rateEnabled,o=e.isBucket,u=e.height,l=Hr().isMobile,c=Lr(),s=c.customStep,f=c.yaxis,d=wn().period,h=Ir(),p=kn(),m=v((0,r.useState)(!1),2),g=m[0],y=m[1],_=(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 i?'\nlabel_map(\n histogram_quantiles("__name__", 0.5, 0.95, 0.99, sum(rate('.concat(r,')) by (vmrange, le)),\n "__name__",\n "0.5", "q50",\n "0.95", "q95",\n "0.99", "q99",\n)'):"\nwith (q = histogram_quantile(0.95, sum(rate(".concat(r,')) by (instance, vmrange, le))) (\n alias(min(q), "q95min"),\n alias(max(q), "q95max"),\n alias(avg(q), "q95avg"),\n)');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]),b=Uc({predefinedQuery:[_],visible:!0,customStep:s,showAllSeries:g}),D=b.isLoading,w=b.graphData,k=b.error,x=b.warning;return Lt("div",{className:mr()({"vm-explore-metrics-graph":!0,"vm-explore-metrics-graph_mobile":l}),children:[D&&Lt(Jc,{}),k&&Lt(Vr,{variant:"error",children:k}),x&&Lt(Vr,{variant:"warning",children:Lt("div",{className:"vm-explore-metrics-graph__warning",children:[Lt("p",{children:x}),Lt(ei,{color:"warning",variant:"outlined",onClick:function(){y(!0)},children:"Show all"})]})}),w&&d&&Lt(Fc,{data:w,period:d,customStep:s,query:[_],yaxis:f,setYaxisLimits:function(e){h({type:"SET_YAXIS_LIMITS",payload:e})},setPeriod:function(e){var t=e.from,n=e.to;p({type:"SET_PERIOD",payload:{from:t,to:n}})},showLegend:!1,height:u})]})},Wf=function(e){var t=e.name,n=e.index,i=e.length,a=e.isBucket,o=e.rateEnabled,u=e.onChangeRate,l=e.onRemoveItem,c=e.onChangeOrder,s=Hr().isMobile,f=v((0,r.useState)(!1),2),d=f[0],h=f[1],p=function(){l(t)},m=function(){c(t,n,n+1)},g=function(){c(t,n,n-1)};return Lt("div",s?{className:"vm-explore-metrics-item-header vm-explore-metrics-item-header_mobile",children:[Lt("div",{className:"vm-explore-metrics-item-header__name",children:t}),Lt(ei,{variant:"text",size:"small",startIcon:Lt(sr,{}),onClick:function(){h(!0)}}),d&&Lt(ii,{title:t,onClose:function(){h(!1)},children:Lt("div",{className:"vm-explore-metrics-item-header-modal",children:[Lt("div",{className:"vm-explore-metrics-item-header-modal-order",children:[Lt(ei,{startIcon:Lt(Xn,{}),variant:"outlined",onClick:g,disabled:0===n}),Lt("p",{children:["position:",Lt("span",{className:"vm-explore-metrics-item-header-modal-order__index",children:["#",n+1]})]}),Lt(ei,{endIcon:Lt(Kn,{}),variant:"outlined",onClick:m,disabled:n===i-1})]}),!a&&Lt("div",{className:"vm-explore-metrics-item-header-modal__rate",children:[Lt(Lc,{label:Lt("span",{children:["enable ",Lt("code",{children:"rate()"})]}),value:o,onChange:u,fullWidth:!0}),Lt("p",{children:"calculates the average per-second speed of metrics change"})]}),Lt(ei,{startIcon:Lt(Tn,{}),color:"error",variant:"outlined",onClick:p,fullWidth:!0,children:"Remove graph"})]})})]}:{className:"vm-explore-metrics-item-header",children:[Lt("div",{className:"vm-explore-metrics-item-header-order",children:[Lt(ai,{title:"move graph up",children:Lt(ei,{className:"vm-explore-metrics-item-header-order__up",startIcon:Lt(jn,{}),variant:"text",color:"gray",size:"small",onClick:g})}),Lt("div",{className:"vm-explore-metrics-item-header__index",children:["#",n+1]}),Lt(ai,{title:"move graph down",children:Lt(ei,{className:"vm-explore-metrics-item-header-order__down",startIcon:Lt(jn,{}),variant:"text",color:"gray",size:"small",onClick:m})})]}),Lt("div",{className:"vm-explore-metrics-item-header__name",children:t}),!a&&Lt("div",{className:"vm-explore-metrics-item-header__rate",children:Lt(ai,{title:"calculates the average per-second speed of metric's change",children:Lt(Lc,{label:Lt("span",{children:["enable ",Lt("code",{children:"rate()"})]}),value:o,onChange:u})})}),Lt("div",{className:"vm-explore-metrics-item-header__close",children:Lt(ai,{title:"close graph",children:Lt(ei,{startIcon:Lt(Tn,{}),variant:"text",color:"gray",size:"small",onClick:p})})})]})},Qf=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],p=d[1],m=hr(document.body),g=(0,r.useMemo)(u.height,[u,m]);return(0,r.useEffect)((function(){p(s)}),[n]),Lt("div",{className:"vm-explore-metrics-item vm-block vm-block_empty-padding",children:[Lt(Wf,{name:t,index:a,length:o,isBucket:f,rateEnabled:h,size:u.id,onChangeRate:p,onRemoveItem:l,onChangeOrder:c}),Lt(qf,{name:t,job:n,instance:i,rateEnabled:h,isBucket:f,height:g},"".concat(t,"_").concat(n,"_").concat(i,"_").concat(h))]})},Gf=function(e){var t=e.values,n=e.onRemoveItem,r=Hr().isMobile;return r?Lt("span",{className:"vm-select-input-content__counter",children:["selected ",t.length]}):Lt(Ot.HY,{children:t.map((function(e){return Lt("div",{className:"vm-select-input-content__selected",children:[Lt("span",{children:e}),Lt("div",{onClick:(t=e,function(e){n(t),e.stopPropagation()}),children:Lt(Tn,{})})]},e);var t}))})},Jf=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=Bt().isDarkTheme,p=Hr().isMobile,m=v((0,r.useState)(""),2),g=m[0],y=m[1],_=(0,r.useRef)(null),b=v((0,r.useState)(!1),2),D=b[0],w=b[1],k=(0,r.useRef)(null),x=Array.isArray(t),C=Array.isArray(t)?t:void 0,E=p&&x&&!(null===C||void 0===C||!C.length),S=(0,r.useMemo)((function(){return D?g:Array.isArray(t)?"":t}),[t,g,D,x]),A=(0,r.useMemo)((function(){return D?g||"(.+)":""}),[g,D]),N=function(){k.current&&k.current.blur()},M=function(e){d(e),x||(w(!1),N()),x&&k.current&&k.current.focus()},F=function(e){k.current!==e.target&&w(!1)};return(0,r.useEffect)((function(){y(""),D&&k.current&&k.current.focus(),D||N()}),[D,k]),(0,r.useEffect)((function(){f&&k.current&&!p&&k.current.focus()}),[f,k]),(0,r.useEffect)((function(){return window.addEventListener("keyup",F),function(){window.removeEventListener("keyup",F)}}),[]),Lt("div",{className:mr()({"vm-select":!0,"vm-select_dark":h}),children:[Lt("div",{className:"vm-select-input",onClick:function(e){e.target instanceof HTMLInputElement||w((function(e){return!e}))},ref:_,children:[Lt("div",{className:"vm-select-input-content",children:[!(null===C||void 0===C||!C.length)&&Lt(Gf,{values:C,onRemoveItem:M}),!E&&Lt("input",{value:S,type:"text",placeholder:a,onInput:function(e){y(e.target.value)},onFocus:function(){w(!0)},ref:k,readOnly:p||!s})]}),i&&Lt("span",{className:"vm-text-field__label",children:i}),l&&t&&Lt("div",{className:"vm-select-input__icon",onClick:function(e){return function(t){M(e),t.stopPropagation()}}(""),children:Lt(Tn,{})}),Lt("div",{className:mr()({"vm-select-input__icon":!0,"vm-select-input__icon_open":D}),children:Lt($n,{})})]}),Lt(Oc,{label:i,value:A,options:n,anchor:_,selected:C,maxWords:10,minLength:0,fullWidth:!0,noOptionsText:o,onSelect:M,onOpenAutocomplete:w})]})},Zf=Dt.map((function(e){return e.id})),Kf=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]),p=(0,r.useMemo)((function(){return a?"":"No metric names. Please select job"}),[a]),m=Hr().isMobile;return Lt("div",{className:mr()({"vm-explore-metrics-header":!0,"vm-explore-metrics-header_mobile":m,"vm-block":!0,"vm-block_mobile":m}),children:[Lt("div",{className:"vm-explore-metrics-header__job",children:Lt(Jf,{value:a,list:t,label:"Job",placeholder:"Please select job",onChange:c,autofocus:!a,searchable:!0})}),Lt("div",{className:"vm-explore-metrics-header__instance",children:Lt(Jf,{value:o,list:n,label:"Instance",placeholder:"Please select instance",onChange:s,noOptionsText:h,clearable:!0,searchable:!0})}),Lt("div",{className:"vm-explore-metrics-header__size",children:Lt(Jf,{label:"Size graphs",value:u,list:Zf,onChange:d})}),Lt("div",{className:"vm-explore-metrics-header-metrics",children:Lt(Jf,{label:"Metrics",value:l,list:i,placeholder:"Search metric name",onChange:f,noOptionsText:p,clearable:!0,searchable:!0})})]})},Xf=wt("job",""),ed=wt("instance",""),td=wt("metrics",""),nd=wt("size",""),rd=Dt.find((function(e){return nd?e.id===nd:e.isDefault}))||Dt[0],id=function(){var e=v((0,r.useState)(Xf),2),t=e[0],n=e[1],i=v((0,r.useState)(ed),2),a=i[0],o=i[1],u=v((0,r.useState)(td?td.split("&"):[]),2),l=u[0],c=u[1],s=v((0,r.useState)(rd),2),f=s[0],d=s[1];!function(e){var t=e.job,n=e.instance,i=e.metrics,a=e.size,o=wn(),u=o.duration,l=o.relativeTime,c=o.period.date,s=Lr().customStep,f=v(nt(),2)[1],d=function(){var e,r=as((it(e={},"g0.range_input",u),it(e,"g0.end_input",c),it(e,"g0.step_input",s),it(e,"g0.relative_time",l),it(e,"size",a),it(e,"job",t),it(e,"instance",n),it(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=Bt().serverUrl,t=wn().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=Wi(Ui().mark((function e(){var t,n,r;return Ui().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}}(),p=h.jobs,m=h.isLoading,g=h.error,y=Vf(t),b=y.instances,D=y.isLoading,w=y.error,k=Uf(t,a),x=k.names,C=k.isLoading,E=k.error,S=(0,r.useMemo)((function(){return m||D||C}),[m,D,C]),A=(0,r.useMemo)((function(){return g||w||E}),[g,w,E]),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]),Lt("div",{className:"vm-explore-metrics",children:[Lt(Kf,{jobs:p,instances:b,names:x,job:t,size:f.id,instance:a,selectedMetrics:l,onChangeJob:n,onChangeSize:function(e){var t=Dt.find((function(t){return t.id===e}));t&&d(t)},onChangeInstance:o,onToggleMetric:N}),S&&Lt(Jc,{}),A&&Lt(Vr,{variant:"error",children:A}),!t&&Lt(Vr,{variant:"info",children:"Please select job to see list of metric names."}),t&&!l.length&&Lt(Vr,{variant:"info",children:"Please select metric names to see the graphs."}),Lt("div",{className:"vm-explore-metrics-body",children:l.map((function(e,n){return Lt(Qf,{name:e,job:t,instance:a,index:n,length:l.length,size:f,onRemoveItem:N,onChangeOrder:M},e)}))})]})},ad=function(){var t=qr().showInfoMessage,n=function(e){return function(){var n;n=e,navigator.clipboard.writeText("<".concat(n,"/>")),t({text:"<".concat(n,"/> has been copied"),type:"success"})}};return Lt("div",{className:"vm-preview-icons",children:Object.entries(e).map((function(e){var t=v(e,2),r=t[0],i=t[1];return Lt("div",{className:"vm-preview-icons-item",onClick:n(r),children:[Lt("div",{className:"vm-preview-icons-item__svg",children:i()}),Lt("div",{className:"vm-preview-icons-item__name",children:"<".concat(r,"/>")})]},r)}))})},od=function(){var e=v((0,r.useState)(!1),2),t=e[0],n=e[1];return Lt(Ot.HY,{children:Lt(Ze,{children:Lt(Zr,{children:Lt(Ot.HY,{children:[Lt(jf,{onLoaded:n}),t&&Lt(Ye,{children:Lt($e,{path:"/",element:Lt(na,{}),children:[Lt($e,{path:dt.home,element:Lt(ys,{})}),Lt($e,{path:dt.metrics,element:Lt(id,{})}),Lt($e,{path:dt.cardinality,element:Lt(Ff,{})}),Lt($e,{path:dt.topQueries,element:Lt(If,{})}),Lt($e,{path:dt.trace,element:Lt(Yf,{})}),Lt($e,{path:dt.dashboards,element:Lt(of,{})}),Lt($e,{path:dt.icons,element:Lt(ad,{})})]})})]})})})})},ud=function(e){e&&n.e(27).then(n.bind(n,27)).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)}))},ld=document.getElementById("root");ld&&(0,r.render)(Lt(od,{}),ld),ud()}()}();
\ No newline at end of file
diff --git a/app/vmselect/vmui/static/js/main.ee50e2ce.js.LICENSE.txt b/app/vmselect/vmui/static/js/main.22a4d00b.js.LICENSE.txt
similarity index 100%
rename from app/vmselect/vmui/static/js/main.ee50e2ce.js.LICENSE.txt
rename to app/vmselect/vmui/static/js/main.22a4d00b.js.LICENSE.txt
diff --git a/app/vmui/packages/vmui/src/components/Chart/ChartTooltipHeatmap/ChartTooltipHeatmap.tsx b/app/vmui/packages/vmui/src/components/Chart/Heatmap/ChartTooltipHeatmap/ChartTooltipHeatmap.tsx
similarity index 88%
rename from app/vmui/packages/vmui/src/components/Chart/ChartTooltipHeatmap/ChartTooltipHeatmap.tsx
rename to app/vmui/packages/vmui/src/components/Chart/Heatmap/ChartTooltipHeatmap/ChartTooltipHeatmap.tsx
index 6e5d2dd587..3cfeb5a355 100644
--- a/app/vmui/packages/vmui/src/components/Chart/ChartTooltipHeatmap/ChartTooltipHeatmap.tsx
+++ b/app/vmui/packages/vmui/src/components/Chart/Heatmap/ChartTooltipHeatmap/ChartTooltipHeatmap.tsx
@@ -1,18 +1,17 @@
import React, { FC, useEffect, useMemo, useRef, useState } from "preact/compat";
import uPlot from "uplot";
import ReactDOM from "react-dom";
-import Button from "../../Main/Button/Button";
-import { CloseIcon, DragIcon } from "../../Main/Icons";
+import Button from "../../../Main/Button/Button";
+import { CloseIcon, DragIcon } from "../../../Main/Icons";
import classNames from "classnames";
import { MouseEvent as ReactMouseEvent } from "react";
-import "../ChartTooltip/style.scss";
+import "../../Line/ChartTooltip/style.scss";
export interface TooltipHeatmapProps {
cursor: {left: number, top: number}
startDate: string,
endDate: string,
- metricName: string,
- fields: string[],
+ bucket: string,
value: number,
valueFormat: string
}
@@ -36,8 +35,7 @@ const ChartTooltipHeatmap: FC = ({
onClose,
startDate,
endDate,
- metricName,
- fields,
+ bucket,
valueFormat,
value
}) => {
@@ -141,18 +139,12 @@ const ChartTooltipHeatmap: FC = ({
- {metricName}:
- {valueFormat}
- {unit}
+ value: {valueFormat}{unit}
- {!!fields.length && (
-
- {fields.map((f, i) => (
-
{f}
- ))}
-
- )}
+
+ {bucket}
+
), targetPortal);
};
diff --git a/app/vmui/packages/vmui/src/components/Chart/HeatmapChart/HeatmapChart.tsx b/app/vmui/packages/vmui/src/components/Chart/Heatmap/HeatmapChart/HeatmapChart.tsx
similarity index 89%
rename from app/vmui/packages/vmui/src/components/Chart/HeatmapChart/HeatmapChart.tsx
rename to app/vmui/packages/vmui/src/components/Chart/Heatmap/HeatmapChart/HeatmapChart.tsx
index 8f7cbc179e..cdbe20fc58 100644
--- a/app/vmui/packages/vmui/src/components/Chart/HeatmapChart/HeatmapChart.tsx
+++ b/app/vmui/packages/vmui/src/components/Chart/Heatmap/HeatmapChart/HeatmapChart.tsx
@@ -4,21 +4,21 @@ import uPlot, {
Options as uPlotOptions,
Range
} from "uplot";
-import { defaultOptions, sizeAxis } from "../../../utils/uplot/helpers";
-import { dragChart } from "../../../utils/uplot/events";
-import { getAxes } from "../../../utils/uplot/axes";
-import { MetricResult } from "../../../api/types";
-import { dateFromSeconds, formatDateForNativeInput, limitsDurations } from "../../../utils/time";
+import { defaultOptions, sizeAxis } from "../../../../utils/uplot/helpers";
+import { dragChart } from "../../../../utils/uplot/events";
+import { getAxes } from "../../../../utils/uplot/axes";
+import { MetricResult } from "../../../../api/types";
+import { dateFromSeconds, formatDateForNativeInput, limitsDurations } from "../../../../utils/time";
import throttle from "lodash.throttle";
-import useResize from "../../../hooks/useResize";
-import { TimeParams } from "../../../types";
-import { YaxisState } from "../../../state/graph/reducer";
+import useResize from "../../../../hooks/useResize";
+import { TimeParams } from "../../../../types";
+import { YaxisState } from "../../../../state/graph/reducer";
import "uplot/dist/uPlot.min.css";
import classNames from "classnames";
import dayjs from "dayjs";
-import { useAppState } from "../../../state/common/StateContext";
-import { heatmapPaths } from "../../../utils/uplot/heatmap";
-import { DATE_FULL_TIMEZONE_FORMAT } from "../../../constants/date";
+import { useAppState } from "../../../../state/common/StateContext";
+import { heatmapPaths } from "../../../../utils/uplot/heatmap";
+import { DATE_FULL_TIMEZONE_FORMAT } from "../../../../constants/date";
import ChartTooltipHeatmap, {
ChartTooltipHeatmapProps,
TooltipHeatmapProps
@@ -33,7 +33,7 @@ export interface HeatmapChartProps {
setPeriod: ({ from, to }: {from: Date, to: Date}) => void;
container: HTMLDivElement | null;
height?: number;
- onChangeLegend: (val: number) => void;
+ onChangeLegend: (val: TooltipHeatmapProps) => void;
}
enum typeChartUpdate {xRange = "xRange", yRange = "yRange"}
@@ -62,7 +62,7 @@ const HeatmapChart: FC = ({
const [tooltipOffset, setTooltipOffset] = useState({ left: 0, top: 0 });
const [stickyTooltips, setStickyToolTips] = useState([]);
const tooltipId = useMemo(() => {
- return `${tooltipProps?.fields.join(",")}_${tooltipProps?.startDate}`;
+ return `${tooltipProps?.bucket}_${tooltipProps?.startDate}`;
}, [tooltipProps]);
const setScale = ({ min, max }: { min: number, max: number }): void => {
@@ -135,7 +135,7 @@ const HeatmapChart: FC = ({
const handleClick = () => {
if (!tooltipProps) return;
- const id = `${tooltipProps?.fields.join(",")}_${tooltipProps?.startDate}`;
+ const id = `${tooltipProps?.bucket}_${tooltipProps?.startDate}`;
const props = {
id,
unit,
@@ -171,12 +171,6 @@ const HeatmapChart: FC = ({
return;
}
- const metric = result?.metric;
- const metricName = metric["__name__"] || "value";
-
- const labelNames = Object.keys(metric).filter(x => x != "__name__");
- const fields = labelNames.map(key => `${key}=${JSON.stringify(metric[key])}`);
-
const [endTime = 0, value = ""] = result.values.find(v => v[0] === second) || [];
const valueFormat = `${+value}%`;
const startTime = xArr[xIdx];
@@ -187,8 +181,7 @@ const HeatmapChart: FC = ({
cursor: { left, top },
startDate,
endDate,
- metricName,
- fields,
+ bucket: result?.metric?.vmrange || "",
value: +value,
valueFormat: valueFormat,
});
@@ -228,7 +221,7 @@ const HeatmapChart: FC = ({
font: axes[0].font,
size: sizeAxis,
splits: metrics.map((m, i) => i),
- values: metrics.map(m => Object.entries(m.metric).map(e => `${e[0]}=${JSON.stringify(e[1])}`)[0]),
+ values: metrics.map(m => m.metric.vmrange),
}
],
scales: {
@@ -339,7 +332,7 @@ const HeatmapChart: FC = ({
}, [tooltipProps, stickyTooltips]);
useEffect(() => {
- onChangeLegend(tooltipProps?.value || 0);
+ if (tooltipProps) onChangeLegend(tooltipProps);
}, [tooltipProps]);
return (
diff --git a/app/vmui/packages/vmui/src/components/Chart/Heatmap/LegendHeatmap/LegendHeatmap.tsx b/app/vmui/packages/vmui/src/components/Chart/Heatmap/LegendHeatmap/LegendHeatmap.tsx
new file mode 100644
index 0000000000..97824cb3f8
--- /dev/null
+++ b/app/vmui/packages/vmui/src/components/Chart/Heatmap/LegendHeatmap/LegendHeatmap.tsx
@@ -0,0 +1,68 @@
+import React, { FC, useEffect, useState } from "preact/compat";
+import { gradMetal16 } from "../../../../utils/uplot/heatmap";
+import "./style.scss";
+import { TooltipHeatmapProps } from "../ChartTooltipHeatmap/ChartTooltipHeatmap";
+import { SeriesItem } from "../../../../utils/uplot/series";
+import LegendItem from "../../Line/Legend/LegendItem/LegendItem";
+import { LegendItemType } from "../../../../utils/uplot/types";
+
+interface LegendHeatmapProps {
+ min: number
+ max: number
+ legendValue: TooltipHeatmapProps | null,
+ series: SeriesItem[]
+}
+
+const LegendHeatmap: FC = (
+ {
+ min,
+ max,
+ legendValue,
+ series,
+ }
+) => {
+
+ const [percent, setPercent] = useState(0);
+ const [valueFormat, setValueFormat] = useState("");
+ const [minFormat, setMinFormat] = useState("");
+ const [maxFormat, setMaxFormat] = useState("");
+
+ useEffect(() => {
+ const value = legendValue?.value || 0;
+ setPercent(value ? (value - min) / (max - min) * 100 : 0);
+ setValueFormat(value ? `${value}%` : "");
+ setMinFormat(`${min}%`);
+ setMaxFormat(`${max}%`);
+ }, [legendValue, min, max]);
+
+ return (
+
+
+
+ {!!legendValue?.value && (
+
+ {valueFormat}
+
+ )}
+
+
{minFormat}
+
{maxFormat}
+
+ {series[1] && (
+
+ )}
+
+ );
+};
+
+export default LegendHeatmap;
diff --git a/app/vmui/packages/vmui/src/components/Chart/LegendHeatmap/style.scss b/app/vmui/packages/vmui/src/components/Chart/Heatmap/LegendHeatmap/style.scss
similarity index 86%
rename from app/vmui/packages/vmui/src/components/Chart/LegendHeatmap/style.scss
rename to app/vmui/packages/vmui/src/components/Chart/Heatmap/LegendHeatmap/style.scss
index acba34f2bb..359dda224c 100644
--- a/app/vmui/packages/vmui/src/components/Chart/LegendHeatmap/style.scss
+++ b/app/vmui/packages/vmui/src/components/Chart/Heatmap/LegendHeatmap/style.scss
@@ -7,6 +7,14 @@
justify-content: space-between;
gap: 4px;
+ &__wrapper {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: $padding-global;
+ flex-wrap: wrap;
+ }
+
&__value {
color: $color-text;
font-size: $font-size-small;
@@ -52,4 +60,8 @@
}
}
}
+
+ &__labels {
+ word-break: break-all;
+ }
}
diff --git a/app/vmui/packages/vmui/src/components/Chart/LegendHeatmap/LegendHeatmap.tsx b/app/vmui/packages/vmui/src/components/Chart/LegendHeatmap/LegendHeatmap.tsx
deleted file mode 100644
index 4747331c63..0000000000
--- a/app/vmui/packages/vmui/src/components/Chart/LegendHeatmap/LegendHeatmap.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import React, { FC, useEffect, useState } from "preact/compat";
-import { gradMetal16 } from "../../../utils/uplot/heatmap";
-import "./style.scss";
-
-interface LegendHeatmapProps {
- min: number
- max: number
- value?: number
-}
-
-const LegendHeatmap: FC = ({ min, max, value }) => {
-
- const [percent, setPercent] = useState(0);
- const [valueFormat, setValueFormat] = useState("");
- const [minFormat, setMinFormat] = useState("");
- const [maxFormat, setMaxFormat] = useState("");
-
- useEffect(() => {
- setPercent(value ? (value - min) / (max - min) * 100 : 0);
- setValueFormat(value ? `${value}%` : "");
- setMinFormat(`${min}%`);
- setMaxFormat(`${max}%`);
- }, [value, min, max]);
-
- return (
-
-
- {!!value && (
-
- {valueFormat}
-
- )}
-
-
{minFormat}
-
{maxFormat}
-
- );
-};
-
-export default LegendHeatmap;
diff --git a/app/vmui/packages/vmui/src/components/Chart/ChartTooltip/ChartTooltip.tsx b/app/vmui/packages/vmui/src/components/Chart/Line/ChartTooltip/ChartTooltip.tsx
similarity index 93%
rename from app/vmui/packages/vmui/src/components/Chart/ChartTooltip/ChartTooltip.tsx
rename to app/vmui/packages/vmui/src/components/Chart/Line/ChartTooltip/ChartTooltip.tsx
index d69a99da7b..23c2a434a3 100644
--- a/app/vmui/packages/vmui/src/components/Chart/ChartTooltip/ChartTooltip.tsx
+++ b/app/vmui/packages/vmui/src/components/Chart/Line/ChartTooltip/ChartTooltip.tsx
@@ -1,17 +1,17 @@
import React, { FC, useEffect, useMemo, useRef, useState } from "preact/compat";
import uPlot from "uplot";
-import { MetricResult } from "../../../api/types";
-import { formatPrettyNumber } from "../../../utils/uplot/helpers";
+import { MetricResult } from "../../../../api/types";
+import { formatPrettyNumber } from "../../../../utils/uplot/helpers";
import dayjs from "dayjs";
-import { DATE_FULL_TIMEZONE_FORMAT } from "../../../constants/date";
+import { DATE_FULL_TIMEZONE_FORMAT } from "../../../../constants/date";
import ReactDOM from "react-dom";
import get from "lodash.get";
-import Button from "../../Main/Button/Button";
-import { CloseIcon, DragIcon } from "../../Main/Icons";
+import Button from "../../../Main/Button/Button";
+import { CloseIcon, DragIcon } from "../../../Main/Icons";
import classNames from "classnames";
import { MouseEvent as ReactMouseEvent } from "react";
import "./style.scss";
-import { SeriesItem } from "../../../utils/uplot/series";
+import { SeriesItem } from "../../../../utils/uplot/series";
export interface ChartTooltipProps {
id: string,
diff --git a/app/vmui/packages/vmui/src/components/Chart/ChartTooltip/style.scss b/app/vmui/packages/vmui/src/components/Chart/Line/ChartTooltip/style.scss
similarity index 98%
rename from app/vmui/packages/vmui/src/components/Chart/ChartTooltip/style.scss
rename to app/vmui/packages/vmui/src/components/Chart/Line/ChartTooltip/style.scss
index 891bd3125d..e924130d5c 100644
--- a/app/vmui/packages/vmui/src/components/Chart/ChartTooltip/style.scss
+++ b/app/vmui/packages/vmui/src/components/Chart/Line/ChartTooltip/style.scss
@@ -78,5 +78,6 @@ $chart-tooltip-y: -1 * ($padding-small + $chart-tooltip-half-icon);
display: grid;
grid-gap: 4px;
word-break: break-all;
+ white-space: pre-wrap;
}
}
diff --git a/app/vmui/packages/vmui/src/components/Chart/Legend/Legend.tsx b/app/vmui/packages/vmui/src/components/Chart/Line/Legend/Legend.tsx
similarity index 92%
rename from app/vmui/packages/vmui/src/components/Chart/Legend/Legend.tsx
rename to app/vmui/packages/vmui/src/components/Chart/Line/Legend/Legend.tsx
index 6cdc476327..9cdffff432 100644
--- a/app/vmui/packages/vmui/src/components/Chart/Legend/Legend.tsx
+++ b/app/vmui/packages/vmui/src/components/Chart/Line/Legend/Legend.tsx
@@ -1,7 +1,7 @@
import React, { FC, useMemo } from "preact/compat";
-import { LegendItemType } from "../../../utils/uplot/types";
+import { LegendItemType } from "../../../../utils/uplot/types";
import LegendItem from "./LegendItem/LegendItem";
-import Accordion from "../../Main/Accordion/Accordion";
+import Accordion from "../../../Main/Accordion/Accordion";
import "./style.scss";
interface LegendProps {
diff --git a/app/vmui/packages/vmui/src/components/Chart/Legend/LegendItem/LegendItem.tsx b/app/vmui/packages/vmui/src/components/Chart/Line/Legend/LegendItem/LegendItem.tsx
similarity index 68%
rename from app/vmui/packages/vmui/src/components/Chart/Legend/LegendItem/LegendItem.tsx
rename to app/vmui/packages/vmui/src/components/Chart/Line/Legend/LegendItem/LegendItem.tsx
index 813f5933c3..ebc080825d 100644
--- a/app/vmui/packages/vmui/src/components/Chart/Legend/LegendItem/LegendItem.tsx
+++ b/app/vmui/packages/vmui/src/components/Chart/Line/Legend/LegendItem/LegendItem.tsx
@@ -1,19 +1,23 @@
import React, { FC, useState, useMemo } from "preact/compat";
import { MouseEvent } from "react";
-import { LegendItemType } from "../../../../utils/uplot/types";
+import { LegendItemType } from "../../../../../utils/uplot/types";
import "./style.scss";
import classNames from "classnames";
-import Tooltip from "../../../Main/Tooltip/Tooltip";
+import Tooltip from "../../../../Main/Tooltip/Tooltip";
import { getFreeFields } from "./helpers";
interface LegendItemProps {
legend: LegendItemType;
- onChange: (item: LegendItemType, metaKey: boolean) => void;
+ onChange?: (item: LegendItemType, metaKey: boolean) => void;
+ isHeatmap?: boolean;
}
-const LegendItem: FC = ({ legend, onChange }) => {
+const LegendItem: FC = ({ legend, onChange, isHeatmap }) => {
const [copiedValue, setCopiedValue] = useState("");
- const freeFormFields = useMemo(() => getFreeFields(legend), [legend]);
+ const freeFormFields = useMemo(() => {
+ const result = getFreeFields(legend);
+ return isHeatmap ? result.filter(f => f.key !== "vmrange") : result;
+ }, [legend, isHeatmap]);
const calculations = legend.calculations;
const showCalculations = Object.values(calculations).some(v => v);
@@ -24,7 +28,7 @@ const LegendItem: FC = ({ legend, onChange }) => {
};
const createHandlerClick = (legend: LegendItemType) => (e: MouseEvent) => {
- onChange(legend, e.ctrlKey || e.metaKey);
+ onChange && onChange(legend, e.ctrlKey || e.metaKey);
};
const createHandlerCopy = (freeField: string, id: string) => (e: MouseEvent) => {
@@ -37,18 +41,21 @@ const LegendItem: FC = ({ legend, onChange }) => {
className={classNames({
"vm-legend-item": true,
"vm-legend-row": true,
- "vm-legend-item_hide": !legend.checked,
+ "vm-legend-item_hide": !legend.checked && !isHeatmap,
+ "vm-legend-item_static": isHeatmap,
})}
onClick={createHandlerClick(legend)}
>
-
+ {!isHeatmap && (
+
+ )}
{legend.freeFormFields["__name__"]}
- {
+ {!!freeFormFields.length && <>{>}
{freeFormFields.map((f, i) => (
= ({ legend, onChange }) => {
))}
- }
+ {!!freeFormFields.length && <>}>}
- {showCalculations && (
+ {!isHeatmap && showCalculations && (
median:{calculations.median}, min:{calculations.min}, max:{calculations.max}, last:{calculations.last}
diff --git a/app/vmui/packages/vmui/src/components/Chart/Legend/LegendItem/helpers.ts b/app/vmui/packages/vmui/src/components/Chart/Line/Legend/LegendItem/helpers.ts
similarity index 84%
rename from app/vmui/packages/vmui/src/components/Chart/Legend/LegendItem/helpers.ts
rename to app/vmui/packages/vmui/src/components/Chart/Line/Legend/LegendItem/helpers.ts
index 53e6bed59d..6fed3c686c 100644
--- a/app/vmui/packages/vmui/src/components/Chart/Legend/LegendItem/helpers.ts
+++ b/app/vmui/packages/vmui/src/components/Chart/Line/Legend/LegendItem/helpers.ts
@@ -1,4 +1,4 @@
-import { LegendItemType } from "../../../../utils/uplot/types";
+import { LegendItemType } from "../../../../../utils/uplot/types";
export const getFreeFields = (legend: LegendItemType) => {
const keys = Object.keys(legend.freeFormFields).filter(f => f !== "__name__");
diff --git a/app/vmui/packages/vmui/src/components/Chart/Legend/LegendItem/style.scss b/app/vmui/packages/vmui/src/components/Chart/Line/Legend/LegendItem/style.scss
similarity index 84%
rename from app/vmui/packages/vmui/src/components/Chart/Legend/LegendItem/style.scss
rename to app/vmui/packages/vmui/src/components/Chart/Line/Legend/LegendItem/style.scss
index 4e32bc26f6..7c5e2ed1bc 100644
--- a/app/vmui/packages/vmui/src/components/Chart/Legend/LegendItem/style.scss
+++ b/app/vmui/packages/vmui/src/components/Chart/Line/Legend/LegendItem/style.scss
@@ -21,6 +21,17 @@
opacity: 0.5;
}
+ &_static {
+ grid-template-columns: 1fr;
+ margin: 0;
+ padding: 0;
+ cursor: default;
+
+ &:hover {
+ background-color: $color-background-block;
+ }
+ }
+
&__marker {
width: 14px;
height: 14px;
diff --git a/app/vmui/packages/vmui/src/components/Chart/Legend/style.scss b/app/vmui/packages/vmui/src/components/Chart/Line/Legend/style.scss
similarity index 100%
rename from app/vmui/packages/vmui/src/components/Chart/Legend/style.scss
rename to app/vmui/packages/vmui/src/components/Chart/Line/Legend/style.scss
diff --git a/app/vmui/packages/vmui/src/components/Chart/LineChart/LineChart.tsx b/app/vmui/packages/vmui/src/components/Chart/Line/LineChart/LineChart.tsx
similarity index 94%
rename from app/vmui/packages/vmui/src/components/Chart/LineChart/LineChart.tsx
rename to app/vmui/packages/vmui/src/components/Chart/Line/LineChart/LineChart.tsx
index f3e41ac55e..7fab79c11e 100644
--- a/app/vmui/packages/vmui/src/components/Chart/LineChart/LineChart.tsx
+++ b/app/vmui/packages/vmui/src/components/Chart/Line/LineChart/LineChart.tsx
@@ -7,22 +7,22 @@ import uPlot, {
Scales,
Scale,
} from "uplot";
-import { defaultOptions } from "../../../utils/uplot/helpers";
-import { dragChart } from "../../../utils/uplot/events";
-import { getAxes, getMinMaxBuffer } from "../../../utils/uplot/axes";
-import { MetricResult } from "../../../api/types";
-import { dateFromSeconds, formatDateForNativeInput, limitsDurations } from "../../../utils/time";
+import { defaultOptions } from "../../../../utils/uplot/helpers";
+import { dragChart } from "../../../../utils/uplot/events";
+import { getAxes, getMinMaxBuffer } from "../../../../utils/uplot/axes";
+import { MetricResult } from "../../../../api/types";
+import { dateFromSeconds, formatDateForNativeInput, limitsDurations } from "../../../../utils/time";
import throttle from "lodash.throttle";
-import useResize from "../../../hooks/useResize";
-import { TimeParams } from "../../../types";
-import { YaxisState } from "../../../state/graph/reducer";
+import useResize from "../../../../hooks/useResize";
+import { TimeParams } from "../../../../types";
+import { YaxisState } from "../../../../state/graph/reducer";
import "uplot/dist/uPlot.min.css";
import "./style.scss";
import classNames from "classnames";
import ChartTooltip, { ChartTooltipProps } from "../ChartTooltip/ChartTooltip";
import dayjs from "dayjs";
-import { useAppState } from "../../../state/common/StateContext";
-import { SeriesItem } from "../../../utils/uplot/series";
+import { useAppState } from "../../../../state/common/StateContext";
+import { SeriesItem } from "../../../../utils/uplot/series";
export interface LineChartProps {
metrics: MetricResult[];
diff --git a/app/vmui/packages/vmui/src/components/Chart/LineChart/style.scss b/app/vmui/packages/vmui/src/components/Chart/Line/LineChart/style.scss
similarity index 100%
rename from app/vmui/packages/vmui/src/components/Chart/LineChart/style.scss
rename to app/vmui/packages/vmui/src/components/Chart/Line/LineChart/style.scss
diff --git a/app/vmui/packages/vmui/src/components/Views/GraphView/GraphView.tsx b/app/vmui/packages/vmui/src/components/Views/GraphView/GraphView.tsx
index d5d6165f1c..cdd95003d1 100644
--- a/app/vmui/packages/vmui/src/components/Views/GraphView/GraphView.tsx
+++ b/app/vmui/packages/vmui/src/components/Views/GraphView/GraphView.tsx
@@ -1,10 +1,10 @@
import React, { FC, useCallback, useEffect, useMemo, useRef, useState } from "preact/compat";
import { MetricResult } from "../../../api/types";
-import LineChart from "../../Chart/LineChart/LineChart";
+import LineChart from "../../Chart/Line/LineChart/LineChart";
import { AlignedData as uPlotData, Series as uPlotSeries } from "uplot";
-import Legend from "../../Chart/Legend/Legend";
-import LegendHeatmap from "../../Chart/LegendHeatmap/LegendHeatmap";
-import { getHideSeries, getLegendItem, getSeriesItemContext } from "../../../utils/uplot/series";
+import Legend from "../../Chart/Line/Legend/Legend";
+import LegendHeatmap from "../../Chart/Heatmap/LegendHeatmap/LegendHeatmap";
+import { getHideSeries, getLegendItem, getSeriesItemContext, SeriesItem } from "../../../utils/uplot/series";
import { getLimitsYAxis, getMinMaxBuffer, getTimeSeries } from "../../../utils/uplot/axes";
import { LegendItemType } from "../../../utils/uplot/types";
import { TimeParams } from "../../../types";
@@ -12,11 +12,12 @@ import { AxisRange, YaxisState } from "../../../state/graph/reducer";
import { getAvgFromArray, getMaxFromArray, getMinFromArray } from "../../../utils/math";
import classNames from "classnames";
import { useTimeState } from "../../../state/time/TimeStateContext";
-import HeatmapChart from "../../Chart/HeatmapChart/HeatmapChart";
+import HeatmapChart from "../../Chart/Heatmap/HeatmapChart/HeatmapChart";
import "./style.scss";
import { promValueToNumber } from "../../../utils/metric";
import { normalizeData } from "../../../utils/uplot/heatmap";
import useDeviceDetect from "../../../hooks/useDeviceDetect";
+import { TooltipHeatmapProps } from "../../Chart/Heatmap/ChartTooltipHeatmap/ChartTooltipHeatmap";
export interface GraphViewProps {
data?: MetricResult[];
@@ -60,7 +61,7 @@ const GraphView: FC = ({
const [series, setSeries] = useState([]);
const [legend, setLegend] = useState([]);
const [hideSeries, setHideSeries] = useState([]);
- const [legendValue, setLegendValue] = useState(0);
+ const [legendValue, setLegendValue] = useState(null);
const setLimitsYaxis = (values: {[key: string]: number[]}) => {
const limits = getLimitsYAxis(values, !isHistogram);
@@ -71,7 +72,7 @@ const GraphView: FC = ({
setHideSeries(getHideSeries({ hideSeries, legend, metaKey, series }));
};
- const handleChangeLegend = (val: number) => {
+ const handleChangeLegend = (val: TooltipHeatmapProps) => {
setLegendValue(val);
};
@@ -209,9 +210,10 @@ const GraphView: FC = ({
)}
{isHistogram && showLegend && (
)}
diff --git a/app/vmui/packages/vmui/src/hooks/useFetchQuery.ts b/app/vmui/packages/vmui/src/hooks/useFetchQuery.ts
index 5c9dcf2c59..9fdb97a552 100644
--- a/app/vmui/packages/vmui/src/hooks/useFetchQuery.ts
+++ b/app/vmui/packages/vmui/src/hooks/useFetchQuery.ts
@@ -79,7 +79,7 @@ export const useFetchQuery = ({
setFetchQueue([...fetchQueue, controller]);
try {
const isDisplayChart = displayType === "chart";
- const seriesLimit = showAllSeries ? Infinity : (+stateSeriesLimits[displayType] || Infinity);
+ let seriesLimit = showAllSeries ? Infinity : (+stateSeriesLimits[displayType] || Infinity);
const tempData: MetricBase[] = [];
const tempTraces: Trace[] = [];
let counter = 1;
@@ -104,6 +104,8 @@ export const useFetchQuery = ({
tempTraces.push(trace);
}
+ const isHistogramResult = isDisplayChart && isHistogramData(resp.data.result);
+ if (isHistogramResult) seriesLimit = Infinity;
const freeTempSize = seriesLimit - tempData.length;
resp.data.result.slice(0, freeTempSize).forEach((d: MetricBase) => {
d.group = counter;
diff --git a/app/vmui/packages/vmui/src/utils/metric.ts b/app/vmui/packages/vmui/src/utils/metric.ts
index f24e47e7d4..90ec03ab91 100644
--- a/app/vmui/packages/vmui/src/utils/metric.ts
+++ b/app/vmui/packages/vmui/src/utils/metric.ts
@@ -31,14 +31,13 @@ export const promValueToNumber = (s: string): number => {
export const isHistogramData = (result: MetricBase[]) => {
if (result.length < 2) return false;
- const histogramNames = ["le", "vmrange"];
+ const histogramLabels = ["le", "vmrange"];
- return result.every(r => {
- const keys = Object.keys(r.metric);
- const labels = Object.keys(r.metric).filter(n => !histogramNames.includes(n));
- const byName = keys.length > labels.length;
- const byLabels = labels.every(l => r.metric[l] === result[0].metric[l]);
-
- return byName && byLabels;
+ const firstLabels = Object.keys(result[0].metric).filter(n => !histogramLabels.includes(n));
+ const isHistogram = result.every(r => {
+ const labels = Object.keys(r.metric).filter(n => !histogramLabels.includes(n));
+ return firstLabels.length === labels.length && labels.every(l => r.metric[l] === result[0].metric[l]);
});
+
+ return isHistogram && result.every(r => histogramLabels.some(l => l in r.metric));
};
diff --git a/app/vmui/packages/vmui/src/utils/uplot/heatmap.ts b/app/vmui/packages/vmui/src/utils/uplot/heatmap.ts
index bae189d3a6..fbe8f1e775 100644
--- a/app/vmui/packages/vmui/src/utils/uplot/heatmap.ts
+++ b/app/vmui/packages/vmui/src/utils/uplot/heatmap.ts
@@ -1,6 +1,7 @@
import uPlot from "uplot";
import { generateGradient } from "../color";
import { MetricResult } from "../../api/types";
+import { promValueToNumber } from "../metric";
// 16-color gradient from "rgb(246, 226, 219)" to "rgb(127, 39, 4)"
export const gradMetal16 = generateGradient([246, 226, 219], [127, 39, 4], 16);
@@ -115,11 +116,11 @@ export const convertPrometheusToVictoriaMetrics = (buckets: MetricResult[]): Met
const sortedBuckets = buckets.sort((a,b) => parseFloat(a.metric.le) - parseFloat(b.metric.le));
const group = buckets[0]?.group || 1;
- let prevBucket: MetricResult = { metric: { le: "0" }, values: [], group };
+ let prevBucket: MetricResult = { metric: { le: "" }, values: [], group };
const result: MetricResult[] = [];
for (const bucket of sortedBuckets) {
- const vmrange = `${prevBucket.metric.le}..${bucket.metric.le}`;
+ const vmrange = [prevBucket.metric.le, bucket.metric.le].filter(n => n).join("...");
const values: [number, string][] = [];
for (const [timestamp, value] of bucket.values) {
@@ -135,14 +136,25 @@ export const convertPrometheusToVictoriaMetrics = (buckets: MetricResult[]): Met
return result;
};
+const getUpperBound = (bucket: MetricResult) => {
+ const values = (bucket.metric.vmrange || bucket.metric.le).split("...");
+ return promValueToNumber(values[values.length - 1]);
+};
+
+const sortBucketsByValues = (a: MetricResult, b: MetricResult) => getUpperBound(a) - getUpperBound(b);
+
export const normalizeData = (buckets: MetricResult[], isHistogram?: boolean): MetricResult[] => {
if (!isHistogram) return buckets;
- const vmBuckets = convertPrometheusToVictoriaMetrics(buckets);
+ const sortedBuckets = buckets.sort(sortBucketsByValues);
+ const vmBuckets = convertPrometheusToVictoriaMetrics(sortedBuckets);
const allValues = vmBuckets.map(b => b.values).flat();
return vmBuckets.map(bucket => {
const values = bucket.values.map((v) => {
- const totalHits = allValues.filter(av => av[0] === v[0]).reduce((bucketSum, v) => bucketSum + +v[1], 0);
+ const totalHits = allValues
+ .filter(av => av[0] === v[0])
+ .reduce((bucketSum, v) => bucketSum + +v[1], 0);
+
return [v[0], `${Math.round((+v[1] / totalHits) * 100)}`];
});