Skip to content

Commit

Permalink
feat: update monitor dashboard (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
xigongdaEricyang authored May 25, 2023
1 parent c4d7388 commit 458670e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 20 deletions.
11 changes: 8 additions & 3 deletions src/components/Charts/SpaceChart.less
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@

.disk-info-content {
display: flex;
position: sticky;
top: 0;
background: #fff;
z-index: 10;
}

.disk-th {
Expand Down Expand Up @@ -112,7 +116,7 @@
justify-content: center;
}

.disk-tr-item > div:not(:last-child) {
.disk-tr-item>div:not(:last-child) {
margin-bottom: 20px;
}

Expand Down Expand Up @@ -201,9 +205,10 @@
position: absolute !important;
top: 10px;
right: 70px;

// width: 200px;
> .ant-select-arrow {
>.ant-select-arrow {
margin-top: -8px !important;
color: #000 !important;
}
}
}
2 changes: 1 addition & 1 deletion src/components/DashboardCard/index.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.dashboard-card {
padding: 5px;
min-height: 293px;
// min-height: 293px;
height: 320px;

> .inner {
Expand Down
14 changes: 3 additions & 11 deletions src/components/MetricCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@ import intl from 'react-intl-universal';

import LineCard from '@/components/DashboardCard/LineCard';
import { VALUE_TYPE } from '@/utils/promQL';
import { ILineChartMetric } from '@/utils/interface';
import { ILineChartMetric, PromResultMetric } from '@/utils/interface';
import { asyncBatchQueries } from '@/requests';
import { calcTimeRange, TIME_OPTION_TYPE } from '@/utils/dashboard';
import { getQueryRangeInfo } from '@/utils';

export interface PromResultMetric {
componentType: string;
instance: string;
instanceName: string;
nebula_cluster: string;
__name__: string;
device?: string;
}

interface IProps {
valueType: VALUE_TYPE;
queries: any;
Expand All @@ -43,6 +34,7 @@ const MetricCard = forwardRef((props: IProps, ref) => {
}

const asyncGetMetricData = async (queries) => {
if (queries.length === 0) return;
const curTimeRange = calcTimeRange(timeRange);
const { start, end, step } = getQueryRangeInfo(curTimeRange[0], curTimeRange[1]);
const data: any = await asyncBatchQueries(queries.map(q => ({
Expand Down Expand Up @@ -75,7 +67,7 @@ const MetricCard = forwardRef((props: IProps, ref) => {
<LineCard
data={metricData}
onChangeBrush={props.onChangeBrush}
onRef={(ref)=>{chartRef.current = ref;}}
onRef={(ref) => { chartRef.current = ref; }}
valueType={valueType}
loading={false}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/MachineDashboard/Cards/DiskCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ const DiskCard = forwardRef((props: IProps, ref) => {
const queries: any = [
{
refId: 'diskSize',
query: `node_filesystem_size_bytes{fstype=~"ext.*|xfs",mountpoint !~".*pod.*"${clusterSuffix1}${instanceSuffix}}`
query: `node_filesystem_size_bytes{mountpoint !~".*pod.*"${clusterSuffix1}${instanceSuffix}}`
},
{
refId: 'diskUsed',
query: `node_filesystem_size_bytes{fstype=~"ext.*|xfs",mountpoint !~".*pod.*"${clusterSuffix1}${instanceSuffix}} - node_filesystem_free_bytes{fstype=~"ext.*|xfs",mountpoint !~".*pod.*"${clusterSuffix1}${instanceSuffix}}`
query: `node_filesystem_size_bytes{mountpoint !~".*pod.*"${clusterSuffix1}${instanceSuffix}} - node_filesystem_free_bytes{fstype=~"ext.*|xfs",mountpoint !~".*pod.*"${clusterSuffix1}${instanceSuffix}}`
}
];
const data = await asyncBatchQueries(queries);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ServiceDashboard/ServiceOverview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
import intl from 'react-intl-universal';
import { connect } from 'react-redux';

import { BatchQueryItem, IServiceMetricItem, ServiceName } from '@/utils/interface';
import { BatchQueryItem, IServiceMetricItem, PromResultMetric, ServiceName } from '@/utils/interface';
import ServiceHeader from '@/components/Service/ServiceHeader';
import Icon from '@/components/Icon';
import { AggregationType, TIME_OPTION_TYPE } from '@/utils/dashboard';
import { ServicePanelConfig } from '../defaultPanelConfig';
import MetricCard, { PromResultMetric } from '@/components/MetricCard';
import MetricCard from '@/components/MetricCard';

import styles from './index.module.less';
import { getClusterPrefix } from '@/utils/promQL';
Expand Down
9 changes: 9 additions & 0 deletions src/utils/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,13 @@ export interface MachinePanelConfig {
valueType: VALUE_TYPE;
showIndex?: number;
refIds: string[];
}

export interface PromResultMetric {
componentType: string;
instance: string;
instanceName: string;
nebula_cluster: string;
__name__: string;
device?: string;
}
2 changes: 1 addition & 1 deletion src/utils/promQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const getClusterPrefix = () => {
return 'nebula_cluster';
}

export const diskPararms = 'fstype=~"ext.*|xfs",mountpoint !~".*pod.*"';
export const diskPararms = 'mountpoint !~".*pod.*"';

const getPromqlLabel = (cluster?, device?: string, instance?: string) => {
const clusterSuffix = cluster ? `${getClusterPrefix()} = "${cluster}"` : '';
Expand Down

0 comments on commit 458670e

Please sign in to comment.