Skip to content
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

feat: support service panel to choose space and show index #241

Merged
merged 1 commit into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/components/ServiceMetricsFilterPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useEffect, useMemo, useRef } from 'react';
import { Form } from 'antd';
import intl from 'react-intl-universal';

import { AGGREGATION_OPTIONS, TIME_INTERVAL_OPTIONS } from '@/utils/dashboard';
import { ServiceName } from '@/utils/interface';
import MetricsFilterPanel from '../MetricsFilterPanel';
import { DashboardSelect, Option } from '../DashboardSelect';
Expand Down
130 changes: 66 additions & 64 deletions src/config/locale/en-US/common.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,67 @@
{
"account": "Account Login",
"login": "Log In",
"logout": "Logout",
"username": "Please enter user name",
"password": "Please enter password",
"rememberPassword": "Remember password",
"version": "Version",
"dashboard": "Dashboard",
"machine": "Machine",
"service": "Service",
"serviceManagement": "Management",
"serviceInfo": "Service Info",
"partitionInfo": "Partition Info",
"config": "Config",
"longTermTask": "Long-term Task",
"metric": "Metric",
"lineChart": "Line Chart",
"barChart": "Bar Chart",
"view": "View",
"set": "Set up",
"cancel": "Cancel",
"confirm": "Confirm",
"overview": "Overview",
"baseLine": "Base Line",
"succeed": "Succeed",
"editBaseLine": "Edit Base Line",
"baseLineTip": "Please enter a number greater than 0",
"unit": "Unit",
"detail": "Detail",
"help": "Help",
"manual": "User Manual",
"forum": "Forum",
"forumLink": "https://discuss.nebula-graph.io/",
"configTip": "Please enter a configuration name",
"all": "All",
"metricLabel": "instance",
"updateFrequency": "refresh frequency",
"overviewInfo": "Info Overview",
"nebulaVersion": {
"enterprise": "Enterprise",
"community": "Community"
},
"noData": "No Data",
"powerInfo": "Powered by NebulaGraph",
"configServer": {
"host": "Graphd IP address",
"port": "Port"
},
"addhostSuccess": "{host} add host success",
"successDelay": "Success, Please refresh the page later to view",
"running": "Running",
"panelName": "Panel Name",
"panelNamePlaceholder": "Please enter a panel name",
"panelMetricType": "Metric Type",
"panelMetricModal": {
"PERCENTAGE": "percentage",
"BYTE": "byte",
"BYTE_SECOND": "byte/s",
"DISK_IO_NET": "io/s",
"NUMBER": "number",
"numberSecond": "number/s",
"latency": "us/ms/s"
}
}
"account": "Account Login",
"login": "Log In",
"logout": "Logout",
"username": "Please enter user name",
"password": "Please enter password",
"rememberPassword": "Remember password",
"version": "Version",
"dashboard": "Dashboard",
"machine": "Machine",
"service": "Service",
"serviceManagement": "Management",
"serviceInfo": "Service Info",
"partitionInfo": "Partition Info",
"config": "Config",
"longTermTask": "Long-term Task",
"metric": "Metric",
"lineChart": "Line Chart",
"barChart": "Bar Chart",
"view": "View",
"set": "Set up",
"cancel": "Cancel",
"confirm": "Confirm",
"overview": "Overview",
"baseLine": "Base Line",
"succeed": "Succeed",
"editBaseLine": "Edit Base Line",
"baseLineTip": "Please enter a number greater than 0",
"unit": "Unit",
"detail": "Detail",
"help": "Help",
"manual": "User Manual",
"forum": "Forum",
"forumLink": "https://discuss.nebula-graph.io/",
"configTip": "Please enter a configuration name",
"all": "All",
"metricLabel": "instance",
"updateFrequency": "refresh frequency",
"overviewInfo": "Info Overview",
"nebulaVersion": {
"enterprise": "Enterprise",
"community": "Community"
},
"noData": "No Data",
"powerInfo": "Powered by NebulaGraph",
"configServer": {
"host": "Graphd IP address",
"port": "Port"
},
"addhostSuccess": "{host} add host success",
"successDelay": "Success, Please refresh the page later to view",
"running": "Running",
"panelName": "Panel Name",
"panelNamePlaceholder": "Please enter a panel name",
"panelMetricType": "Metric Type",
"panelMetricModal": {
"PERCENTAGE": "percentage",
"BYTE": "byte",
"BYTE_SECOND": "byte/s",
"DISK_IO_NET": "io/s",
"NUMBER": "number",
"numberSecond": "number/s",
"latency": "us/ms/s"
},
"showIndex": "Show Index",
"showIndexTip": "Panel display order: the smaller the number, the closer to the front; the minimum value is 1."
}
130 changes: 66 additions & 64 deletions src/config/locale/zh-CN/common.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,67 @@
{
"account": "账户登录",
"login": "登录",
"logout": "登出",
"username": "请输入用户名",
"password": "请输入密码",
"rememberPassword": "记住密码",
"version": "版本",
"dashboard": "看板",
"machine": "机器",
"service": "服务",
"serviceManagement": "管理",
"serviceInfo": "服务信息",
"partitionInfo": "分片信息",
"config": "配置",
"longTermTask": "长时任务",
"metric": "指标",
"lineChart": "折线图",
"barChart": "柱状图",
"view": "查看",
"set": "设置",
"cancel": "取消",
"confirm": "确认",
"overview": "概览",
"baseLine": "基线",
"succeed": "成功",
"editBaseLine": "编辑基线",
"baseLineTip": "请输入大于0的值",
"unit": "单位",
"detail": "详情",
"help": "帮助",
"manual": "使用手册",
"forum": "求助论坛",
"forumLink": "https://discuss.nebula-graph.com.cn/",
"all": "全部",
"updateFrequency": "更新频率",
"configTip": "请输入配置名进行搜索",
"metricLabel": "实例",
"overviewInfo": "信息总览",
"nebulaVersion": {
"enterprise": "企业版",
"community": "社区版"
},
"noData": "没有数据",
"powerInfo": "版权归 NebulaGraph 所有",
"configServer": {
"host": "Graphd IP 地址",
"port": "端口号"
},
"addhostSuccess": "{host} add host 成功",
"successDelay": "操作成功,请稍后刷新页面查看",
"running": "运行中",
"panelName": "面板名称",
"panelNamePlaceholder": "请输入监控面板名称",
"panelMetricType": "监控指标类型",
"panelMetricModal": {
"PERCENTAGE": "百分比",
"BYTE": "字节",
"BYTE_SECOND": "字节/秒",
"DISK_IO_NET": "io/秒",
"NUMBER": "数值",
"numberSecond": "数值/秒",
"latency": "秒/微妙/毫秒"
}
}
"account": "账户登录",
"login": "登录",
"logout": "登出",
"username": "请输入用户名",
"password": "请输入密码",
"rememberPassword": "记住密码",
"version": "版本",
"dashboard": "看板",
"machine": "机器",
"service": "服务",
"serviceManagement": "管理",
"serviceInfo": "服务信息",
"partitionInfo": "分片信息",
"config": "配置",
"longTermTask": "长时任务",
"metric": "指标",
"lineChart": "折线图",
"barChart": "柱状图",
"view": "查看",
"set": "设置",
"cancel": "取消",
"confirm": "确认",
"overview": "概览",
"baseLine": "基线",
"succeed": "成功",
"editBaseLine": "编辑基线",
"baseLineTip": "请输入大于0的值",
"unit": "单位",
"detail": "详情",
"help": "帮助",
"manual": "使用手册",
"forum": "求助论坛",
"forumLink": "https://discuss.nebula-graph.com.cn/",
"all": "全部",
"updateFrequency": "更新频率",
"configTip": "请输入配置名进行搜索",
"metricLabel": "实例",
"overviewInfo": "信息总览",
"nebulaVersion": {
"enterprise": "企业版",
"community": "社区版"
},
"noData": "没有数据",
"powerInfo": "版权归 NebulaGraph 所有",
"configServer": {
"host": "Graphd IP 地址",
"port": "端口号"
},
"addhostSuccess": "{host} add host 成功",
"successDelay": "操作成功,请稍后刷新页面查看",
"running": "运行中",
"panelName": "面板名称",
"panelNamePlaceholder": "请输入监控面板名称",
"panelMetricType": "监控指标类型",
"panelMetricModal": {
"PERCENTAGE": "百分比",
"BYTE": "字节",
"BYTE_SECOND": "字节/秒",
"DISK_IO_NET": "io/秒",
"NUMBER": "数值",
"numberSecond": "数值/秒",
"latency": "秒/微妙/毫秒"
},
"showIndex": "展示顺序",
"showIndexTip": "面板展示顺序,数字越小越靠前,最小值为1"
}
15 changes: 12 additions & 3 deletions src/pages/ServiceDashboard/ServiceOverview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,16 @@ function ServiceOverview(props: IProps) {
const aggregation = metricItem.aggregations.includes(AggregationType.Sum)
? AggregationType.Sum
: (metricItem.aggregations[0] as AggregationType);
const spaceSuffix = configItem.space != undefined ? `,space="${configItem.space}"` : '';
let query = getQueryByMetricType(metricItem, aggregation, '5');
const clusterSuffix1 = cluster ? `,${getClusterPrefix()}="${cluster.id}"` : '';
if (aggregation === AggregationType.Sum && !metricItem.isRawMetric) {
query = `sum_over_time(${query}{instanceName="${curServiceName}"${clusterSuffix1}}[${15}s])`;
query = `sum_over_time(${query}{instanceName="${curServiceName}"${clusterSuffix1}${spaceSuffix}}[${15}s])`;
} else {
if (query.includes('cpu_seconds_total')) {
query = `avg by (instanceName) (rate(${query}{instanceName="${curServiceName}"${clusterSuffix1}}[5m])) * 100`
} else {
query = `${query}{instanceName="${curServiceName}"${clusterSuffix1}}`;
query = `${query}{instanceName="${curServiceName}"${clusterSuffix1}${spaceSuffix}}`;
}
}
return {
Expand Down Expand Up @@ -171,6 +172,14 @@ function ServiceOverview(props: IProps) {
return `/clusters/${cluster.id}/service-metric/${serviceType}/${serviceName}/${encodeURIComponent(panelName)}`;
}

const sortedPanels = (panels: ServicePanelConfig[]) => {
return panels.sort((panelA, panelB) => {
const AIndex = panelA.showIndex ? +panelA.showIndex : Number.MAX_VALUE;
const BIndex = panelB.showIndex ? +panelB.showIndex : Number.MAX_VALUE;
return AIndex - BIndex;
});
}

return (
<div className={styles.serviceTableItem}>
<ServiceHeader serviceType={serviceType} title={
Expand Down Expand Up @@ -210,7 +219,7 @@ function ServiceOverview(props: IProps) {
<Spin spinning={loading}>
<div className={styles.serviceTableItemContent}>
{
panelConfigData.map((configItem: ServicePanelConfig, index) => (
sortedPanels(panelConfigData).map((configItem: ServicePanelConfig, index) => (
<DashboardCard
title={configItem.title}
key={index}
Expand Down
6 changes: 6 additions & 0 deletions src/pages/ServiceDashboard/defaultPanelConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { BatchQueryItem, ServiceName } from '@/utils/interface';
export interface ServicePanelConfig {
title: string;
valueType: VALUE_TYPE;
space?: string;
showIndex?: number;
queries: BatchQueryItem[];
}

Expand All @@ -20,6 +22,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [
{
title: intl.get('metric_description.graphd_latency'),
valueType: VALUE_TYPE.latency,
space: '',
queries: [
{
refId: 'slow_query_latency',
Expand All @@ -38,6 +41,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [
{
title: intl.get('metric_description.graphd_sessions'),
valueType: VALUE_TYPE.number,
space: '',
queries: [
{
refId: 'active_sessions',
Expand All @@ -64,6 +68,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [
{
title: intl.get('metric_description.graphd_queries'),
valueType: VALUE_TYPE.number,
space: '',
queries: [
{
refId: 'active_queries',
Expand Down Expand Up @@ -94,6 +99,7 @@ export const defaultServicePanelConfigData: ServicePanelConfigItem[] = [
{
title: intl.get('metric_description.process_disk'),
valueType: VALUE_TYPE.byte,
space: '',
queries: [
{
refId: 'read_bytes_total',
Expand Down
Loading