Skip to content

Commit

Permalink
Merge pull request #1257 from avivtur/no_data_overview_graphs
Browse files Browse the repository at this point in the history
Bug 2183915: "No data available" shows on Virtualization overview metrics chart
  • Loading branch information
openshift-merge-robot committed Apr 18, 2023
2 parents 5ea423e + 8ff6358 commit ed3dfcf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions locales/en/plugin__kubevirt-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,7 @@
"VM": "VM",
"VMI": "VMI",
"VMs": "VMs",
"VMs in this namespace are new, therefore not enough data is collected to display a graph.": "VMs in this namespace are new, therefore not enough data is collected to display a graph.",
"VNC Address": "VNC Address",
"VNC console": "VNC console",
"VNC Port": "VNC Port",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';

import MutedTextSpan from '@kubevirt-utils/components/MutedTextSpan/MutedTextSpan';
import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
import { isEmpty } from '@kubevirt-utils/utils/utils';
import { Bullseye, Card, Grid, GridItem } from '@patternfly/react-core';

import useMetricChartData from '../utils/hooks/useMetricChartData';
Expand Down Expand Up @@ -40,7 +41,15 @@ const ChartCard: React.FC<ChartCardProps> = ({ metric }) => {
</span>
) : (
<Bullseye>
<MutedTextSpan text={t('No data available')} />
<MutedTextSpan
text={
isEmpty(chartData)
? t('No data available')
: t(
'VMs in this namespace are new, therefore not enough data is collected to display a graph.',
)
}
/>
</Bullseye>
)}
</GridItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ const metricQueriesForNamespace = {
[METRICS.VCPU_USAGE]: (namespace) =>
`count(kubevirt_vmi_vcpu_wait_seconds{namespace="${namespace}"})`,
[METRICS.MEMORY]: (namespace) =>
`sum(kubevirt_vmi_memory_available_bytes - kubevirt_vmi_memory_usable_bytes) by (${namespace})`,
[METRICS.STORAGE]: (namespace) => `sum(kubevirt_vmi_filesystem_used_bytes) by (${namespace})`,
`sum by (namespace)(kubevirt_vmi_memory_available_bytes{namespace="${namespace}"} - kubevirt_vmi_memory_usable_bytes{namespace="${namespace}"})`,
[METRICS.STORAGE]: (namespace) =>
`sum by (namespace)(kubevirt_vmi_filesystem_used_bytes{namespace="${namespace}"})`,
};

const metricQueriesForAllNamespaces = {
Expand Down

0 comments on commit ed3dfcf

Please sign in to comment.