-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add metric charts to cluster overview page #971
Add metric charts to cluster overview page #971
Conversation
6e200a7
to
63ae401
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please go over all missing optional chainings to object (obj?.field) to avoid crashes
63ae401
to
f5f9eda
Compare
src/views/clusteroverview/OverviewTab/metric-charts-card/components/ChartCard.scss
Outdated
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/components/ChartCard.tsx
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/components/MetricChart.scss
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/components/MetricChart.tsx
Outdated
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/components/MetricChart.tsx
Outdated
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/utils/hooks/types.ts
Outdated
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/components/MetricChart.tsx
Outdated
Show resolved
Hide resolved
2f6f6d5
to
f016633
Compare
src/views/clusteroverview/OverviewTab/metric-charts-card/components/ChartCard.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this image present either a new cluster that just created the first VM or first VM created in a project scope, and we have only one point of data, maybe it's best to make sure we have 2 points? also I think the single-day trend is a bit confusing, IMO it will be a better idea to name it "Today's trend" instead of "last 1 days' trend", I'd ask Foday about this
src/views/clusteroverview/OverviewTab/metric-charts-card/components/ChartCard.scss
Outdated
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/utils/utils.ts
Outdated
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/utils/hooks/useXAxisTicks.ts
Outdated
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/utils/hooks/utils.ts
Outdated
Show resolved
Hide resolved
|
||
export const getLargestValue = (data: PrometheusValue[]) => { | ||
return data?.reduce((acc, point) => { | ||
const currValue = Number(point?.[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we do something point?.y
instead of point?.[1]
? the 1 can be not clear in the future for other developer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are PrometheusValue
types, which are arrays with two values, so we can't index them like an object. I created a function to make it easier to understand.
src/views/clusteroverview/OverviewTab/metric-charts-card/utils/utils.ts
Outdated
Show resolved
Hide resolved
import { METRICS } from './constants'; | ||
|
||
export const formatCurrentValue = (value: number, metric: string) => { | ||
switch (metric) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we get a sum of VMs that is with a decimal point? if not this function is not really needed,
but if we still need it I think this would look a bit cleaner to this function,
export const formatCurrentValue = (value: number, metric: string): number =>
metric === METRICS.VM ? Math.trunc(value) : value;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote this function when I was using a placeholder query for VMs and forgot to remove it. We don't need it, so I got rid of it.
src/views/clusteroverview/OverviewTab/metric-charts-card/components/MetricChart.scss
Show resolved
Hide resolved
}, | ||
}} | ||
/> | ||
<ChartGroup> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can remove this ChartGroup and everything will stay the same, can you check that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it and it removed the body of the chart.
src/views/clusteroverview/OverviewTab/metric-charts-card/components/MetricChart.tsx
Outdated
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/utils/hooks/useMetricChartData.ts
Outdated
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/utils/hooks/useXAxisTicks.ts
Outdated
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/utils/hooks/useXAxisTicks.ts
Outdated
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/utils/hooks/utils.ts
Outdated
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/utils/utils.ts
Outdated
Show resolved
Hide resolved
f016633
to
d22c12d
Compare
src/utils/i18n.ts
Outdated
@@ -40,3 +40,5 @@ | |||
// t('plugin__kubevirt-plugin~Node') | |||
// t('plugin__kubevirt-plugin~Create a Virtual Machine from a template') | |||
// t('plugin__kubevirt-plugin~Hardware Devices') | |||
// t('plugin__kubevirt-plugin~VMs') | |||
// t('plugin__kubevirt-plugin~vCPU') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do u need it if we can get 't' everywhere we need now? not only as a hook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be a good idea to make a bug for removing this file and adding the function t
we created wherever needed, but in a different PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
src/views/clusteroverview/OverviewTab/metric-charts-card/utils/hooks/useMetricChartData.ts
Outdated
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/utils/hooks/useXAxisTicks.ts
Outdated
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/utils/hooks/useXAxisTicks.ts
Outdated
Show resolved
Hide resolved
src/views/clusteroverview/OverviewTab/metric-charts-card/utils/hooks/useXAxisTicks.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great!
one last comment I added can that can also be in a follow-up PR, let's wait for @metalice to review his comments as well
src/views/clusteroverview/OverviewTab/metric-charts-card/components/ChartCard.scss
Outdated
Show resolved
Hide resolved
d22c12d
to
b08483d
Compare
lgtm from me, @metalice? |
b08483d
to
bc959c7
Compare
/lgtm |
/hold cancel |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: metalice, pcbailey The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/cherry-pick release-4.12 |
@pcbailey: new pull request created: #990 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
📝 Description
This PR replaces the resources inventory card on the cluster overview page with the metric charts card.
Note: The VMs chart in the screenshot below is empty because I was unable to obtain a cluster with the metric present. The metric has been merged to 4.12 and 4.13, but there is no 4.12 build is available at this time that contains that particular commit.
🎥 Screenshot