mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-06-29 18:07:35 +00:00
fix: set different scope for topN metrics (#40)
This commit is contained in:
parent
c00d5d2a05
commit
d733594804
@ -22,6 +22,7 @@ import { useSelectorStore } from "@/store/modules/selectors";
|
|||||||
import { useAppStoreWithOut } from "@/store/modules/app";
|
import { useAppStoreWithOut } from "@/store/modules/app";
|
||||||
import { Instance, Endpoint, Service } from "@/types/selector";
|
import { Instance, Endpoint, Service } from "@/types/selector";
|
||||||
import { MetricConfigOpt } from "@/types/dashboard";
|
import { MetricConfigOpt } from "@/types/dashboard";
|
||||||
|
import { MetricCatalog } from "@/views/dashboard/data";
|
||||||
|
|
||||||
export function useQueryProcessor(config: any) {
|
export function useQueryProcessor(config: any) {
|
||||||
if (!(config.metrics && config.metrics[0])) {
|
if (!(config.metrics && config.metrics[0])) {
|
||||||
@ -61,8 +62,10 @@ export function useQueryProcessor(config: any) {
|
|||||||
parentService: ["All"].includes(dashboardStore.entity)
|
parentService: ["All"].includes(dashboardStore.entity)
|
||||||
? null
|
? null
|
||||||
: selectorStore.currentService.value,
|
: selectorStore.currentService.value,
|
||||||
normal: selectorStore.currentService.normal,
|
normal: selectorStore.currentService
|
||||||
scope: dashboardStore.entity,
|
? selectorStore.currentService.normal
|
||||||
|
: true,
|
||||||
|
scope: config.catalog || dashboardStore.entity,
|
||||||
topN: 10,
|
topN: 10,
|
||||||
order: c.sortOrder || "DES",
|
order: c.sortOrder || "DES",
|
||||||
};
|
};
|
||||||
@ -340,3 +343,27 @@ export function aggregation(val: number, config: any): number | string {
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function useGetMetricEntity(metric: string, metricType: any) {
|
||||||
|
if (!metric || !metricType) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let catalog = "";
|
||||||
|
const dashboardStore = useDashboardStore();
|
||||||
|
if (
|
||||||
|
[
|
||||||
|
MetricQueryTypes.ReadSampledRecords,
|
||||||
|
MetricQueryTypes.SortMetrics,
|
||||||
|
].includes(metricType)
|
||||||
|
) {
|
||||||
|
const res = await dashboardStore.fetchMetricList(metric);
|
||||||
|
if (res.errors) {
|
||||||
|
ElMessage.error(res.errors);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const c: string = res.data.metrics[0].catalog;
|
||||||
|
catalog = (MetricCatalog as any)[c];
|
||||||
|
}
|
||||||
|
|
||||||
|
return catalog;
|
||||||
|
}
|
||||||
|
@ -111,7 +111,11 @@ import {
|
|||||||
} from "../../../data";
|
} from "../../../data";
|
||||||
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/useProcessor";
|
import {
|
||||||
|
useQueryProcessor,
|
||||||
|
useSourceProcessor,
|
||||||
|
useGetMetricEntity,
|
||||||
|
} from "@/hooks/useProcessor";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { DashboardItem, MetricConfigOpt } from "@/types/dashboard";
|
import { DashboardItem, MetricConfigOpt } from "@/types/dashboard";
|
||||||
import Standard from "./Standard.vue";
|
import Standard from "./Standard.vue";
|
||||||
@ -343,8 +347,9 @@ async function queryMetrics() {
|
|||||||
if (states.isList) {
|
if (states.isList) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { metricConfig } = dashboardStore.selectedGrid;
|
const { metricConfig, metricTypes, metrics } = dashboardStore.selectedGrid;
|
||||||
const params = useQueryProcessor({ ...states, metricConfig });
|
const catalog = await useGetMetricEntity(metrics[0], metricTypes[0]);
|
||||||
|
const params = useQueryProcessor({ ...states, metricConfig, catalog });
|
||||||
if (!params) {
|
if (!params) {
|
||||||
emit("update", {});
|
emit("update", {});
|
||||||
return;
|
return;
|
||||||
|
@ -81,7 +81,11 @@ import { useAppStoreWithOut } from "@/store/modules/app";
|
|||||||
import { useSelectorStore } from "@/store/modules/selectors";
|
import { useSelectorStore } from "@/store/modules/selectors";
|
||||||
import graphs from "../graphs";
|
import graphs from "../graphs";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { useQueryProcessor, useSourceProcessor } from "@/hooks/useProcessor";
|
import {
|
||||||
|
useQueryProcessor,
|
||||||
|
useSourceProcessor,
|
||||||
|
useGetMetricEntity,
|
||||||
|
} from "@/hooks/useProcessor";
|
||||||
import { EntityType, ListChartTypes } from "../data";
|
import { EntityType, ListChartTypes } from "../data";
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
@ -113,7 +117,9 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function queryMetrics() {
|
async function queryMetrics() {
|
||||||
const params = await useQueryProcessor(props.data);
|
const { metricTypes, metrics } = props.data;
|
||||||
|
const catalog = await useGetMetricEntity(metrics[0], metricTypes[0]);
|
||||||
|
const params = await useQueryProcessor({ ...props.data, catalog });
|
||||||
|
|
||||||
if (!params) {
|
if (!params) {
|
||||||
state.source = {};
|
state.source = {};
|
||||||
|
@ -106,11 +106,12 @@ const getMetricConfig = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function changeConfigs(param: { [key: string]: string }) {
|
function changeConfigs(param: { [key: string]: string }) {
|
||||||
const metricConfig = getMetricConfig.value;
|
const metricConfig = getMetricConfig.value || [];
|
||||||
metricConfig[currentIndex.value] = {
|
metricConfig[currentIndex.value] = {
|
||||||
...metricConfig[currentIndex.value],
|
...metricConfig[currentIndex.value],
|
||||||
...param,
|
...param,
|
||||||
};
|
};
|
||||||
|
currentConfig.value = metricConfig[currentIndex.value];
|
||||||
emit("update", { [props.type]: metricConfig });
|
emit("update", { [props.type]: metricConfig });
|
||||||
}
|
}
|
||||||
function changeMetric(val: string) {
|
function changeMetric(val: string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user