mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-13 08:17:33 +00:00
feat: add pod topology expression
This commit is contained in:
parent
4d032d96ac
commit
2d5f004ca2
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { RespFields } from "./data";
|
import { RespFields } from "./data";
|
||||||
import { ExpressionResultType } from "@/views/dashboard/data";
|
import { EntityType, ExpressionResultType } from "@/views/dashboard/data";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
import { useSelectorStore } from "@/store/modules/selectors";
|
import { useSelectorStore } from "@/store/modules/selectors";
|
||||||
@ -23,7 +23,6 @@ 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";
|
||||||
import type { Node, Call } from "@/types/topology";
|
import type { Node, Call } from "@/types/topology";
|
||||||
import { MetricCatalog } from "@/views/dashboard/data";
|
|
||||||
|
|
||||||
export async function useExpressionsQueryProcessor(config: Indexable) {
|
export async function useExpressionsQueryProcessor(config: Indexable) {
|
||||||
function expressionsGraphqlPods() {
|
function expressionsGraphqlPods() {
|
||||||
@ -315,8 +314,9 @@ export async function useExpressionsQueryPodsMetrics(
|
|||||||
return expressionParams;
|
return expressionParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useQueryTopologyExpressionsProcessor(metrics: string[], instances: any[]) {
|
export function useQueryTopologyExpressionsProcessor(metrics: string[], instances: (Call | Node)[]) {
|
||||||
const appStore = useAppStoreWithOut();
|
const appStore = useAppStoreWithOut();
|
||||||
|
const dashboardStore = useDashboardStore();
|
||||||
|
|
||||||
function getExpressionQuery() {
|
function getExpressionQuery() {
|
||||||
const conditions: { [key: string]: unknown } = {
|
const conditions: { [key: string]: unknown } = {
|
||||||
@ -324,11 +324,43 @@ export function useQueryTopologyExpressionsProcessor(metrics: string[], instance
|
|||||||
};
|
};
|
||||||
const variables: string[] = [`$duration: Duration!`];
|
const variables: string[] = [`$duration: Duration!`];
|
||||||
const fragmentList = instances.map((d: any, index: number) => {
|
const fragmentList = instances.map((d: any, index: number) => {
|
||||||
|
let serviceName;
|
||||||
|
let destServiceName;
|
||||||
|
let endpointName;
|
||||||
|
let serviceInstanceName;
|
||||||
|
let destServiceInstanceName;
|
||||||
|
let destEndpointName;
|
||||||
|
if (d.sourceObj && d.targetObj) {
|
||||||
|
// instances = Calls
|
||||||
|
serviceName = d.sourceObj.serviceName || d.sourceObj.name;
|
||||||
|
destServiceName = d.targetObj.serviceName || d.targetObj.name;
|
||||||
|
if (EntityType[4].value === dashboardStore.entity) {
|
||||||
|
serviceInstanceName = d.sourceObj.name;
|
||||||
|
destServiceInstanceName = d.targetObj.name;
|
||||||
|
}
|
||||||
|
if (EntityType[2].value === dashboardStore.entity) {
|
||||||
|
endpointName = d.sourceObj.name;
|
||||||
|
destEndpointName = d.targetObj.name;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// instances = Nodes
|
||||||
|
serviceName = d.serviceName || d.name;
|
||||||
|
if (EntityType[4].value === dashboardStore.entity) {
|
||||||
|
serviceInstanceName = d.name;
|
||||||
|
}
|
||||||
|
if (EntityType[2].value === dashboardStore.entity) {
|
||||||
|
endpointName = d.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
const entity = {
|
const entity = {
|
||||||
serviceName: d.sourceObj ? d.sourceObj.name : d.name,
|
serviceName,
|
||||||
normal: true,
|
normal: true,
|
||||||
|
serviceInstanceName,
|
||||||
|
endpointName,
|
||||||
|
destServiceName,
|
||||||
destNormal: true,
|
destNormal: true,
|
||||||
destServiceName: (d.targetObj && d.targetObj.name) || undefined,
|
destServiceInstanceName,
|
||||||
|
destEndpointName,
|
||||||
};
|
};
|
||||||
variables.push(`$entity${index}: Entity!`);
|
variables.push(`$entity${index}: Entity!`);
|
||||||
conditions[`entity${index}`] = entity;
|
conditions[`entity${index}`] = entity;
|
||||||
|
@ -69,7 +69,7 @@ limitations under the License. -->
|
|||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
import { useSelectorStore } from "@/store/modules/selectors";
|
import { useSelectorStore } from "@/store/modules/selectors";
|
||||||
import { useAppStoreWithOut } from "@/store/modules/app";
|
import { useAppStoreWithOut } from "@/store/modules/app";
|
||||||
import { EntityType, DepthList } from "../../../data";
|
import { EntityType, DepthList, MetricModes } from "../../../data";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import Sankey from "./Sankey.vue";
|
import Sankey from "./Sankey.vue";
|
||||||
import Settings from "./Settings.vue";
|
import Settings from "./Settings.vue";
|
||||||
@ -119,10 +119,16 @@ limitations under the License. -->
|
|||||||
};
|
};
|
||||||
height.value = dom.height - 70;
|
height.value = dom.height - 70;
|
||||||
width.value = dom.width - 5;
|
width.value = dom.width - 5;
|
||||||
|
if (settings.value.metricMode === MetricModes.Expression) {
|
||||||
|
topologyStore.queryNodeExpressions(settings.value.nodeExpressions || []);
|
||||||
|
topologyStore.getLinkExpressions(settings.value.linkClientExpressions || []);
|
||||||
|
topologyStore.getLinkExpressions(settings.value.linkServerExpressions || []);
|
||||||
|
} else {
|
||||||
topologyStore.getLinkClientMetrics(settings.value.linkClientMetrics || []);
|
topologyStore.getLinkClientMetrics(settings.value.linkClientMetrics || []);
|
||||||
topologyStore.getLinkServerMetrics(settings.value.linkServerMetrics || []);
|
topologyStore.getLinkServerMetrics(settings.value.linkServerMetrics || []);
|
||||||
topologyStore.queryNodeMetrics(settings.value.nodeMetrics || []);
|
topologyStore.queryNodeMetrics(settings.value.nodeMetrics || []);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function resize() {
|
function resize() {
|
||||||
const dom = document.querySelector(".topology")?.getBoundingClientRect() || {
|
const dom = document.querySelector(".topology")?.getBoundingClientRect() || {
|
||||||
|
@ -23,6 +23,7 @@ limitations under the License. -->
|
|||||||
import type { Node, Call } from "@/types/topology";
|
import type { Node, Call } from "@/types/topology";
|
||||||
import type { MetricConfigOpt } from "@/types/dashboard";
|
import type { MetricConfigOpt } from "@/types/dashboard";
|
||||||
import { aggregation } from "@/hooks/useMetricsProcessor";
|
import { aggregation } from "@/hooks/useMetricsProcessor";
|
||||||
|
import { MetricModes } from "../../../data";
|
||||||
|
|
||||||
/*global defineEmits, defineProps */
|
/*global defineEmits, defineProps */
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -75,8 +76,14 @@ limitations under the License. -->
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
function linkTooltip(data: Call) {
|
function linkTooltip(data: Call) {
|
||||||
const clientMetrics: string[] = Object.keys(topologyStore.linkClientMetrics);
|
const clientMetrics: string[] =
|
||||||
const serverMetrics: string[] = Object.keys(topologyStore.linkServerMetrics);
|
props.settings.metricMode === MetricModes.Expression
|
||||||
|
? props.settings.linkClientExpressions
|
||||||
|
: props.settings.linkClientMetrics;
|
||||||
|
const serverMetrics: string[] =
|
||||||
|
props.settings.metricMode === MetricModes.Expression
|
||||||
|
? props.settings.linkServerExpressions
|
||||||
|
: props.settings.linkServerMetrics;
|
||||||
const linkServerMetricConfig: MetricConfigOpt[] = props.settings.linkServerMetricConfig || [];
|
const linkServerMetricConfig: MetricConfigOpt[] = props.settings.linkServerMetricConfig || [];
|
||||||
const linkClientMetricConfig: MetricConfigOpt[] = props.settings.linkClientMetricConfig || [];
|
const linkClientMetricConfig: MetricConfigOpt[] = props.settings.linkClientMetricConfig || [];
|
||||||
|
|
||||||
@ -108,7 +115,10 @@ limitations under the License. -->
|
|||||||
}
|
}
|
||||||
|
|
||||||
function nodeTooltip(data: Node) {
|
function nodeTooltip(data: Node) {
|
||||||
const nodeMetrics: string[] = Object.keys(topologyStore.nodeMetricValue);
|
const nodeMetrics: string[] =
|
||||||
|
props.settings.metricMode === MetricModes.Expression
|
||||||
|
? props.settings.nodeExpressions
|
||||||
|
: props.settings.nodeMetrics;
|
||||||
const nodeMetricConfig = props.settings.nodeMetricConfig || [];
|
const nodeMetricConfig = props.settings.nodeMetricConfig || [];
|
||||||
const html = nodeMetrics.map((m, index) => {
|
const html = nodeMetrics.map((m, index) => {
|
||||||
const metric =
|
const metric =
|
||||||
|
Loading…
Reference in New Issue
Block a user