mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-13 00:08:56 +00:00
feat: update
This commit is contained in:
commit
a0f4f8a4fa
1986
package-lock.json
generated
1986
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -72,9 +72,9 @@
|
|||||||
"stylelint-config-standard": "^33.0.0",
|
"stylelint-config-standard": "^33.0.0",
|
||||||
"stylelint-order": "^6.0.3",
|
"stylelint-order": "^6.0.3",
|
||||||
"typescript": "~4.7.4",
|
"typescript": "~4.7.4",
|
||||||
"unplugin-auto-import": "^0.16.4",
|
"unplugin-auto-import": "^0.7.0",
|
||||||
"unplugin-vue-components": "^0.25.0",
|
"unplugin-vue-components": "^0.19.2",
|
||||||
"vite": "^4.0.0",
|
"vite": "^4.0.5",
|
||||||
"vite-plugin-monaco-editor": "^1.1.0",
|
"vite-plugin-monaco-editor": "^1.1.0",
|
||||||
"vite-plugin-svg-icons": "^2.0.1",
|
"vite-plugin-svg-icons": "^2.0.1",
|
||||||
"vitest": "^0.25.6",
|
"vitest": "^0.25.6",
|
||||||
|
@ -68,12 +68,3 @@ export const deleteTemplate = {
|
|||||||
message
|
message
|
||||||
}`,
|
}`,
|
||||||
};
|
};
|
||||||
export const TypeOfMQE = {
|
|
||||||
variable: "$expression: String!",
|
|
||||||
query: `
|
|
||||||
metricType: returnTypeOfMQE(expression: $expression) {
|
|
||||||
type
|
|
||||||
error
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
};
|
|
||||||
|
@ -21,7 +21,6 @@ import {
|
|||||||
addTemplate,
|
addTemplate,
|
||||||
changeTemplate,
|
changeTemplate,
|
||||||
deleteTemplate,
|
deleteTemplate,
|
||||||
TypeOfMQE,
|
|
||||||
} from "../fragments/dashboard";
|
} from "../fragments/dashboard";
|
||||||
|
|
||||||
export const queryTypeOfMetrics = `query typeOfMetrics(${TypeOfMetrics.variable}) {${TypeOfMetrics.query}}`;
|
export const queryTypeOfMetrics = `query typeOfMetrics(${TypeOfMetrics.variable}) {${TypeOfMetrics.query}}`;
|
||||||
@ -35,5 +34,3 @@ export const updateTemplate = `mutation template(${changeTemplate.variable}) {${
|
|||||||
export const removeTemplate = `mutation template(${deleteTemplate.variable}) {${deleteTemplate.query}}`;
|
export const removeTemplate = `mutation template(${deleteTemplate.variable}) {${deleteTemplate.query}}`;
|
||||||
|
|
||||||
export const getTemplates = `query templates {${getAllTemplates.query}}`;
|
export const getTemplates = `query templates {${getAllTemplates.query}}`;
|
||||||
|
|
||||||
export const getTypeOfMQE = `query returnTypeOfMQE(${TypeOfMQE.variable}) {${TypeOfMQE.query}}`;
|
|
||||||
|
@ -116,7 +116,6 @@ export const RespFields: Indexable = {
|
|||||||
type
|
type
|
||||||
results {
|
results {
|
||||||
metric {
|
metric {
|
||||||
name
|
|
||||||
labels {
|
labels {
|
||||||
key
|
key
|
||||||
value
|
value
|
||||||
|
@ -23,129 +23,142 @@ import { useAppStoreWithOut } from "@/store/modules/app";
|
|||||||
import type { MetricConfigOpt } from "@/types/dashboard";
|
import type { MetricConfigOpt } from "@/types/dashboard";
|
||||||
import type { Instance, Endpoint, Service } from "@/types/selector";
|
import type { Instance, Endpoint, Service } from "@/types/selector";
|
||||||
|
|
||||||
export function useExpressionsQueryProcessor(config: Indexable) {
|
export async function useExpressionsQueryProcessor(config: Indexable) {
|
||||||
if (!(config.metrics && config.metrics[0])) {
|
function expressionsGraphqlPods() {
|
||||||
return;
|
if (!(config.metrics && config.metrics[0])) {
|
||||||
}
|
return;
|
||||||
if (!(config.metricTypes && config.metricTypes[0])) {
|
}
|
||||||
return;
|
const appStore = useAppStoreWithOut();
|
||||||
}
|
const dashboardStore = useDashboardStore();
|
||||||
const appStore = useAppStoreWithOut();
|
const selectorStore = useSelectorStore();
|
||||||
const dashboardStore = useDashboardStore();
|
|
||||||
const selectorStore = useSelectorStore();
|
|
||||||
|
|
||||||
if (!selectorStore.currentService && dashboardStore.entity !== "All") {
|
if (!selectorStore.currentService && dashboardStore.entity !== "All") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const conditions: Recordable = {
|
const conditions: Recordable = {
|
||||||
duration: appStore.durationTime,
|
duration: appStore.durationTime,
|
||||||
};
|
};
|
||||||
const variables: string[] = [`$duration: Duration!`];
|
const variables: string[] = [`$duration: Duration!`];
|
||||||
const isRelation = ["ServiceRelation", "ServiceInstanceRelation", "EndpointRelation", "ProcessRelation"].includes(
|
const isRelation = ["ServiceRelation", "ServiceInstanceRelation", "EndpointRelation", "ProcessRelation"].includes(
|
||||||
dashboardStore.entity,
|
dashboardStore.entity,
|
||||||
);
|
);
|
||||||
if (isRelation && !selectorStore.currentDestService) {
|
if (isRelation && !selectorStore.currentDestService) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const fragment = config.metrics.map((name: string, index: number) => {
|
const fragment = config.metrics.map((name: string, index: number) => {
|
||||||
variables.push(`$expression${index}: String!`, `$entity${index}: Entity!`);
|
variables.push(`$expression${index}: String!`, `$entity${index}: Entity!`);
|
||||||
conditions[`expression${index}`] = name;
|
conditions[`expression${index}`] = name;
|
||||||
const entity = {
|
const entity = {
|
||||||
serviceName: dashboardStore.entity === "All" ? undefined : selectorStore.currentService.value,
|
serviceName: dashboardStore.entity === "All" ? undefined : selectorStore.currentService.value,
|
||||||
normal: dashboardStore.entity === "All" ? undefined : selectorStore.currentService.normal,
|
normal: dashboardStore.entity === "All" ? undefined : selectorStore.currentService.normal,
|
||||||
serviceInstanceName: ["ServiceInstance", "ServiceInstanceRelation", "ProcessRelation"].includes(
|
serviceInstanceName: ["ServiceInstance", "ServiceInstanceRelation", "ProcessRelation"].includes(
|
||||||
dashboardStore.entity,
|
dashboardStore.entity,
|
||||||
)
|
)
|
||||||
? selectorStore.currentPod && selectorStore.currentPod.value
|
? selectorStore.currentPod && selectorStore.currentPod.value
|
||||||
: undefined,
|
: undefined,
|
||||||
endpointName: dashboardStore.entity.includes("Endpoint")
|
endpointName: dashboardStore.entity.includes("Endpoint")
|
||||||
? selectorStore.currentPod && selectorStore.currentPod.value
|
? selectorStore.currentPod && selectorStore.currentPod.value
|
||||||
: undefined,
|
: undefined,
|
||||||
processName: dashboardStore.entity.includes("Process")
|
processName: dashboardStore.entity.includes("Process")
|
||||||
? selectorStore.currentProcess && selectorStore.currentProcess.value
|
? selectorStore.currentProcess && selectorStore.currentProcess.value
|
||||||
: undefined,
|
: undefined,
|
||||||
destNormal: isRelation ? selectorStore.currentDestService.normal : undefined,
|
destNormal: isRelation ? selectorStore.currentDestService.normal : undefined,
|
||||||
destServiceName: isRelation ? selectorStore.currentDestService.value : undefined,
|
destServiceName: isRelation ? selectorStore.currentDestService.value : undefined,
|
||||||
destServiceInstanceName: ["ServiceInstanceRelation", "ProcessRelation"].includes(dashboardStore.entity)
|
destServiceInstanceName: ["ServiceInstanceRelation", "ProcessRelation"].includes(dashboardStore.entity)
|
||||||
? selectorStore.currentDestPod && selectorStore.currentDestPod.value
|
|
||||||
: undefined,
|
|
||||||
destEndpointName:
|
|
||||||
dashboardStore.entity === "EndpointRelation"
|
|
||||||
? selectorStore.currentDestPod && selectorStore.currentDestPod.value
|
? selectorStore.currentDestPod && selectorStore.currentDestPod.value
|
||||||
: undefined,
|
: undefined,
|
||||||
destProcessName: dashboardStore.entity.includes("ProcessRelation")
|
destEndpointName:
|
||||||
? selectorStore.currentDestProcess && selectorStore.currentDestProcess.value
|
dashboardStore.entity === "EndpointRelation"
|
||||||
: undefined,
|
? selectorStore.currentDestPod && selectorStore.currentDestPod.value
|
||||||
|
: undefined,
|
||||||
|
destProcessName: dashboardStore.entity.includes("ProcessRelation")
|
||||||
|
? selectorStore.currentDestProcess && selectorStore.currentDestProcess.value
|
||||||
|
: undefined,
|
||||||
|
};
|
||||||
|
conditions[`entity${index}`] = entity;
|
||||||
|
|
||||||
|
return `expression${index}: execExpression(expression: $expression${index}, entity: $entity${index}, duration: $duration)${RespFields.execExpression}`;
|
||||||
|
});
|
||||||
|
const queryStr = `query queryData(${variables}) {${fragment}}`;
|
||||||
|
|
||||||
|
return {
|
||||||
|
queryStr,
|
||||||
|
conditions,
|
||||||
};
|
};
|
||||||
conditions[`entity${index}`] = entity;
|
|
||||||
|
|
||||||
return `expression${index}: execExpression(expression: $expression${index}, entity: $entity${index}, duration: $duration)${RespFields.execExpression}`;
|
|
||||||
});
|
|
||||||
const queryStr = `query queryData(${variables}) {${fragment}}`;
|
|
||||||
|
|
||||||
return {
|
|
||||||
queryStr,
|
|
||||||
conditions,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useExpressionsSourceProcessor(
|
|
||||||
resp: { errors: string; data: Indexable },
|
|
||||||
config: {
|
|
||||||
metrics: string[];
|
|
||||||
metricTypes: string[];
|
|
||||||
metricConfig: MetricConfigOpt[];
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
if (resp.errors) {
|
|
||||||
ElMessage.error(resp.errors);
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
if (!resp.data) {
|
|
||||||
ElMessage.error("The query is wrong");
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
const source: { [key: string]: unknown } = {};
|
|
||||||
const keys = Object.keys(resp.data);
|
|
||||||
for (let i = 0; i < config.metricTypes.length; i++) {
|
|
||||||
const type = config.metricTypes[i];
|
|
||||||
const c: MetricConfigOpt = (config.metricConfig && config.metricConfig[i]) || {};
|
|
||||||
const results = (resp.data[keys[i]] && resp.data[keys[i]].results) || [];
|
|
||||||
const name = ((results[0] || {}).metric || {}).name;
|
|
||||||
|
|
||||||
if (type === ExpressionResultType.TIME_SERIES_VALUES) {
|
function expressionsSource(resp: { errors: string; data: Indexable }) {
|
||||||
if (results.length === 1) {
|
if (resp.errors) {
|
||||||
source[c.label || name] = results[0].values.map((d: { value: unknown }) => d.value) || [];
|
ElMessage.error(resp.errors);
|
||||||
} else {
|
return { source: {}, tips: [], typesOfMQE: [] };
|
||||||
const labels = (c.label || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, ""));
|
}
|
||||||
for (const item of results) {
|
if (!resp.data) {
|
||||||
const values = item.values.map((d: { value: unknown }) => d.value) || [];
|
ElMessage.error("The query is wrong");
|
||||||
const index = item.metric.labels[0].value;
|
return { source: {}, tips: [], typesOfMQE: [] };
|
||||||
const indexNum = labels.findIndex((_, i: number) => i === Number(index));
|
}
|
||||||
if (labels[indexNum] && indexNum > -1) {
|
const tips: string[] = [];
|
||||||
source[labels[indexNum]] = values;
|
const source: { [key: string]: unknown } = {};
|
||||||
|
const keys = Object.keys(resp.data);
|
||||||
|
const typesOfMQE: string[] = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < config.metrics.length; i++) {
|
||||||
|
const c: MetricConfigOpt = (config.metricConfig && config.metricConfig[i]) || {};
|
||||||
|
const obj = resp.data[keys[i]] || {};
|
||||||
|
const results = obj.results || [];
|
||||||
|
const name = config.metrics[i];
|
||||||
|
const type = obj.type;
|
||||||
|
|
||||||
|
tips.push(obj.error);
|
||||||
|
typesOfMQE.push(type);
|
||||||
|
if (!obj.error) {
|
||||||
|
if (type === ExpressionResultType.TIME_SERIES_VALUES) {
|
||||||
|
if (results.length === 1) {
|
||||||
|
source[c.label || name] = results[0].values.map((d: { value: unknown }) => d.value) || [];
|
||||||
} else {
|
} else {
|
||||||
source[index] = values;
|
const labels = (c.label || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, ""));
|
||||||
|
for (const item of results) {
|
||||||
|
const values = item.values.map((d: { value: unknown }) => d.value) || [];
|
||||||
|
const index = item.metric.labels[0].value;
|
||||||
|
const indexNum = labels.findIndex((_, i: number) => i === Number(index));
|
||||||
|
if (labels[indexNum] && indexNum > -1) {
|
||||||
|
source[labels[indexNum]] = values;
|
||||||
|
} else {
|
||||||
|
source[index] = values;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (type === ExpressionResultType.SINGLE_VALUE) {
|
||||||
|
source[c.label || name] = results[0].values[0].value;
|
||||||
|
}
|
||||||
|
if (([ExpressionResultType.RECORD_LIST, ExpressionResultType.SORTED_LIST] as string[]).includes(type)) {
|
||||||
|
source[name] = results[0].values;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type === ExpressionResultType.SINGLE_VALUE) {
|
|
||||||
source[c.label || name] = results[0].values[0].value;
|
return { source, tips, typesOfMQE };
|
||||||
}
|
}
|
||||||
if (([ExpressionResultType.RECORD_LIST, ExpressionResultType.SORTED_LIST] as string[]).includes(type)) {
|
const params = await expressionsGraphqlPods();
|
||||||
source[name] = results[0].values;
|
if (!params) {
|
||||||
}
|
return { source: {}, tips: [], typesOfMQE: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
return source;
|
const dashboardStore = useDashboardStore();
|
||||||
|
const json = await dashboardStore.fetchMetricValue(params);
|
||||||
|
if (json.errors) {
|
||||||
|
ElMessage.error(json.errors);
|
||||||
|
return { source: {}, tips: [], typesOfMQE: [] };
|
||||||
|
}
|
||||||
|
const data = expressionsSource(json);
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function useExpressionsQueryPodsMetrics(
|
export async function useExpressionsQueryPodsMetrics(
|
||||||
pods: Array<(Instance | Endpoint | Service) & Indexable>,
|
pods: Array<(Instance | Endpoint | Service) & Indexable>,
|
||||||
config: {
|
config: {
|
||||||
expressions: string[];
|
expressions: string[];
|
||||||
typesOfMQE: string[];
|
|
||||||
subExpressions: string[];
|
subExpressions: string[];
|
||||||
metricConfig: MetricConfigOpt[];
|
metricConfig: MetricConfigOpt[];
|
||||||
},
|
},
|
||||||
@ -154,16 +167,13 @@ export async function useExpressionsQueryPodsMetrics(
|
|||||||
function expressionsGraphqlPods() {
|
function expressionsGraphqlPods() {
|
||||||
const metrics: string[] = [];
|
const metrics: string[] = [];
|
||||||
const subMetrics: string[] = [];
|
const subMetrics: string[] = [];
|
||||||
const metricTypes: string[] = [];
|
|
||||||
config.expressions = config.expressions || [];
|
config.expressions = config.expressions || [];
|
||||||
config.subExpressions = config.subExpressions || [];
|
config.subExpressions = config.subExpressions || [];
|
||||||
config.typesOfMQE = config.typesOfMQE || [];
|
|
||||||
|
|
||||||
for (let i = 0; i < config.expressions.length; i++) {
|
for (let i = 0; i < config.expressions.length; i++) {
|
||||||
if (config.expressions[i]) {
|
if (config.expressions[i]) {
|
||||||
metrics.push(config.expressions[i]);
|
metrics.push(config.expressions[i]);
|
||||||
subMetrics.push(config.subExpressions[i]);
|
subMetrics.push(config.subExpressions[i]);
|
||||||
metricTypes.push(config.typesOfMQE[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!metrics.length) {
|
if (!metrics.length) {
|
||||||
@ -214,16 +224,24 @@ export async function useExpressionsQueryPodsMetrics(
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const names: string[] = [];
|
const names: string[] = [];
|
||||||
|
const subNames: string[] = [];
|
||||||
const metricConfigArr: MetricConfigOpt[] = [];
|
const metricConfigArr: MetricConfigOpt[] = [];
|
||||||
const metricTypesArr: string[] = [];
|
const metricTypesArr: string[] = [];
|
||||||
|
const expressionsTips: string[] = [];
|
||||||
|
const subExpressionsTips: string[] = [];
|
||||||
const data = pods.map((d: any, idx: number) => {
|
const data = pods.map((d: any, idx: number) => {
|
||||||
for (let index = 0; index < config.expressions.length; index++) {
|
for (let index = 0; index < config.expressions.length; index++) {
|
||||||
const c: MetricConfigOpt = (config.metricConfig && config.metricConfig[index]) || {};
|
const c: MetricConfigOpt = (config.metricConfig && config.metricConfig[index]) || {};
|
||||||
const k = "expression" + idx + index;
|
const k = "expression" + idx + index;
|
||||||
const sub = "subexpression" + idx + index;
|
const sub = "subexpression" + idx + index;
|
||||||
const results = (resp.data[k] && resp.data[k].results) || [];
|
const obj = resp.data[k] || {};
|
||||||
const subResults = (resp.data[sub] && resp.data[sub].results) || [];
|
const results = obj.results || [];
|
||||||
|
const typesOfMQE = obj.type || "";
|
||||||
|
const subObj = resp.data[sub] || {};
|
||||||
|
const subResults = subObj.results || [];
|
||||||
|
|
||||||
|
expressionsTips.push(obj.error);
|
||||||
|
subExpressionsTips.push(subObj.error);
|
||||||
if (results.length > 1) {
|
if (results.length > 1) {
|
||||||
const labels = (c.label || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, ""));
|
const labels = (c.label || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, ""));
|
||||||
const labelsIdx = (c.labelsIndex || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, ""));
|
const labelsIdx = (c.labelsIndex || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, ""));
|
||||||
@ -248,33 +266,38 @@ export async function useExpressionsQueryPodsMetrics(
|
|||||||
if (!j) {
|
if (!j) {
|
||||||
names.push(name);
|
names.push(name);
|
||||||
metricConfigArr.push({ ...c, index: i });
|
metricConfigArr.push({ ...c, index: i });
|
||||||
metricTypesArr.push(config.typesOfMQE[index]);
|
metricTypesArr.push(typesOfMQE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!results[0]) {
|
if (!results[0]) {
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
const name = results[0].metric.name || "";
|
const name = config.expressions[index] || "";
|
||||||
|
const subName = config.subExpressions[index] || "";
|
||||||
if (!d[name]) {
|
if (!d[name]) {
|
||||||
d[name] = {};
|
d[name] = {};
|
||||||
}
|
}
|
||||||
d[name]["avg"] = [results[0].values[0].value];
|
d[name]["avg"] = [results[0].values[0].value];
|
||||||
if (subResults[0]) {
|
if (subResults[0]) {
|
||||||
d[name]["values"] = subResults[0].values.map((d: { value: number }) => d.value);
|
if (!d[subName]) {
|
||||||
|
d[subName] = {};
|
||||||
|
}
|
||||||
|
d[subName]["values"] = subResults[0].values.map((d: { value: number }) => d.value);
|
||||||
}
|
}
|
||||||
const j = names.find((d: string) => d === name);
|
const j = names.find((d: string) => d === name);
|
||||||
if (!j) {
|
if (!j) {
|
||||||
names.push(name);
|
names.push(name);
|
||||||
|
subNames.push(subName);
|
||||||
metricConfigArr.push(c);
|
metricConfigArr.push(c);
|
||||||
metricTypesArr.push(config.typesOfMQE[index]);
|
metricTypesArr.push(typesOfMQE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
});
|
});
|
||||||
|
|
||||||
return { data, names, metricConfigArr, metricTypesArr };
|
return { data, names, subNames, metricConfigArr, metricTypesArr, expressionsTips, subExpressionsTips };
|
||||||
}
|
}
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const params = await expressionsGraphqlPods();
|
const params = await expressionsGraphqlPods();
|
||||||
@ -284,7 +307,7 @@ export async function useExpressionsQueryPodsMetrics(
|
|||||||
ElMessage.error(json.errors);
|
ElMessage.error(json.errors);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const { data, names, metricTypesArr, metricConfigArr } = expressionsPodsSource(json);
|
const expressionParams = expressionsPodsSource(json);
|
||||||
|
|
||||||
return { data, names, metricTypesArr, metricConfigArr };
|
return expressionParams;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
import { MetricQueryTypes, Calculations } from "./data";
|
import { MetricQueryTypes, Calculations } from "./data";
|
||||||
import { MetricModes } from "@/views/dashboard/data";
|
import { MetricModes } from "@/views/dashboard/data";
|
||||||
|
|
||||||
export function useListConfig(config: Indexable, index: string) {
|
export function useListConfig(config: Indexable, index: number) {
|
||||||
if (config.metricModes === MetricModes.Expression) {
|
if (config.metricModes === MetricModes.Expression) {
|
||||||
return {
|
return {
|
||||||
isLinear: false,
|
isLinear: false,
|
||||||
|
@ -402,5 +402,8 @@ const msg = {
|
|||||||
monitorInstances: "Monitor Instances",
|
monitorInstances: "Monitor Instances",
|
||||||
processDashboards: "Process Dashboards",
|
processDashboards: "Process Dashboards",
|
||||||
instanceDashboards: "Instance Dashboards",
|
instanceDashboards: "Instance Dashboards",
|
||||||
|
detailLabel: "Detail Label",
|
||||||
|
summary: "Summary",
|
||||||
|
detail: "Detail",
|
||||||
};
|
};
|
||||||
export default msg;
|
export default msg;
|
||||||
|
@ -401,5 +401,8 @@ const msg = {
|
|||||||
monitorInstances: "Ejemplo de Monitor",
|
monitorInstances: "Ejemplo de Monitor",
|
||||||
processDashboards: "Tablero de proceso",
|
processDashboards: "Tablero de proceso",
|
||||||
instanceDashboards: "Tablero de ejemplo",
|
instanceDashboards: "Tablero de ejemplo",
|
||||||
|
detailLabel: "Detail Label",
|
||||||
|
summary: "Summary",
|
||||||
|
detail: "Detail",
|
||||||
};
|
};
|
||||||
export default msg;
|
export default msg;
|
||||||
|
@ -399,5 +399,8 @@ const msg = {
|
|||||||
monitorInstances: "监视实例",
|
monitorInstances: "监视实例",
|
||||||
processDashboards: "进程仪表板",
|
processDashboards: "进程仪表板",
|
||||||
instanceDashboards: "实例仪表板",
|
instanceDashboards: "实例仪表板",
|
||||||
|
detailLabel: "详细标签",
|
||||||
|
summary: "概括",
|
||||||
|
detail: "详细",
|
||||||
};
|
};
|
||||||
export default msg;
|
export default msg;
|
||||||
|
2
src/types/app.d.ts
vendored
2
src/types/app.d.ts
vendored
@ -42,7 +42,7 @@ export type EventParams = {
|
|||||||
dataIndex: number;
|
dataIndex: number;
|
||||||
data: unknown;
|
data: unknown;
|
||||||
dataType: string;
|
dataType: string;
|
||||||
value: number | Array<any>;
|
value: number | any[];
|
||||||
color: string;
|
color: string;
|
||||||
event: any;
|
event: any;
|
||||||
};
|
};
|
||||||
|
1
src/types/components.d.ts
vendored
1
src/types/components.d.ts
vendored
@ -22,7 +22,6 @@ declare module '@vue/runtime-core' {
|
|||||||
ElMenuItemGroup: typeof import('element-plus/es')['ElMenuItemGroup']
|
ElMenuItemGroup: typeof import('element-plus/es')['ElMenuItemGroup']
|
||||||
ElOption: typeof import('element-plus/es')['ElOption']
|
ElOption: typeof import('element-plus/es')['ElOption']
|
||||||
ElPagination: typeof import('element-plus/es')['ElPagination']
|
ElPagination: typeof import('element-plus/es')['ElPagination']
|
||||||
ElPopconfirm: typeof import('element-plus/es')['ElPopconfirm']
|
|
||||||
ElPopover: typeof import('element-plus/es')['ElPopover']
|
ElPopover: typeof import('element-plus/es')['ElPopover']
|
||||||
ElProgress: typeof import('element-plus/es')['ElProgress']
|
ElProgress: typeof import('element-plus/es')['ElProgress']
|
||||||
ElRadio: typeof import('element-plus/es')['ElRadio']
|
ElRadio: typeof import('element-plus/es')['ElRadio']
|
||||||
|
2
src/types/dashboard.d.ts
vendored
2
src/types/dashboard.d.ts
vendored
@ -15,7 +15,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { DurationTime } from "./app";
|
import { DurationTime } from "./app";
|
||||||
|
|
||||||
export type DashboardItem = {
|
export type DashboardItem = {
|
||||||
id?: string;
|
id?: string;
|
||||||
entity: string;
|
entity: string;
|
||||||
@ -80,6 +79,7 @@ export type MetricConfigOpt = {
|
|||||||
sortOrder?: string;
|
sortOrder?: string;
|
||||||
topN?: number;
|
topN?: number;
|
||||||
index?: number;
|
index?: number;
|
||||||
|
detailLabel?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface WidgetConfig {
|
export interface WidgetConfig {
|
||||||
|
@ -57,7 +57,7 @@ limitations under the License. -->
|
|||||||
import { useSelectorStore } from "@/store/modules/selectors";
|
import { useSelectorStore } from "@/store/modules/selectors";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
import { useQueryProcessor, useSourceProcessor } from "@/hooks/useMetricsProcessor";
|
import { useQueryProcessor, useSourceProcessor } from "@/hooks/useMetricsProcessor";
|
||||||
import { useExpressionsQueryProcessor, useExpressionsSourceProcessor } from "@/hooks/useExpressionsProcessor";
|
import { useExpressionsQueryProcessor } from "@/hooks/useExpressionsProcessor";
|
||||||
import graphs from "./graphs";
|
import graphs from "./graphs";
|
||||||
import { EntityType } from "./data";
|
import { EntityType } from "./data";
|
||||||
import timeFormat from "@/utils/timeFormat";
|
import timeFormat from "@/utils/timeFormat";
|
||||||
@ -130,11 +130,18 @@ limitations under the License. -->
|
|||||||
}
|
}
|
||||||
async function queryMetrics() {
|
async function queryMetrics() {
|
||||||
const isExpression = config.value.metricMode === MetricModes.Expression;
|
const isExpression = config.value.metricMode === MetricModes.Expression;
|
||||||
const params = isExpression
|
if (isExpression) {
|
||||||
? await useExpressionsQueryProcessor({
|
loading.value = true;
|
||||||
...config.value,
|
const params = await useExpressionsQueryProcessor({
|
||||||
})
|
metrics: config.value.expressions || [],
|
||||||
: await useQueryProcessor({ ...config.value });
|
metricConfig: config.value.metricConfig || [],
|
||||||
|
subExpressions: config.value.subExpressions || [],
|
||||||
|
});
|
||||||
|
loading.value = false;
|
||||||
|
source.value = params.source || {};
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const params = await useQueryProcessor({ ...config.value });
|
||||||
if (!params) {
|
if (!params) {
|
||||||
source.value = {};
|
source.value = {};
|
||||||
return;
|
return;
|
||||||
@ -149,9 +156,8 @@ limitations under the License. -->
|
|||||||
metrics: config.value.metrics || [],
|
metrics: config.value.metrics || [],
|
||||||
metricTypes: config.value.metricTypes || [],
|
metricTypes: config.value.metricTypes || [],
|
||||||
metricConfig: config.value.metricConfig || [],
|
metricConfig: config.value.metricConfig || [],
|
||||||
subExpressions: config.value.subExpressions || [],
|
|
||||||
};
|
};
|
||||||
source.value = isExpression ? await useExpressionsSourceProcessor(json, d) : await useSourceProcessor(json, d);
|
source.value = await useSourceProcessor(json, d);
|
||||||
}
|
}
|
||||||
watch(
|
watch(
|
||||||
() => appStoreWithOut.durationTime,
|
() => appStoreWithOut.durationTime,
|
||||||
@ -181,7 +187,7 @@ limitations under the License. -->
|
|||||||
|
|
||||||
.widget-chart {
|
.widget-chart {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
box-shadow: 0px 1px 4px 0px #00000029;
|
box-shadow: 0 1px 4px 0 #00000029;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -45,6 +45,7 @@ limitations under the License. -->
|
|||||||
subTypesOfMQE: dashboardStore.selectedGrid.subTypesOfMQE || [],
|
subTypesOfMQE: dashboardStore.selectedGrid.subTypesOfMQE || [],
|
||||||
}"
|
}"
|
||||||
:needQuery="true"
|
:needQuery="true"
|
||||||
|
@expressionTips="getErrors"
|
||||||
/>
|
/>
|
||||||
<div v-show="!graph.type" class="no-data">
|
<div v-show="!graph.type" class="no-data">
|
||||||
{{ t("noData") }}
|
{{ t("noData") }}
|
||||||
@ -54,7 +55,7 @@ limitations under the License. -->
|
|||||||
<div class="collapse" :style="{ height: configHeight + 'px' }">
|
<div class="collapse" :style="{ height: configHeight + 'px' }">
|
||||||
<el-collapse v-model="states.activeNames" :style="{ '--el-collapse-header-font-size': '15px' }">
|
<el-collapse v-model="states.activeNames" :style="{ '--el-collapse-header-font-size': '15px' }">
|
||||||
<el-collapse-item :title="t('selectVisualization')" name="1">
|
<el-collapse-item :title="t('selectVisualization')" name="1">
|
||||||
<MetricOptions @update="getSource" @loading="setLoading" />
|
<MetricOptions @update="getSource" @loading="setLoading" :errors="errors" :subErrors="subErrors" />
|
||||||
</el-collapse-item>
|
</el-collapse-item>
|
||||||
<el-collapse-item :title="t('graphStyles')" name="2">
|
<el-collapse-item :title="t('graphStyles')" name="2">
|
||||||
<component :is="`${graph.type}Config`" />
|
<component :is="`${graph.type}Config`" />
|
||||||
@ -102,6 +103,8 @@ limitations under the License. -->
|
|||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const appStoreWithOut = useAppStoreWithOut();
|
const appStoreWithOut = useAppStoreWithOut();
|
||||||
const loading = ref<boolean>(false);
|
const loading = ref<boolean>(false);
|
||||||
|
const errors = ref<string[]>([]);
|
||||||
|
const subErrors = ref<string[]>([]);
|
||||||
const states = reactive<{
|
const states = reactive<{
|
||||||
activeNames: string;
|
activeNames: string;
|
||||||
source: unknown;
|
source: unknown;
|
||||||
@ -128,6 +131,11 @@ limitations under the License. -->
|
|||||||
states.source = source;
|
states.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getErrors(params: { tips: string[]; subTips: string[] }) {
|
||||||
|
errors.value = params.tips;
|
||||||
|
subErrors.value = params.subTips;
|
||||||
|
}
|
||||||
|
|
||||||
function setLoading(load: boolean) {
|
function setLoading(load: boolean) {
|
||||||
loading.value = load;
|
loading.value = load;
|
||||||
}
|
}
|
||||||
@ -169,12 +177,15 @@ limitations under the License. -->
|
|||||||
applyConfig,
|
applyConfig,
|
||||||
cancelConfig,
|
cancelConfig,
|
||||||
getSource,
|
getSource,
|
||||||
|
getErrors,
|
||||||
setLoading,
|
setLoading,
|
||||||
widget,
|
widget,
|
||||||
graph,
|
graph,
|
||||||
title,
|
title,
|
||||||
tips,
|
tips,
|
||||||
hasAssociate,
|
hasAssociate,
|
||||||
|
errors,
|
||||||
|
subErrors,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -35,8 +35,8 @@ limitations under the License. -->
|
|||||||
@change="changeMetricMode"
|
@change="changeMetricMode"
|
||||||
/>
|
/>
|
||||||
<div v-if="isExpression && states.isList">
|
<div v-if="isExpression && states.isList">
|
||||||
<span class="title">Summary</span>
|
<span class="title">{{ t("summary") }}</span>
|
||||||
<span>Detail</span>
|
<span>{{ t("detail") }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-for="(metric, index) in states.metrics" :key="index" class="mb-10">
|
<div v-for="(metric, index) in states.metrics" :key="index" class="mb-10">
|
||||||
<span v-if="isExpression">
|
<span v-if="isExpression">
|
||||||
@ -93,8 +93,12 @@ limitations under the License. -->
|
|||||||
/>
|
/>
|
||||||
<Icon class="cp" iconName="remove_circle_outline" size="middle" @click="deleteMetric(index)" />
|
<Icon class="cp" iconName="remove_circle_outline" size="middle" @click="deleteMetric(index)" />
|
||||||
</span>
|
</span>
|
||||||
<div v-if="states.tips[index] && isExpression" class="ml-10 red sm">{{ states.tips[index] }}</div>
|
<div v-if="(errors || states.tips)[index] && isExpression" class="ml-10 red sm">
|
||||||
<div v-if="states.tips[index] && isExpression" class="ml-10 red sm">{{ states.tips[index] }}</div>
|
{{ (errors || states.tips)[index] }}
|
||||||
|
</div>
|
||||||
|
<div v-if="(subErrors || states.tips)[index] && isExpression" class="ml-10 red sm">
|
||||||
|
{{ (subErrors || states.tips)[index] }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>{{ t("visualization") }}</div>
|
<div>{{ t("visualization") }}</div>
|
||||||
<div class="chart-types">
|
<div class="chart-types">
|
||||||
@ -102,9 +106,7 @@ limitations under the License. -->
|
|||||||
v-for="(type, index) in setVisTypes"
|
v-for="(type, index) in setVisTypes"
|
||||||
:key="index"
|
:key="index"
|
||||||
@click="changeChartType(type)"
|
@click="changeChartType(type)"
|
||||||
:class="{
|
:class="{ active: type.value === graph.type }"
|
||||||
active: type.value === graph.type,
|
|
||||||
}"
|
|
||||||
>
|
>
|
||||||
{{ type.label }}
|
{{ type.label }}
|
||||||
</span>
|
</span>
|
||||||
@ -112,6 +114,7 @@ limitations under the License. -->
|
|||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { reactive, ref, computed } from "vue";
|
import { reactive, ref, computed } from "vue";
|
||||||
|
import type { PropType } from "vue";
|
||||||
import type { Option } from "@/types/app";
|
import type { Option } from "@/types/app";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
import {
|
import {
|
||||||
@ -129,14 +132,23 @@ limitations under the License. -->
|
|||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import Icon from "@/components/Icon.vue";
|
import Icon from "@/components/Icon.vue";
|
||||||
import { useQueryProcessor, useSourceProcessor } from "@/hooks/useMetricsProcessor";
|
import { useQueryProcessor, useSourceProcessor } from "@/hooks/useMetricsProcessor";
|
||||||
import { useExpressionsQueryProcessor, useExpressionsSourceProcessor } from "@/hooks/useExpressionsProcessor";
|
import { useExpressionsQueryProcessor } from "@/hooks/useExpressionsProcessor";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import type { DashboardItem, MetricConfigOpt } from "@/types/dashboard";
|
import type { DashboardItem, MetricConfigOpt } from "@/types/dashboard";
|
||||||
import Standard from "./Standard.vue";
|
import Standard from "./Standard.vue";
|
||||||
|
|
||||||
/*global defineEmits */
|
/*global defineEmits, Indexable */
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const emit = defineEmits(["update", "loading"]);
|
const emit = defineEmits(["update", "loading"]);
|
||||||
|
/*global defineProps */
|
||||||
|
defineProps({
|
||||||
|
errors: {
|
||||||
|
type: Array as PropType<string[]>,
|
||||||
|
},
|
||||||
|
subErrors: {
|
||||||
|
type: Array as PropType<string[]>,
|
||||||
|
},
|
||||||
|
});
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const isExpression = ref<boolean>(dashboardStore.selectedGrid.metricMode === MetricModes.Expression ? true : false);
|
const isExpression = ref<boolean>(dashboardStore.selectedGrid.metricMode === MetricModes.Expression ? true : false);
|
||||||
const metrics = computed(
|
const metrics = computed(
|
||||||
@ -398,26 +410,20 @@ limitations under the License. -->
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function queryMetricsWithExpressions() {
|
async function queryMetricsWithExpressions() {
|
||||||
const { metricConfig, typesOfMQE, expressions } = dashboardStore.selectedGrid;
|
const { expressions, metricConfig } = dashboardStore.selectedGrid;
|
||||||
if (!(expressions && expressions[0] && typesOfMQE && typesOfMQE[0])) {
|
if (!(expressions && expressions[0])) {
|
||||||
return emit("update", {});
|
return emit("update", {});
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = useExpressionsQueryProcessor({ ...states, metricConfig });
|
const params: Indexable = (await useExpressionsQueryProcessor({ ...states, metricConfig })) || {};
|
||||||
if (!params) {
|
states.tips = params.tips || [];
|
||||||
emit("update", {});
|
states.metricTypes = params.typesOfMQE || [];
|
||||||
return;
|
dashboardStore.selectWidget({
|
||||||
}
|
...dashboardStore.selectedGrid,
|
||||||
|
typesOfMQE: states.metricTypes,
|
||||||
|
});
|
||||||
|
|
||||||
emit("loading", true);
|
emit("update", params.source || {});
|
||||||
const json = await dashboardStore.fetchMetricValue(params);
|
|
||||||
emit("loading", false);
|
|
||||||
if (json.errors) {
|
|
||||||
ElMessage.error(json.errors);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const source = useExpressionsSourceProcessor(json, { ...states, metricConfig });
|
|
||||||
emit("update", source);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeDashboard(opt: any) {
|
function changeDashboard(opt: any) {
|
||||||
@ -490,13 +496,14 @@ limitations under the License. -->
|
|||||||
const metricConfig = config[index] ? config.splice(index, 1) : config;
|
const metricConfig = config[index] ? config.splice(index, 1) : config;
|
||||||
let p = {};
|
let p = {};
|
||||||
if (isExpression.value) {
|
if (isExpression.value) {
|
||||||
p = { typesOfMQE: states.metricTypes, expressions: states.metrics };
|
|
||||||
if (states.isList) {
|
if (states.isList) {
|
||||||
states.subMetrics = [""];
|
states.subMetrics.splice(index, 1);
|
||||||
states.subMetricTypes = [""];
|
states.subMetricTypes.splice(index, 1);
|
||||||
states.subTips = [""];
|
states.subTips.splice(index, 1);
|
||||||
p = {
|
p = {
|
||||||
...p,
|
...p,
|
||||||
|
typesOfMQE: states.metricTypes,
|
||||||
|
expressions: states.metrics,
|
||||||
subTypesOfMQE: states.subMetricTypes,
|
subTypesOfMQE: states.subMetricTypes,
|
||||||
subExpressions: states.subMetrics,
|
subExpressions: states.subMetrics,
|
||||||
};
|
};
|
||||||
@ -553,21 +560,10 @@ limitations under the License. -->
|
|||||||
async function changeExpression(event: any, index: number) {
|
async function changeExpression(event: any, index: number) {
|
||||||
const params = (event.target.textContent || "").replace(/\s+/g, "");
|
const params = (event.target.textContent || "").replace(/\s+/g, "");
|
||||||
|
|
||||||
if (params) {
|
states.metrics[index] = params;
|
||||||
const resp = await dashboardStore.getTypeOfMQE(params);
|
|
||||||
states.metrics[index] = params;
|
|
||||||
states.metricTypes[index] = resp.data.metricType.type;
|
|
||||||
states.tips[index] = resp.data.metricType.error || "";
|
|
||||||
} else {
|
|
||||||
states.metrics[index] = params;
|
|
||||||
states.metricTypes[index] = "";
|
|
||||||
states.tips[index] = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
dashboardStore.selectWidget({
|
dashboardStore.selectWidget({
|
||||||
...dashboardStore.selectedGrid,
|
...dashboardStore.selectedGrid,
|
||||||
expressions: states.metrics,
|
expressions: states.metrics,
|
||||||
typesOfMQE: states.metricTypes,
|
|
||||||
});
|
});
|
||||||
if (params) {
|
if (params) {
|
||||||
await queryMetrics();
|
await queryMetrics();
|
||||||
@ -576,17 +572,7 @@ limitations under the License. -->
|
|||||||
async function changeSubExpression(event: any, index: number) {
|
async function changeSubExpression(event: any, index: number) {
|
||||||
const params = (event.target.textContent || "").replace(/\s+/g, "");
|
const params = (event.target.textContent || "").replace(/\s+/g, "");
|
||||||
|
|
||||||
if (params) {
|
states.subMetrics[index] = params;
|
||||||
const resp = await dashboardStore.getTypeOfMQE(params);
|
|
||||||
states.subMetrics[index] = params;
|
|
||||||
states.subMetricTypes[index] = resp.data.metricType.type;
|
|
||||||
states.subTips[index] = resp.data.metricType.error || "";
|
|
||||||
} else {
|
|
||||||
states.subMetrics[index] = params;
|
|
||||||
states.subMetricTypes[index] = "";
|
|
||||||
states.subTips[index] = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
dashboardStore.selectWidget({
|
dashboardStore.selectWidget({
|
||||||
...dashboardStore.selectedGrid,
|
...dashboardStore.selectedGrid,
|
||||||
subExpressions: states.subMetrics,
|
subExpressions: states.subMetrics,
|
||||||
@ -640,8 +626,8 @@ limitations under the License. -->
|
|||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
color: #606266;
|
color: #606266;
|
||||||
outline: none;
|
outline: none;
|
||||||
height: 26px;
|
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
|
min-height: 26px;
|
||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
border-color: #409eff;
|
border-color: #409eff;
|
||||||
|
@ -34,7 +34,7 @@ limitations under the License. -->
|
|||||||
class="input"
|
class="input"
|
||||||
v-model="currentMetric.label"
|
v-model="currentMetric.label"
|
||||||
size="small"
|
size="small"
|
||||||
placeholder="Please input a name"
|
placeholder="Please input a label"
|
||||||
@change="
|
@change="
|
||||||
updateConfig(index, {
|
updateConfig(index, {
|
||||||
label: encodeURIComponent(currentMetric.label || ''),
|
label: encodeURIComponent(currentMetric.label || ''),
|
||||||
@ -42,13 +42,21 @@ limitations under the License. -->
|
|||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div class="item mb-10" v-if="isList && isExpression">
|
||||||
class="item mb-10"
|
<span class="label">{{ t("detailLabel") }}</span>
|
||||||
v-if="
|
<el-input
|
||||||
[ProtocolTypes.ReadLabeledMetricsValues].includes(metricType) &&
|
class="input"
|
||||||
dashboardStore.selectedGrid.metricMode === MetricModes.General
|
v-model="currentMetric.detailLabel"
|
||||||
"
|
size="small"
|
||||||
>
|
placeholder="Please input a label"
|
||||||
|
@change="
|
||||||
|
updateConfig(index, {
|
||||||
|
detailLabel: encodeURIComponent(currentMetric.detailLabel || ''),
|
||||||
|
})
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="item mb-10" v-if="[ProtocolTypes.ReadLabeledMetricsValues].includes(metricType) && !isExpression">
|
||||||
<span class="label">{{ t("labelsIndex") }}</span>
|
<span class="label">{{ t("labelsIndex") }}</span>
|
||||||
<el-input
|
<el-input
|
||||||
class="input"
|
class="input"
|
||||||
@ -57,7 +65,7 @@ limitations under the License. -->
|
|||||||
placeholder="auto"
|
placeholder="auto"
|
||||||
@change="
|
@change="
|
||||||
updateConfig(index, {
|
updateConfig(index, {
|
||||||
labelsIndex: encodeURIComponent(currentMetric.labelsIndex),
|
labelsIndex: encodeURIComponent(currentMetric.labelsIndex || ''),
|
||||||
})
|
})
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
@ -136,6 +144,10 @@ limitations under the License. -->
|
|||||||
].includes(metricType.value)
|
].includes(metricType.value)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
const isList = computed(() => {
|
||||||
|
const graph = dashboardStore.selectedGrid.graph || {};
|
||||||
|
return ListChartTypes.includes(graph.type);
|
||||||
|
});
|
||||||
const isTopn = computed(() =>
|
const isTopn = computed(() =>
|
||||||
[ProtocolTypes.SortMetrics, ProtocolTypes.ReadSampledRecords, ProtocolTypes.ReadRecords].includes(
|
[ProtocolTypes.SortMetrics, ProtocolTypes.ReadSampledRecords, ProtocolTypes.ReadRecords].includes(
|
||||||
metricTypes.value[props.index],
|
metricTypes.value[props.index],
|
||||||
@ -162,6 +174,7 @@ limitations under the License. -->
|
|||||||
watch(
|
watch(
|
||||||
() => props.currentMetricConfig,
|
() => props.currentMetricConfig,
|
||||||
() => {
|
() => {
|
||||||
|
isExpression.value = dashboardStore.selectedGrid.metricMode === MetricModes.Expression;
|
||||||
currentMetric.value = {
|
currentMetric.value = {
|
||||||
...props.currentMetricConfig,
|
...props.currentMetricConfig,
|
||||||
topN: Number(props.currentMetricConfig.topN) || 10,
|
topN: Number(props.currentMetricConfig.topN) || 10,
|
||||||
|
@ -82,7 +82,7 @@ limitations under the License. -->
|
|||||||
import graphs from "../graphs";
|
import graphs from "../graphs";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { useQueryProcessor, useSourceProcessor } from "@/hooks/useMetricsProcessor";
|
import { useQueryProcessor, useSourceProcessor } from "@/hooks/useMetricsProcessor";
|
||||||
import { useExpressionsQueryProcessor, useExpressionsSourceProcessor } from "@/hooks/useExpressionsProcessor";
|
import { useExpressionsQueryProcessor } from "@/hooks/useExpressionsProcessor";
|
||||||
import { EntityType, ListChartTypes } from "../data";
|
import { EntityType, ListChartTypes } from "../data";
|
||||||
import type { EventParams } from "@/types/dashboard";
|
import type { EventParams } from "@/types/dashboard";
|
||||||
import getDashboard from "@/hooks/useDashboardsSession";
|
import getDashboard from "@/hooks/useDashboardsSession";
|
||||||
@ -121,13 +121,18 @@ limitations under the License. -->
|
|||||||
|
|
||||||
async function queryMetrics() {
|
async function queryMetrics() {
|
||||||
const isExpression = props.data.metricMode === MetricModes.Expression;
|
const isExpression = props.data.metricMode === MetricModes.Expression;
|
||||||
const params = isExpression
|
if (isExpression) {
|
||||||
? await useExpressionsQueryProcessor({
|
loading.value = true;
|
||||||
metrics: props.data.expressions,
|
const e = {
|
||||||
metricTypes: props.data.typesOfMQE,
|
metrics: props.data.expressions || [],
|
||||||
metricConfig: props.data.metricConfig,
|
metricConfig: props.data.metricConfig || [],
|
||||||
})
|
};
|
||||||
: await useQueryProcessor({ ...props.data });
|
const params = (await useExpressionsQueryProcessor(e)) || {};
|
||||||
|
loading.value = false;
|
||||||
|
state.source = params.source || {};
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const params = await useQueryProcessor({ ...props.data });
|
||||||
|
|
||||||
if (!params) {
|
if (!params) {
|
||||||
state.source = {};
|
state.source = {};
|
||||||
@ -144,12 +149,7 @@ limitations under the License. -->
|
|||||||
metricTypes: props.data.metricTypes || [],
|
metricTypes: props.data.metricTypes || [],
|
||||||
metricConfig: props.data.metricConfig || [],
|
metricConfig: props.data.metricConfig || [],
|
||||||
};
|
};
|
||||||
const e = {
|
state.source = await useSourceProcessor(json, d);
|
||||||
metrics: props.data.expressions || [],
|
|
||||||
metricTypes: props.data.typesOfMQE || [],
|
|
||||||
metricConfig: props.data.metricConfig || [],
|
|
||||||
};
|
|
||||||
state.source = isExpression ? await useExpressionsSourceProcessor(json, e) : await useSourceProcessor(json, d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeWidget() {
|
function removeWidget() {
|
||||||
|
@ -36,9 +36,9 @@ limitations under the License. -->
|
|||||||
<ColumnGraph
|
<ColumnGraph
|
||||||
:intervalTime="intervalTime"
|
:intervalTime="intervalTime"
|
||||||
:colMetrics="colMetrics"
|
:colMetrics="colMetrics"
|
||||||
|
:colSubMetrics="colSubMetrics"
|
||||||
:config="{
|
:config="{
|
||||||
...config,
|
...config,
|
||||||
metrics: colMetrics,
|
|
||||||
metricConfig,
|
metricConfig,
|
||||||
metricTypes,
|
metricTypes,
|
||||||
metricMode,
|
metricMode,
|
||||||
@ -96,6 +96,7 @@ limitations under the License. -->
|
|||||||
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(["expressionTips"]);
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const selectorStore = useSelectorStore();
|
const selectorStore = useSelectorStore();
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
@ -103,6 +104,7 @@ limitations under the License. -->
|
|||||||
const endpoints = ref<Endpoint[]>([]);
|
const endpoints = ref<Endpoint[]>([]);
|
||||||
const searchText = ref<string>("");
|
const searchText = ref<string>("");
|
||||||
const colMetrics = ref<string[]>([]);
|
const colMetrics = ref<string[]>([]);
|
||||||
|
const colSubMetrics = ref<string[]>([]);
|
||||||
const metricConfig = ref<MetricConfigOpt[]>(props.config.metricConfig || []);
|
const metricConfig = ref<MetricConfigOpt[]>(props.config.metricConfig || []);
|
||||||
const metricTypes = ref<string[]>(props.config.metricTypes || []);
|
const metricTypes = ref<string[]>(props.config.metricTypes || []);
|
||||||
const metricMode = ref<string>(props.config.metricMode);
|
const metricMode = ref<string>(props.config.metricMode);
|
||||||
@ -167,26 +169,29 @@ limitations under the License. -->
|
|||||||
}
|
}
|
||||||
async function queryEndpointExpressions(currentPods: Endpoint[]) {
|
async function queryEndpointExpressions(currentPods: Endpoint[]) {
|
||||||
const expressions = props.config.expressions || [];
|
const expressions = props.config.expressions || [];
|
||||||
const typesOfMQE = props.config.typesOfMQE || [];
|
|
||||||
const subExpressions = props.config.subExpressions || [];
|
const subExpressions = props.config.subExpressions || [];
|
||||||
|
|
||||||
if (expressions.length && expressions[0] && typesOfMQE.length && typesOfMQE[0]) {
|
if (expressions.length && expressions[0]) {
|
||||||
const params = await useExpressionsQueryPodsMetrics(
|
const params = await useExpressionsQueryPodsMetrics(
|
||||||
currentPods,
|
currentPods,
|
||||||
{ ...props.config, metricConfig: metricConfig.value || [], typesOfMQE, expressions, subExpressions },
|
{ metricConfig: metricConfig.value || [], expressions, subExpressions },
|
||||||
EntityType[2].value,
|
EntityType[2].value,
|
||||||
);
|
);
|
||||||
endpoints.value = params.data;
|
endpoints.value = params.data;
|
||||||
colMetrics.value = params.names;
|
colMetrics.value = params.names;
|
||||||
metricTypes.value = params.metricTypesArr;
|
metricTypes.value = params.metricTypesArr;
|
||||||
metricConfig.value = params.metricConfigArr;
|
metricConfig.value = params.metricConfigArr;
|
||||||
|
colSubMetrics.value = params.colSubMetrics;
|
||||||
|
emit("expressionTips", { tips: params.expressionsTips, subTips: params.subExpressionsTips });
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
endpoints.value = currentPods;
|
endpoints.value = currentPods;
|
||||||
colMetrics.value = [];
|
colMetrics.value = [];
|
||||||
|
colSubMetrics.value = [];
|
||||||
metricTypes.value = [];
|
metricTypes.value = [];
|
||||||
metricConfig.value = [];
|
metricConfig.value = [];
|
||||||
|
emit("expressionTips", [], []);
|
||||||
}
|
}
|
||||||
function clickEndpoint(scope: any) {
|
function clickEndpoint(scope: any) {
|
||||||
const { dashboard } = getDashboard({
|
const { dashboard } = getDashboard({
|
||||||
@ -230,9 +235,9 @@ limitations under the License. -->
|
|||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import "./style.scss";
|
@import url("./style.scss");
|
||||||
|
|
||||||
.tips {
|
.tips {
|
||||||
color: rgba(255, 0, 0, 0.5);
|
color: rgb(255 0 0 / 50%);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -35,9 +35,9 @@ limitations under the License. -->
|
|||||||
<ColumnGraph
|
<ColumnGraph
|
||||||
:intervalTime="intervalTime"
|
:intervalTime="intervalTime"
|
||||||
:colMetrics="colMetrics"
|
:colMetrics="colMetrics"
|
||||||
|
:colSubMetrics="colSubMetrics"
|
||||||
:config="{
|
:config="{
|
||||||
...config,
|
...config,
|
||||||
metrics: colMetrics,
|
|
||||||
metricConfig,
|
metricConfig,
|
||||||
metricTypes,
|
metricTypes,
|
||||||
metricMode,
|
metricMode,
|
||||||
@ -122,6 +122,7 @@ limitations under the License. -->
|
|||||||
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
||||||
needQuery: { type: Boolean, default: false },
|
needQuery: { type: Boolean, default: false },
|
||||||
});
|
});
|
||||||
|
const emit = defineEmits(["expressionTips"]);
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const selectorStore = useSelectorStore();
|
const selectorStore = useSelectorStore();
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
@ -130,6 +131,7 @@ limitations under the License. -->
|
|||||||
const pageSize = 10;
|
const pageSize = 10;
|
||||||
const searchText = ref<string>("");
|
const searchText = ref<string>("");
|
||||||
const colMetrics = ref<string[]>([]);
|
const colMetrics = ref<string[]>([]);
|
||||||
|
const colSubMetrics = ref<string[]>([]);
|
||||||
const metricConfig = ref<MetricConfigOpt[]>(props.config.metricConfig || []);
|
const metricConfig = ref<MetricConfigOpt[]>(props.config.metricConfig || []);
|
||||||
const metricTypes = ref<string[]>(props.config.metricTypes || []);
|
const metricTypes = ref<string[]>(props.config.metricTypes || []);
|
||||||
const pods = ref<Instance[]>([]); // all instances
|
const pods = ref<Instance[]>([]); // all instances
|
||||||
@ -192,6 +194,7 @@ limitations under the License. -->
|
|||||||
colMetrics.value = names;
|
colMetrics.value = names;
|
||||||
metricTypes.value = metricTypesArr;
|
metricTypes.value = metricTypesArr;
|
||||||
metricConfig.value = metricConfigArr;
|
metricConfig.value = metricConfigArr;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
instances.value = currentInstances;
|
instances.value = currentInstances;
|
||||||
@ -202,26 +205,29 @@ limitations under the License. -->
|
|||||||
|
|
||||||
async function queryInstanceExpressions(currentInstances: Instance[]) {
|
async function queryInstanceExpressions(currentInstances: Instance[]) {
|
||||||
const expressions = props.config.expressions || [];
|
const expressions = props.config.expressions || [];
|
||||||
const typesOfMQE = props.config.typesOfMQE || [];
|
|
||||||
const subExpressions = props.config.subExpressions || [];
|
const subExpressions = props.config.subExpressions || [];
|
||||||
|
|
||||||
if (expressions.length && expressions[0] && typesOfMQE.length && typesOfMQE[0]) {
|
if (expressions.length && expressions[0]) {
|
||||||
const params = await useExpressionsQueryPodsMetrics(
|
const params = await useExpressionsQueryPodsMetrics(
|
||||||
currentInstances,
|
currentInstances,
|
||||||
{ ...props.config, metricConfig: metricConfig.value || [], typesOfMQE, expressions, subExpressions },
|
{ metricConfig: metricConfig.value || [], expressions, subExpressions },
|
||||||
EntityType[3].value,
|
EntityType[3].value,
|
||||||
);
|
);
|
||||||
instances.value = params.data;
|
instances.value = params.data;
|
||||||
colMetrics.value = params.names;
|
colMetrics.value = params.names;
|
||||||
|
colSubMetrics.value = params.colSubMetrics;
|
||||||
metricTypes.value = params.metricTypesArr;
|
metricTypes.value = params.metricTypesArr;
|
||||||
metricConfig.value = params.metricConfigArr;
|
metricConfig.value = params.metricConfigArr;
|
||||||
|
emit("expressionTips", { tips: params.expressionsTips, subTips: params.subExpressionsTips });
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
instances.value = currentInstances;
|
instances.value = currentInstances;
|
||||||
|
colSubMetrics.value = [];
|
||||||
colMetrics.value = [];
|
colMetrics.value = [];
|
||||||
metricTypes.value = [];
|
metricTypes.value = [];
|
||||||
metricConfig.value = [];
|
metricConfig.value = [];
|
||||||
|
emit("expressionTips", [], []);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clickInstance(scope: any) {
|
function clickInstance(scope: any) {
|
||||||
@ -281,7 +287,7 @@ limitations under the License. -->
|
|||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import "./style.scss";
|
@import url("./style.scss");
|
||||||
|
|
||||||
.attributes {
|
.attributes {
|
||||||
max-height: 400px;
|
max-height: 400px;
|
||||||
|
@ -47,9 +47,9 @@ limitations under the License. -->
|
|||||||
<ColumnGraph
|
<ColumnGraph
|
||||||
:intervalTime="intervalTime"
|
:intervalTime="intervalTime"
|
||||||
:colMetrics="colMetrics"
|
:colMetrics="colMetrics"
|
||||||
|
:colSubMetrics="colSubMetrics"
|
||||||
:config="{
|
:config="{
|
||||||
...config,
|
...config,
|
||||||
metrics: colMetrics,
|
|
||||||
metricConfig,
|
metricConfig,
|
||||||
metricTypes,
|
metricTypes,
|
||||||
metricMode,
|
metricMode,
|
||||||
@ -114,6 +114,7 @@ limitations under the License. -->
|
|||||||
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
||||||
isEdit: { type: Boolean, default: false },
|
isEdit: { type: Boolean, default: false },
|
||||||
});
|
});
|
||||||
|
const emit = defineEmits(["expressionTips"]);
|
||||||
const selectorStore = useSelectorStore();
|
const selectorStore = useSelectorStore();
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const appStore = useAppStoreWithOut();
|
const appStore = useAppStoreWithOut();
|
||||||
@ -121,6 +122,7 @@ limitations under the License. -->
|
|||||||
const pageSize = 10;
|
const pageSize = 10;
|
||||||
const services = ref<Service[]>([]);
|
const services = ref<Service[]>([]);
|
||||||
const colMetrics = ref<string[]>([]);
|
const colMetrics = ref<string[]>([]);
|
||||||
|
const colSubMetrics = ref<string[]>([]);
|
||||||
const searchText = ref<string>("");
|
const searchText = ref<string>("");
|
||||||
const groups = ref<any>({});
|
const groups = ref<any>({});
|
||||||
const sortServices = ref<(Service & { merge: boolean })[]>([]);
|
const sortServices = ref<(Service & { merge: boolean })[]>([]);
|
||||||
@ -250,25 +252,28 @@ limitations under the License. -->
|
|||||||
}
|
}
|
||||||
async function queryServiceExpressions(currentServices: Service[]) {
|
async function queryServiceExpressions(currentServices: Service[]) {
|
||||||
const expressions = props.config.expressions || [];
|
const expressions = props.config.expressions || [];
|
||||||
const typesOfMQE = props.config.typesOfMQE || [];
|
|
||||||
const subExpressions = props.config.subExpressions || [];
|
const subExpressions = props.config.subExpressions || [];
|
||||||
|
|
||||||
if (expressions.length && expressions[0] && typesOfMQE.length && typesOfMQE[0]) {
|
if (expressions.length && expressions[0]) {
|
||||||
const params = await useExpressionsQueryPodsMetrics(
|
const params = await useExpressionsQueryPodsMetrics(
|
||||||
currentServices,
|
currentServices,
|
||||||
{ ...props.config, metricConfig: metricConfig.value || [], typesOfMQE, expressions, subExpressions },
|
{ metricConfig: metricConfig.value || [], expressions, subExpressions },
|
||||||
EntityType[0].value,
|
EntityType[0].value,
|
||||||
);
|
);
|
||||||
services.value = params.data;
|
services.value = params.data;
|
||||||
colMetrics.value = params.names;
|
colMetrics.value = params.names;
|
||||||
|
colSubMetrics.value = params.subNames;
|
||||||
metricTypes.value = params.metricTypesArr;
|
metricTypes.value = params.metricTypesArr;
|
||||||
metricConfig.value = params.metricConfigArr;
|
metricConfig.value = params.metricConfigArr;
|
||||||
|
emit("expressionTips", { tips: params.expressionsTips, subTips: params.subExpressionsTips });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
services.value = currentServices;
|
services.value = currentServices;
|
||||||
colMetrics.value = [];
|
colMetrics.value = [];
|
||||||
|
colSubMetrics.value = [];
|
||||||
metricTypes.value = [];
|
metricTypes.value = [];
|
||||||
metricConfig.value = [];
|
metricConfig.value = [];
|
||||||
|
emit("expressionTips", [], []);
|
||||||
}
|
}
|
||||||
function objectSpanMethod(param: any): any {
|
function objectSpanMethod(param: any): any {
|
||||||
if (!props.config.showGroup) {
|
if (!props.config.showGroup) {
|
||||||
@ -329,5 +334,5 @@ limitations under the License. -->
|
|||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@import "./style.scss";
|
@import url("./style.scss");
|
||||||
</style>
|
</style>
|
||||||
|
@ -48,7 +48,8 @@ limitations under the License. -->
|
|||||||
<div class="view-line">
|
<div class="view-line">
|
||||||
<Line
|
<Line
|
||||||
:data="{
|
:data="{
|
||||||
[metric]: scope.row[metric] && scope.row[metric].values,
|
[decodeURIComponent(getLabel(colSubMetrics[index], index, true)) || metric]:
|
||||||
|
scope.row[colSubMetrics[index] || metric] && scope.row[colSubMetrics[index] || metric].values,
|
||||||
}"
|
}"
|
||||||
:intervalTime="intervalTime"
|
:intervalTime="intervalTime"
|
||||||
:config="{
|
:config="{
|
||||||
@ -86,11 +87,11 @@ limitations under the License. -->
|
|||||||
|
|
||||||
/*global defineProps */
|
/*global defineProps */
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
colMetrics: { type: Object },
|
colMetrics: { type: Array as PropType<string[]>, default: () => [] },
|
||||||
|
colSubMetrics: { type: Array as PropType<string[]>, default: () => [] },
|
||||||
config: {
|
config: {
|
||||||
type: Object as PropType<{
|
type: Object as PropType<{
|
||||||
i: string;
|
i: string;
|
||||||
metrics: string[];
|
|
||||||
metricTypes: string[];
|
metricTypes: string[];
|
||||||
metricConfig: MetricConfigOpt[];
|
metricConfig: MetricConfigOpt[];
|
||||||
metricMode: string;
|
metricMode: string;
|
||||||
@ -100,7 +101,7 @@ limitations under the License. -->
|
|||||||
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
||||||
});
|
});
|
||||||
|
|
||||||
function getUnit(index: string) {
|
function getUnit(index: number) {
|
||||||
const i = Number(index);
|
const i = Number(index);
|
||||||
const u = props.config.metricConfig && props.config.metricConfig[i] && props.config.metricConfig[i].unit;
|
const u = props.config.metricConfig && props.config.metricConfig[i] && props.config.metricConfig[i].unit;
|
||||||
if (u) {
|
if (u) {
|
||||||
@ -108,9 +109,15 @@ limitations under the License. -->
|
|||||||
}
|
}
|
||||||
return encodeURIComponent("");
|
return encodeURIComponent("");
|
||||||
}
|
}
|
||||||
function getLabel(metric: string, index: string) {
|
function getLabel(metric: string, index: number, isDetail?: boolean) {
|
||||||
const i = Number(index);
|
const i = Number(index);
|
||||||
const label = props.config.metricConfig && props.config.metricConfig[i] && props.config.metricConfig[i].label;
|
let label = "";
|
||||||
|
if (isDetail) {
|
||||||
|
label =
|
||||||
|
(props.config.metricConfig && props.config.metricConfig[i] && props.config.metricConfig[i].detailLabel) || "";
|
||||||
|
} else {
|
||||||
|
label = (props.config.metricConfig && props.config.metricConfig[i] && props.config.metricConfig[i].label) || "";
|
||||||
|
}
|
||||||
if (label) {
|
if (label) {
|
||||||
if (
|
if (
|
||||||
(
|
(
|
||||||
@ -128,7 +135,7 @@ limitations under the License. -->
|
|||||||
}
|
}
|
||||||
return encodeURIComponent(label);
|
return encodeURIComponent(label);
|
||||||
}
|
}
|
||||||
return encodeURIComponent(metric);
|
return encodeURIComponent(metric || "");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
Loading…
Reference in New Issue
Block a user