Unverified Commit 0b3d323c authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

[Feature][admin,web]support some home overview (#2067)

* support some home overview * support some home overview * format code * format code
parent 7f878326
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.controller;
import org.dinky.assertion.Asserts;
import org.dinky.data.model.HomeResource;
import org.dinky.data.model.JobModelOverview;
import org.dinky.data.model.JobStatusOverView;
import org.dinky.data.model.JobTypeOverView;
import org.dinky.data.result.Result;
import org.dinky.service.HomeService;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@RestController
@RequestMapping("/api/home")
@RequiredArgsConstructor
public class HomeController {
private final HomeService homeService;
/**
* query resource overview
*
* @return {@link Result}<{@link HomeResource}>
*/
@GetMapping("/getResourceOverview")
public Result<HomeResource> getResourceOverview() {
HomeResource resourceOverview = homeService.getResourceOverview();
if (Asserts.isNull(resourceOverview)) {
return Result.failed();
}
return Result.succeed(resourceOverview);
}
/**
* query job status overview
*
* @return {@link Result}<{@link JobStatusOverView}>
*/
@GetMapping("/getJobStatusOverView")
public Result<JobStatusOverView> getJobStatusOverView() {
JobStatusOverView jobStatusOverView = homeService.getJobStatusOverView();
if (Asserts.isNull(jobStatusOverView)) {
return Result.failed();
}
return Result.succeed(jobStatusOverView);
}
/**
* query job type overview
*
* @return {@link Result}<{@link JobTypeOverView}>
*/
@GetMapping("/getJobTypeOverview")
public Result<List<JobTypeOverView>> getJobTypeOverView() {
List<JobTypeOverView> jobTypeOverView = homeService.getJobTypeOverView();
if (Asserts.isNull(jobTypeOverView)) {
return Result.failed();
}
return Result.succeed(jobTypeOverView);
}
/**
* query job model overview , eg: batch: 1, streaming: 2
*
* @return {@link Result}<{@link JobModelOverview}>
*/
@GetMapping("/getJobModelOverview")
public Result<JobModelOverview> getJobModelOverview() {
JobModelOverview jobModelOverview = homeService.getJobModelOverview();
if (Asserts.isNull(jobModelOverview)) {
return Result.failed();
}
return Result.succeed(jobModelOverview);
}
}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.data.model;
import lombok.Data;
@Data
public class HomeResource {
/** flink instance count */
private Integer flinkClusterCount;
/** flink config count */
private Integer flinkConfigCount;
/** data source count */
private Integer dbSourceCount;
/** global var count */
private Integer globalVarCount;
/** alert instance count */
private Integer alertInstanceCount;
/** alert group count */
private Integer alertGroupCount;
/** git project count */
private Integer gitProjectCount;
}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.data.model;
import lombok.Data;
@Data
public class JobModelOverview {
/** BATCH_JOB_COUNT */
private Integer batchJobCount;
/** STREAMING_JOB_COUNT */
private Integer streamingJobCount;
}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.data.model;
import lombok.Data;
@Data
public class JobStatusOverView {
private Integer jobRunningCount;
private Integer jobFinishedCount;
private Integer jobRecoveredCount;
private Integer jobOnlineCount;
private Integer jobOfflineCount;
private Integer jobErrorCount;
}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.data.model;
import lombok.Data;
@Data
public class JobTypeOverView {
/** JOB TYPE eg: FlinkJar Mysql etc. */
private String jobType;
/** JOB TYPE COUNT */
private Integer jobTypeCount;
/** JOB TYPE RATE */
private Double rate;
}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.service;
import org.dinky.data.model.HomeResource;
import org.dinky.data.model.JobModelOverview;
import org.dinky.data.model.JobStatusOverView;
import org.dinky.data.model.JobTypeOverView;
import java.util.List;
public interface HomeService {
/**
* query resource overview
*
* @return {@link HomeResource}
*/
HomeResource getResourceOverview();
/**
* query job status overview
*
* @return {@link JobStatusOverView}
*/
JobStatusOverView getJobStatusOverView();
/**
* query job type overview
*
* @return {@link JobTypeOverView}
*/
List<JobTypeOverView> getJobTypeOverView();
/**
* query job model overview
*
* @return {@link JobModelOverview}
*/
JobModelOverview getJobModelOverview();
}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.service.impl;
import org.dinky.data.model.HomeResource;
import org.dinky.data.model.JobModelOverview;
import org.dinky.data.model.JobStatusOverView;
import org.dinky.data.model.JobTypeOverView;
import org.dinky.data.model.Task;
import org.dinky.service.AlertGroupService;
import org.dinky.service.AlertInstanceService;
import org.dinky.service.ClusterConfigurationService;
import org.dinky.service.ClusterInstanceService;
import org.dinky.service.DataBaseService;
import org.dinky.service.FragmentVariableService;
import org.dinky.service.GitProjectService;
import org.dinky.service.HomeService;
import org.dinky.service.TaskService;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
@Service
@RequiredArgsConstructor
public class HomeServiceImpl implements HomeService {
private final ClusterInstanceService clusterInstanceService;
private final ClusterConfigurationService clusterConfigurationService;
private final DataBaseService dataBaseService;
private final FragmentVariableService fragmentVariableService;
private final GitProjectService gitProjectService;
private final AlertGroupService alertGroupService;
private final AlertInstanceService alertInstanceService;
private final TaskService taskService;
@Override
public HomeResource getResourceOverview() {
HomeResource homeResource = new HomeResource();
homeResource.setFlinkClusterCount(clusterInstanceService.list().size());
homeResource.setFlinkConfigCount(clusterConfigurationService.list().size());
homeResource.setDbSourceCount(dataBaseService.list().size());
homeResource.setGlobalVarCount(fragmentVariableService.list().size());
homeResource.setGitProjectCount(gitProjectService.list().size());
homeResource.setAlertGroupCount(alertGroupService.list().size());
homeResource.setAlertInstanceCount(alertInstanceService.list().size());
return homeResource;
}
@Override
public JobStatusOverView getJobStatusOverView() {
JobStatusOverView jobStatusOverView = new JobStatusOverView();
// todo: query job status
return jobStatusOverView;
}
@Override
public List<JobTypeOverView> getJobTypeOverView() {
List<JobTypeOverView> jobTypeOverViews = new ArrayList<>();
taskService
.list()
.forEach(
task -> {
JobTypeOverView jobTypeOverView = new JobTypeOverView();
jobTypeOverView.setJobType(task.getDialect());
LambdaQueryWrapper<Task> taskLambdaQueryWrapper =
new LambdaQueryWrapper<Task>()
.eq(Task::getDialect, task.getDialect());
List<Task> taskList = taskService.list(taskLambdaQueryWrapper);
jobTypeOverView.setJobTypeCount(taskList.size());
jobTypeOverView.setRate(
taskList.size() * 1D / taskService.list().size());
jobTypeOverViews.add(jobTypeOverView);
});
return jobTypeOverViews;
}
@Override
public JobModelOverview getJobModelOverview() {
JobModelOverview jobModelOverview = new JobModelOverview();
// todo: query job model 1: get job model 2: get job model count
return jobModelOverview;
}
}
...@@ -62,7 +62,7 @@ export default { ...@@ -62,7 +62,7 @@ export default {
'menu.settings.systemlog': 'System Log', 'menu.settings.systemlog': 'System Log',
'menu.settings.process': 'Process List', 'menu.settings.process': 'Process List',
'menu.settings.services': 'Servers List', 'menu.settings.services': 'Servers List',
'menu.metrics': 'Dashboard', 'menu.metrics': 'Metrics',
'menu.about': 'About', 'menu.about': 'About',
'menu.version': 'Version: {version}', 'menu.version': 'Version: {version}',
}; };
...@@ -600,4 +600,14 @@ export default { ...@@ -600,4 +600,14 @@ export default {
'sys.info.logList.tips': 'Click left log file to viewing', 'sys.info.logList.tips': 'Click left log file to viewing',
// metrics
'metrics.filter.60seconds': '60 Seconds',
'metrics.filter.5minutes': '5 Minutes',
'metrics.filter.10minutes': '10 Minutes',
'metrics.filter.1hour': '1 Hours',
'metrics.filter.2hours': '2 Hours',
'metrics.filter.5hours': '5 Hours',
'metrics.filter.custom': 'Custom',
'metrics.filter.custom.range': 'DateTime Range',
}; };
...@@ -602,4 +602,15 @@ export default { ...@@ -602,4 +602,15 @@ export default {
// system info of log // system info of log
'sys.info.logList.tips': '点击左侧日志文件查看', 'sys.info.logList.tips': '点击左侧日志文件查看',
// metrics
'metrics.filter.60seconds': '60秒',
'metrics.filter.5minutes': '5分钟',
'metrics.filter.10minutes': '10分钟',
'metrics.filter.1hour': '1小时',
'metrics.filter.2hours': '2小时',
'metrics.filter.5hours': '5小时',
'metrics.filter.custom': '自定义',
'metrics.filter.custom.range': '日期时间范围',
}; };
...@@ -27,17 +27,35 @@ import { ...@@ -27,17 +27,35 @@ import {
DatabaseIcon, GitIcon, DatabaseIcon, GitIcon,
GlobalVarIcon GlobalVarIcon
} from "@/components/Icons/HomeIcon"; } from "@/components/Icons/HomeIcon";
import {DatabaseTwoTone} from "@ant-design/icons";
import {imgStyle} from "@/pages/Home/constants"; import {imgStyle} from "@/pages/Home/constants";
import CountFormatter from "@/components/CountFormatter"; import CountFormatter from "@/components/CountFormatter";
import {l} from "@/utils/intl"; import {l} from "@/utils/intl";
import {queryDataByParams} from "@/services/BusinessCrud";
import {API_CONSTANTS} from "@/services/constants";
type ResourceView ={
flinkClusterCount: number;
flinkConfigCount: number;
dbSourceCount: number;
globalVarCount: number;
alertInstanceCount: number;
alertGroupCount: number;
gitProjectCount: number;
}
const ResourceView = () => { const ResourceView = () => {
const [responsive, setResponsive] = useState(false); const [responsive, setResponsive] = useState(false);
const [data, setData] = useState<ResourceView>();
useEffect(() => {
queryDataByParams(API_CONSTANTS.GET_RESOURCE_OVERVIEW).then((res) => {
console.log(res);
setData(res);
});
}, [])
return ( return (
<RcResizeObserver <RcResizeObserver
key="resize-observer" key="resize-observer"
...@@ -49,7 +67,7 @@ const ResourceView = () => { ...@@ -49,7 +67,7 @@ const ResourceView = () => {
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: l('home.develop.re.ci'), title: l('home.develop.re.ci'),
value: 2176, value: data?.flinkClusterCount || 0,
icon:<ClusterInstanceIcon style={imgStyle}/>, icon:<ClusterInstanceIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/> formatter: (value)=> <CountFormatter value={Number(value)}/>
}} }}
...@@ -57,7 +75,7 @@ const ResourceView = () => { ...@@ -57,7 +75,7 @@ const ResourceView = () => {
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: l('home.develop.re.cc'), title: l('home.develop.re.cc'),
value: 475, value: data?.flinkConfigCount || 0,
icon: <ClusterConfigIcon style={imgStyle}/>, icon: <ClusterConfigIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/> formatter: (value)=> <CountFormatter value={Number(value)}/>
}} }}
...@@ -67,7 +85,7 @@ const ResourceView = () => { ...@@ -67,7 +85,7 @@ const ResourceView = () => {
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: l('home.develop.re.ds'), title: l('home.develop.re.ds'),
value: 87, value: data?.dbSourceCount || 0,
icon: <DatabaseIcon style={imgStyle}/>, icon: <DatabaseIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/> formatter: (value)=> <CountFormatter value={Number(value)}/>
}} }}
...@@ -75,7 +93,7 @@ const ResourceView = () => { ...@@ -75,7 +93,7 @@ const ResourceView = () => {
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: l('home.develop.re.gv'), title: l('home.develop.re.gv'),
value: 1754, value: data?.globalVarCount || 0,
icon: <GlobalVarIcon style={imgStyle}/>, icon: <GlobalVarIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/> formatter: (value)=> <CountFormatter value={Number(value)}/>
}} }}
...@@ -85,7 +103,7 @@ const ResourceView = () => { ...@@ -85,7 +103,7 @@ const ResourceView = () => {
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: l('home.develop.re.ai'), title: l('home.develop.re.ai'),
value: 87, value: data?.alertInstanceCount || 0,
icon: <AlertInstanceIcon style={imgStyle}/>, icon: <AlertInstanceIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/> formatter: (value)=> <CountFormatter value={Number(value)}/>
}} }}
...@@ -93,7 +111,7 @@ const ResourceView = () => { ...@@ -93,7 +111,7 @@ const ResourceView = () => {
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: l('home.develop.re.ag'), title: l('home.develop.re.ag'),
value: 1754, value: data?.alertGroupCount || 0,
icon: <AlertGroupIcon style={imgStyle}/>, icon: <AlertGroupIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/> formatter: (value)=> <CountFormatter value={Number(value)}/>
}} }}
...@@ -103,7 +121,7 @@ const ResourceView = () => { ...@@ -103,7 +121,7 @@ const ResourceView = () => {
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: l('home.develop.re.git'), title: l('home.develop.re.git'),
value: 220, value: data?.gitProjectCount || 0,
icon: <GitIcon style={imgStyle}/>, icon: <GitIcon style={imgStyle}/>,
formatter: (value)=> <CountFormatter value={Number(value)}/> formatter: (value)=> <CountFormatter value={Number(value)}/>
}} }}
......
...@@ -17,84 +17,56 @@ ...@@ -17,84 +17,56 @@
* *
*/ */
import React from 'react'; import React, {useEffect, useState} from 'react';
import {Radar, RadarConfig} from '@ant-design/plots'; import {Radar, RadarConfig} from '@ant-design/plots';
import {l} from "@/utils/intl"; import {l} from "@/utils/intl";
import {queryDataByParams} from "@/services/BusinessCrud";
import {API_CONSTANTS} from "@/services/constants";
type TaskDialectSummary = { type TaskDialectSummary = {
type: string; jobType: string;
count: number; jobTypeCount: number;
rate: number; rate: number;
} }
const TaskDialectRadar = () => { const TaskDialectRadar = () => {
// 数据更新于 2021.01.09
const data : TaskDialectSummary[] = [ const [data, setData] = useState<TaskDialectSummary[]>([]);
{
type: 'FlinkSQL', useEffect(() => {
count: 10371, queryDataByParams(API_CONSTANTS.GET_JOB_TYPE_OVERVIEW).then((res) => {
rate: 0.01, setData(res);
}, })
{ }, [])
type: 'FlinkJar',
count: 7380,
rate: 0.01,
}, const config: RadarConfig = {
{ data: data,
type: 'K8SApplication', xField: 'jobType',
count: 7414, yField: 'jobTypeCount',
rate: 0.01, autoFit: true,
}, appendPadding: [0, 10, 0, 10],
{ meta: {
type: 'Doris', jobTypeCount: {
count: 2140, alias: l('home.job.total'),
rate: 0.01, min: 0,
}, nice: true,
{ formatter: (v) => Number(v),
type: 'FlinkSQLEnv', },
count: 660, },
rate: 0.01, yAxis: {
}, label: false,
{ grid: {
type: 'Java', alternateColor: 'rgba(0, 0, 0, 0.04)',
count: 885, },
rate: 0.01, },
}, // 开启辅助点
{ point: {
type: 'Mysql', size: 2,
count: 1626, },
rate: 0.01, area: {},
}, };
]; return <div style={{height: '35vh'}}><Radar {...config} /></div>;
const config:RadarConfig = {
data: data.map((d) => ({...d, count: Math.sqrt(d.count)})),
xField: 'type',
yField: 'count',
autoFit: true,
appendPadding: [0, 10, 0, 10],
meta: {
count: {
alias: l('home.job.total'),
min: 0,
nice: true,
formatter: (v) => Number(v),
},
},
xAxis: {
tickLine: null,
},
yAxis: {
label: false,
grid: {
alternateColor: 'rgba(0, 0, 0, 0.04)',
},
},
// 开启辅助点
point: {
size: 2,
},
area: {},
};
return <div style={{height: '35vh'}}><Radar {...config} /></div>;
}; };
export default TaskDialectRadar export default TaskDialectRadar
...@@ -37,9 +37,6 @@ const CPU: React.FC<CpuProps> = (props) => { ...@@ -37,9 +37,6 @@ const CPU: React.FC<CpuProps> = (props) => {
return {time: x.heartTime, value: Number( x.content.jvm.cpuUsed.toFixed(2))}; return {time: x.heartTime, value: Number( x.content.jvm.cpuUsed.toFixed(2))};
}) })
useEffect(() => {
}, []);
const config: AreaConfig = { const config: AreaConfig = {
animation: false, animation: false,
...@@ -55,13 +52,6 @@ const CPU: React.FC<CpuProps> = (props) => { ...@@ -55,13 +52,6 @@ const CPU: React.FC<CpuProps> = (props) => {
min:0, min:0,
max:100 max:100
}, },
// slider: {
// start: 0,
// end: 1,
// trendCfg: {
// isArea: true,
// },
// },
}; };
return <Area {...config} />; return <Area {...config} />;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
import {LightFilter, ProFormDateTimeRangePicker, ProFormRadio} from "@ant-design/pro-components"; import {LightFilter, ProFormDateTimeRangePicker, ProFormRadio} from "@ant-design/pro-components";
import React from "react"; import React from "react";
import {DATE_RANGE_OPTIONS} from "@/pages/Metrics/Server/constants"; import {DATE_RANGE_OPTIONS} from "@/pages/Metrics/Server/constants";
import {l} from "@/utils/intl";
type GlobalFilterProps = { type GlobalFilterProps = {
custom: boolean; custom: boolean;
...@@ -47,7 +48,7 @@ const GlobalFilter: React.FC<GlobalFilterProps> = (props) => { ...@@ -47,7 +48,7 @@ const GlobalFilter: React.FC<GlobalFilterProps> = (props) => {
/> />
{dateRange=="custom"?<ProFormDateTimeRangePicker {dateRange=="custom"?<ProFormDateTimeRangePicker
name="datetimeRanger" name="datetimeRanger"
label="日期时间范围" label={l('metrics.filter.custom.range')}
allowClear={false} allowClear={false}
initialValue={[startTime, endTime]} initialValue={[startTime, endTime]}
fieldProps={{ fieldProps={{
......
...@@ -34,8 +34,6 @@ const Heap: React.FC<HeapProps> = (props) => { ...@@ -34,8 +34,6 @@ const Heap: React.FC<HeapProps> = (props) => {
const dataList: Heap[] = data.map(x => { const dataList: Heap[] = data.map(x => {
return {time: x.heartTime, value: Number((x.content.jvm.heapUsed/(1024*1024)).toFixed(0))}; return {time: x.heartTime, value: Number((x.content.jvm.heapUsed/(1024*1024)).toFixed(0))};
}) })
useEffect(() => {
}, []);
const config: AreaConfig = { const config: AreaConfig = {
...@@ -52,10 +50,6 @@ const Heap: React.FC<HeapProps> = (props) => { ...@@ -52,10 +50,6 @@ const Heap: React.FC<HeapProps> = (props) => {
min:0, min:0,
max:max max:max
}, },
// slider: {
// start: 0.1,
// end: 0.9,
// },
}; };
return <Area {...config} />; return <Area {...config} />;
......
...@@ -17,9 +17,10 @@ ...@@ -17,9 +17,10 @@
* *
*/ */
import {useEffect, useState} from "react"; import React, {useEffect, useState} from "react";
import {Area, AreaConfig} from "@ant-design/plots"; import {Area, AreaConfig} from "@ant-design/plots";
import {MetricsDataType} from "@/pages/Metrics/Server/data"; import {MetricsDataType} from "@/pages/Metrics/Server/data";
type NonHeapProps = { type NonHeapProps = {
data: MetricsDataType[]; data: MetricsDataType[];
max: number; max: number;
...@@ -29,17 +30,15 @@ type NonHeap = { ...@@ -29,17 +30,15 @@ type NonHeap = {
value: string | number; value: string | number;
} }
const NonHeap: React.FC<NonHeapProps> = (props) => { const NonHeap: React.FC<NonHeapProps> = (props) => {
const {data,max} = props; const {data, max} = props;
const dataList: NonHeap[] = data.map(x => { const dataList: NonHeap[] = data.map(x => {
return {time: x.heartTime, value: Number((x.content.jvm.nonHeapMax/(1024*1024)).toFixed(0))}; return {time: x.heartTime, value: Number((x.content.jvm.nonHeapMax / (1024 * 1024)).toFixed(0))};
}) })
useEffect(() => {
}, []);
const config: AreaConfig = { const config: AreaConfig = {
data:dataList, data: dataList,
animation:false, animation: false,
height: 200, height: 200,
yField: 'value', yField: 'value',
xField: 'time', xField: 'time',
...@@ -47,14 +46,10 @@ const NonHeap: React.FC<NonHeapProps> = (props) => { ...@@ -47,14 +46,10 @@ const NonHeap: React.FC<NonHeapProps> = (props) => {
type: 'time', type: 'time',
mask: 'HH:mm:ss', mask: 'HH:mm:ss',
}, },
yAxis:{ yAxis: {
min:0, min: 0,
max:max max: max
}, },
// slider: {
// start: 0.1,
// end: 0.9,
// },
}; };
return <Area {...config} />; return <Area {...config} />;
......
...@@ -28,29 +28,26 @@ type ThreadProps = { ...@@ -28,29 +28,26 @@ type ThreadProps = {
type Thread = { type Thread = {
time: Date; time: Date;
value: string | number; value: string | number;
name:string name: string
} }
const Thread: React.FC<ThreadProps> = (props) => { const Thread: React.FC<ThreadProps> = (props) => {
const {data} = props; const {data} = props;
const dataList: Thread[] = data.map(x => { const dataList: Thread[] = data.map(x => {
return {time: x.heartTime, value: x.content.jvm.threadPeakCount,name:"Peak"}; return {time: x.heartTime, value: x.content.jvm.threadPeakCount, name: "Peak"};
}) })
const dataList2: Thread[] = data.map(x => { const dataList2: Thread[] = data.map(x => {
return {time: x.heartTime, value: x.content.jvm.threadCount,name:"Count"}; return {time: x.heartTime, value: x.content.jvm.threadCount, name: "Count"};
}) })
const dataListAll = dataList.concat(dataList2); const dataListAll = dataList.concat(dataList2);
useEffect(() => {
}, []);
const config: AreaConfig = { const config: AreaConfig = {
data:dataListAll, data: dataListAll,
animation:false, animation: false,
height: 200, height: 200,
xField: 'time', xField: 'time',
yField: 'value', yField: 'value',
seriesField: 'name', seriesField: 'name',
isStack:false,
xAxis: { xAxis: {
type: 'time', type: 'time',
mask: 'HH:mm:ss', mask: 'HH:mm:ss',
......
...@@ -18,40 +18,42 @@ ...@@ -18,40 +18,42 @@
*/ */
import {l} from "@/utils/intl";
export const DATE_RANGE_OPTIONS =(disable:boolean)=> [ export const DATE_RANGE_OPTIONS =(disable:boolean)=> [
{ {
value: '60s', value: '60s',
label: '60秒', label: l('metrics.filter.60seconds'),
disable:!disable disable:!disable
}, },
{ {
value: '5min', value: '5min',
label: '5分钟', label: l('metrics.filter.5minutes'),
disable:!disable disable:!disable
}, },
{ {
value: '10min', value: '10min',
label: '10分钟', label: l('metrics.filter.10minutes'),
disable:!disable disable:!disable
}, },
{ {
value: '1h', value: '1h',
label: '1小时', label: l('metrics.filter.1hour'),
disable:!disable disable:!disable
}, },
{ {
value: '2h', value: '2h',
label: '2小时', label: l('metrics.filter.2hours'),
disable:!disable disable:!disable
}, },
{ {
value: '5h', value: '5h',
label: '5小时', label: l('metrics.filter.5hours'),
disable:!disable disable:!disable
}, },
{ {
value: 'custom', value: 'custom',
label: '自定义', label: l('metrics.filter.custom'),
disable:disable disable:disable
}, },
] ]
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
export type MetricsDataType = { export type MetricsDataType = {
content: { content: {
jvm: JVMType, jvm: JVMType,
cpu: CPUType, cpu: CPUType,
mem: MemoryType, mem: MemoryType,
}, },
metricsTotal: number, metricsTotal: number,
model: string, model: string,
heartTime: Date, heartTime: Date,
} }
type JVMType = { type JVMType = {
total: number, total: number,
max: number, max: number,
free: number, free: number,
cpuUsed: number, cpuUsed: number,
nonHeapMax: number, nonHeapMax: number,
nonHeapUsed: number, nonHeapUsed: number,
heapMax: number, heapMax: number,
heapUsed: number, heapUsed: number,
threadPeakCount: number, threadPeakCount: number,
threadCount: number, threadCount: number,
version: string, version: string,
home: string, home: string,
} }
type CPUType = { type CPUType = {
cpuNum: number, cpuNum: number,
sys: number, sys: number,
wait: number, wait: number,
free: number, free: number,
} }
type MemoryType = { type MemoryType = {
total: number, total: number,
used: number, used: number,
free: number, free: number,
} }
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
* @param {number} minutes | sub minutes * @param {number} minutes | sub minutes
* @returns {Date} | return the time before several minutes * @returns {Date} | return the time before several minutes
*/ */
export const getSubMinTime = (currentTime : Date ,minutes: number) => { export const getSubMinTime = (currentTime: Date, minutes: number) => {
const pastTime = new Date(currentTime.getTime() - minutes * 60000); const pastTime = new Date(currentTime.getTime() - minutes * 60000);
return pastTime; return pastTime;
}; };
...@@ -37,13 +37,13 @@ export const getSubMinTime = (currentTime : Date ,minutes: number) => { ...@@ -37,13 +37,13 @@ export const getSubMinTime = (currentTime : Date ,minutes: number) => {
* @param {boolean} isStart | is start time , if true , the time is 00:00:00.000 if false , the time is 23:59:59.999 * @param {boolean} isStart | is start time , if true , the time is 00:00:00.000 if false , the time is 23:59:59.999
* @returns {Date} | return the time before several days * @returns {Date} | return the time before several days
*/ */
export const getSubDateTime = (currentTime : Date , day: number,isStart: boolean) => { export const getSubDateTime = (currentTime: Date, day: number, isStart: boolean) => {
const pastTime = new Date( const pastTime = new Date(
currentTime.getFullYear(), currentTime.getFullYear(),
currentTime.getMonth(), currentTime.getMonth(),
currentTime.getDate() - day, currentTime.getDate() - day,
(isStart? 0: 23), (isStart? 0: 59), (isStart? 0: 59), (isStart? 0: 999) (isStart ? 0 : 23), (isStart ? 0 : 59), (isStart ? 0 : 59), (isStart ? 0 : 999)
); );
return pastTime; return pastTime;
}; };
...@@ -55,12 +55,12 @@ export const getSubDateTime = (currentTime : Date , day: number,isStart: boolean ...@@ -55,12 +55,12 @@ export const getSubDateTime = (currentTime : Date , day: number,isStart: boolean
* @param {boolean} isFirst | is first day of month, if true , the time is 00:00:00.000 if false , the time is 23:59:59.999 * @param {boolean} isFirst | is first day of month, if true , the time is 00:00:00.000 if false , the time is 23:59:59.999
* @returns {Date} | return the first day / last day of current month * @returns {Date} | return the first day / last day of current month
*/ */
export const getDayOfMonth = (currentTime : Date , isFirst: boolean) => { export const getDayOfMonth = (currentTime: Date, isFirst: boolean) => {
const pastTime = new Date( const pastTime = new Date(
currentTime.getFullYear(), currentTime.getFullYear(),
currentTime.getMonth() + (isFirst ? 0 : 1), currentTime.getMonth() + (isFirst ? 0 : 1),
(isFirst? 1: 0), (isFirst ? 1 : 0),
(isFirst? 0: 23), (isFirst? 0: 59), (isFirst? 0: 59), (isFirst? 0: 999) (isFirst ? 0 : 23), (isFirst ? 0 : 59), (isFirst ? 0 : 59), (isFirst ? 0 : 999)
); );
return pastTime; return pastTime;
} }
...@@ -130,7 +130,6 @@ const Server = () => { ...@@ -130,7 +130,6 @@ const Server = () => {
setEndTime(currentTime) setEndTime(currentTime)
break; break;
case '5min': case '5min':
console.log('5min')
setStartTime(getSubMinTime(currentTime, 5)) setStartTime(getSubMinTime(currentTime, 5))
setEndTime(currentTime) setEndTime(currentTime)
break; break;
......
...@@ -191,6 +191,10 @@ export const API_CONSTANTS = { ...@@ -191,6 +191,10 @@ export const API_CONSTANTS = {
// -- home // -- home
GET_STATUS_COUNT: "api/jobInstance/getStatusCount", GET_STATUS_COUNT: "api/jobInstance/getStatusCount",
GET_RESOURCE_OVERVIEW: "/api/home/getResourceOverview",
GET_JOB_STATUS_OVERVIEW: "/api/home/getJobStatusOverview",
GET_JOB_TYPE_OVERVIEW: "/api/home/getJobTypeOverview",
GET_JOB_MODEL_OVERVIEW: "/api/home/getJobModelOverview",
// monitor // monitor
MONITOR_GET_SYSTEM_DATA:"/api/monitor/getSysData", MONITOR_GET_SYSTEM_DATA:"/api/monitor/getSysData",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment