mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-18 13:25:25 +00:00
feat: set metrics for instance and endpoint topology
This commit is contained in:
parent
995f572a47
commit
147f4f644d
@ -21,11 +21,13 @@ import type { PropType } from "vue";
|
|||||||
import { useECharts } from "@/hooks/useEcharts";
|
import { useECharts } from "@/hooks/useEcharts";
|
||||||
import { addResizeListener, removeResizeListener } from "@/utils/event";
|
import { addResizeListener, removeResizeListener } from "@/utils/event";
|
||||||
|
|
||||||
/*global Nullable, defineProps*/
|
/*global Nullable, defineProps, defineEmits*/
|
||||||
|
const emits = defineEmits(["select"]);
|
||||||
const chartRef = ref<Nullable<HTMLDivElement>>(null);
|
const chartRef = ref<Nullable<HTMLDivElement>>(null);
|
||||||
const { setOptions, resize } = useECharts(chartRef as Ref<HTMLDivElement>);
|
const { setOptions, resize, getInstance } = useECharts(
|
||||||
|
chartRef as Ref<HTMLDivElement>
|
||||||
|
);
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
clickEvent: { type: Function as PropType<(param: unknown) => void> },
|
|
||||||
height: { type: String, default: "100%" },
|
height: { type: String, default: "100%" },
|
||||||
width: { type: String, default: "100%" },
|
width: { type: String, default: "100%" },
|
||||||
option: {
|
option: {
|
||||||
@ -35,6 +37,10 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
const instance = getInstance();
|
||||||
|
instance.on("click", (params: any) => {
|
||||||
|
emits("select", params);
|
||||||
|
});
|
||||||
setOptions(props.option);
|
setOptions(props.option);
|
||||||
addResizeListener(unref(chartRef), resize);
|
addResizeListener(unref(chartRef), resize);
|
||||||
});
|
});
|
||||||
|
@ -129,6 +129,7 @@ export const topologyStore = defineStore({
|
|||||||
},
|
},
|
||||||
setLinkServerMetrics(m: { id: string; value: unknown }[]) {
|
setLinkServerMetrics(m: { id: string; value: unknown }[]) {
|
||||||
this.linkServerMetrics = m;
|
this.linkServerMetrics = m;
|
||||||
|
console.log(m);
|
||||||
},
|
},
|
||||||
setLinkClientMetrics(m: { id: string; value: unknown }[]) {
|
setLinkClientMetrics(m: { id: string; value: unknown }[]) {
|
||||||
this.linkClientMetrics = m;
|
this.linkClientMetrics = m;
|
||||||
@ -294,7 +295,6 @@ export const topologyStore = defineStore({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async getEndpointTopology(endpointIds: string[]) {
|
async getEndpointTopology(endpointIds: string[]) {
|
||||||
// const endpointId = useSelectorStore().currentPod.id;
|
|
||||||
const duration = useAppStoreWithOut().durationTime;
|
const duration = useAppStoreWithOut().durationTime;
|
||||||
const variables = ["$duration: Duration!"];
|
const variables = ["$duration: Duration!"];
|
||||||
const fragment = endpointIds.map((id: string, index: number) => {
|
const fragment = endpointIds.map((id: string, index: number) => {
|
||||||
|
1
src/types/topology.d.ts
vendored
1
src/types/topology.d.ts
vendored
@ -30,4 +30,5 @@ export interface Node {
|
|||||||
type: string;
|
type: string;
|
||||||
isReal: boolean;
|
isReal: boolean;
|
||||||
layer?: string;
|
layer?: string;
|
||||||
|
serviceName?: string;
|
||||||
}
|
}
|
||||||
|
@ -14,15 +14,16 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License. -->
|
limitations under the License. -->
|
||||||
<template>
|
<template>
|
||||||
<div class="tool">
|
<div class="tool">
|
||||||
|
<span v-show="dashboardStore.entity === EntityType[2].value">
|
||||||
<span class="label">{{ t("currentDepth") }}</span>
|
<span class="label">{{ t("currentDepth") }}</span>
|
||||||
<Selector
|
<Selector
|
||||||
class="inputs"
|
class="inputs"
|
||||||
:value="depth"
|
:value="depth"
|
||||||
:options="depthList"
|
:options="depthList"
|
||||||
placeholder="Select metrics"
|
placeholder="Select a option"
|
||||||
@change="changeDepth"
|
@change="changeDepth"
|
||||||
:style="`background: '#2b3037';`"
|
|
||||||
/>
|
/>
|
||||||
|
</span>
|
||||||
<span class="switch-icon ml-5" title="Settings">
|
<span class="switch-icon ml-5" title="Settings">
|
||||||
<Icon @click="setConfig" size="middle" iconName="settings" />
|
<Icon @click="setConfig" size="middle" iconName="settings" />
|
||||||
</span>
|
</span>
|
||||||
@ -55,7 +56,7 @@ const dashboardStore = useDashboardStore();
|
|||||||
const selectorStore = useSelectorStore();
|
const selectorStore = useSelectorStore();
|
||||||
const topologyStore = useTopologyStore();
|
const topologyStore = useTopologyStore();
|
||||||
const loading = ref<boolean>(false);
|
const loading = ref<boolean>(false);
|
||||||
const height = ref<number>(document.body.clientHeight - 110);
|
const height = ref<number>(document.body.clientHeight - 150);
|
||||||
const width = ref<number>(document.body.clientWidth - 40);
|
const width = ref<number>(document.body.clientWidth - 40);
|
||||||
const showSettings = ref<boolean>(false);
|
const showSettings = ref<boolean>(false);
|
||||||
const depth = ref<string>("2");
|
const depth = ref<string>("2");
|
||||||
|
@ -14,11 +14,12 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License. -->
|
limitations under the License. -->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Graph :option="option" />
|
<Graph :option="option" @select="clickChart" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
import { useTopologyStore } from "@/store/modules/topology";
|
import { useTopologyStore } from "@/store/modules/topology";
|
||||||
|
import { Node, Call } from "@/types/topology";
|
||||||
|
|
||||||
const topologyStore = useTopologyStore();
|
const topologyStore = useTopologyStore();
|
||||||
const option = computed(() => getOption());
|
const option = computed(() => getOption());
|
||||||
@ -63,14 +64,59 @@ function getOption() {
|
|||||||
position: "bottom",
|
position: "bottom",
|
||||||
formatter: (param: { data: any; dataType: string }) => {
|
formatter: (param: { data: any; dataType: string }) => {
|
||||||
if (param.dataType === "edge") {
|
if (param.dataType === "edge") {
|
||||||
return `${param.data.sourceObj.serviceName} -> ${param.data.targetObj.serviceName}`;
|
return linkTooltip(param.data);
|
||||||
}
|
}
|
||||||
return param.data.serviceName;
|
return nodeTooltip(param.data);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
function linkTooltip(data: Call) {
|
||||||
|
const clientMetrics: string[] = Object.keys(topologyStore.linkClientMetrics);
|
||||||
|
const serverMetrics: string[] = Object.keys(topologyStore.linkServerMetrics);
|
||||||
|
const htmlServer = serverMetrics.map((m) => {
|
||||||
|
const metric = topologyStore.linkServerMetrics[m].values.filter(
|
||||||
|
(val: { id: string; value: unknown }) => val.id === data.id
|
||||||
|
)[0];
|
||||||
|
if (metric) {
|
||||||
|
return ` <div><span>${m}: </span>${metric.value}</div>`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const htmlClient = clientMetrics.map((m) => {
|
||||||
|
const metric = topologyStore.linkClientMetrics[m].values.filter(
|
||||||
|
(val: { id: string; value: unknown }) => val.id === data.id
|
||||||
|
)[0];
|
||||||
|
if (metric) {
|
||||||
|
return ` <div><span>${m}: </span>${metric.value}</div>`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const html = [
|
||||||
|
`<div>${data.sourceObj.serviceName} -> ${data.targetObj.serviceName}</div>`,
|
||||||
|
...htmlServer,
|
||||||
|
...htmlClient,
|
||||||
|
].join(" ");
|
||||||
|
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
function nodeTooltip(data: Node) {
|
||||||
|
const nodeMetrics: string[] = Object.keys(topologyStore.nodeMetrics);
|
||||||
|
const html = nodeMetrics.map((m) => {
|
||||||
|
const metric =
|
||||||
|
topologyStore.nodeMetrics[m].values.filter(
|
||||||
|
(val: { id: string; value: unknown }) => val.id === data.id
|
||||||
|
)[0] || {};
|
||||||
|
return ` <div><span>${m}: </span>${metric.value}</div>`;
|
||||||
|
});
|
||||||
|
return [` <div><span>name: </span>${data.serviceName}</div>`, ...html].join(
|
||||||
|
" "
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function clickChart(param: any) {
|
||||||
|
console.log(param);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.sankey {
|
.sankey {
|
||||||
|
@ -144,6 +144,8 @@ async function getMetricList() {
|
|||||||
const e =
|
const e =
|
||||||
dashboardStore.entity === EntityType[1].value
|
dashboardStore.entity === EntityType[1].value
|
||||||
? EntityType[0].value
|
? EntityType[0].value
|
||||||
|
: dashboardStore.entity === EntityType[4].value
|
||||||
|
? EntityType[3].value
|
||||||
: dashboardStore.entity;
|
: dashboardStore.entity;
|
||||||
states.linkMetricList = (json.data.metrics || []).filter(
|
states.linkMetricList = (json.data.metrics || []).filter(
|
||||||
(d: { catalog: string }) =>
|
(d: { catalog: string }) =>
|
||||||
|
Loading…
Reference in New Issue
Block a user