mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-13 08:17:33 +00:00
refactor: remove scope in metric query
This commit is contained in:
parent
1ceaef6802
commit
8f919b4583
@ -57,13 +57,11 @@ export function useQueryProcessor(config: Indexable) {
|
|||||||
name,
|
name,
|
||||||
parentService: ["All"].includes(dashboardStore.entity) ? null : selectorStore.currentService.value,
|
parentService: ["All"].includes(dashboardStore.entity) ? null : selectorStore.currentService.value,
|
||||||
normal: selectorStore.currentService ? selectorStore.currentService.normal : true,
|
normal: selectorStore.currentService ? selectorStore.currentService.normal : true,
|
||||||
scope: config.catalog,
|
|
||||||
topN: Number(c.topN) || 10,
|
topN: Number(c.topN) || 10,
|
||||||
order: c.sortOrder || "DES",
|
order: c.sortOrder || "DES",
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const entity = {
|
const entity = {
|
||||||
scope: config.catalog,
|
|
||||||
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(
|
||||||
@ -99,7 +97,6 @@ export function useQueryProcessor(config: Indexable) {
|
|||||||
order: c.sortOrder || "DES",
|
order: c.sortOrder || "DES",
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
entity.scope = dashboardStore.entity;
|
|
||||||
if (metricType === MetricQueryTypes.ReadLabeledMetricsValues) {
|
if (metricType === MetricQueryTypes.ReadLabeledMetricsValues) {
|
||||||
const labels = (c.labelsIndex || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, ""));
|
const labels = (c.labelsIndex || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, ""));
|
||||||
variables.push(`$labels${index}: [String!]!`);
|
variables.push(`$labels${index}: [String!]!`);
|
||||||
@ -233,7 +230,6 @@ export function useQueryPodsMetrics(
|
|||||||
const currentService = selectorStore.currentService || {};
|
const currentService = selectorStore.currentService || {};
|
||||||
const fragmentList = pods.map((d: (Instance | Endpoint | Service) & Indexable, index: number) => {
|
const fragmentList = pods.map((d: (Instance | Endpoint | Service) & Indexable, index: number) => {
|
||||||
const param = {
|
const param = {
|
||||||
scope,
|
|
||||||
serviceName: scope === "Service" ? d.label : currentService.label,
|
serviceName: scope === "Service" ? d.label : currentService.label,
|
||||||
serviceInstanceName: scope === "ServiceInstance" ? d.label : undefined,
|
serviceInstanceName: scope === "ServiceInstance" ? d.label : undefined,
|
||||||
endpointName: scope === "Endpoint" ? d.label : undefined,
|
endpointName: scope === "Endpoint" ? d.label : undefined,
|
||||||
@ -440,26 +436,3 @@ export function aggregation(val: number, config: { calculation?: string }): numb
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function useGetMetricEntity(metric: string, metricType: string) {
|
|
||||||
if (!metric || !metricType) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let catalog = "";
|
|
||||||
const dashboardStore = useDashboardStore();
|
|
||||||
if (
|
|
||||||
([MetricQueryTypes.ReadSampledRecords, MetricQueryTypes.SortMetrics, MetricQueryTypes.ReadRecords] as any).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 Indexable)[c];
|
|
||||||
}
|
|
||||||
|
|
||||||
return catalog;
|
|
||||||
}
|
|
||||||
|
@ -51,7 +51,7 @@ limitations under the License. -->
|
|||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
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, useGetMetricEntity } from "@/hooks/useMetricsProcessor";
|
import { useQueryProcessor, useSourceProcessor } from "@/hooks/useMetricsProcessor";
|
||||||
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";
|
||||||
@ -122,10 +122,7 @@ limitations under the License. -->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function queryMetrics() {
|
async function queryMetrics() {
|
||||||
const metricTypes = config.value.metricTypes || [];
|
const params = await useQueryProcessor({ ...config.value });
|
||||||
const metrics = config.value.metrics || [];
|
|
||||||
const catalog = await useGetMetricEntity(metrics[0], metricTypes[0]);
|
|
||||||
const params = await useQueryProcessor({ ...config.value, catalog });
|
|
||||||
if (!params) {
|
if (!params) {
|
||||||
source.value = {};
|
source.value = {};
|
||||||
return;
|
return;
|
||||||
|
@ -108,12 +108,10 @@ limitations under the License. -->
|
|||||||
ChartTypes,
|
ChartTypes,
|
||||||
PodsChartTypes,
|
PodsChartTypes,
|
||||||
MetricsType,
|
MetricsType,
|
||||||
ProtocolTypes,
|
|
||||||
ExpressionResultType,
|
|
||||||
} 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, useGetMetricEntity } from "@/hooks/useMetricsProcessor";
|
import { useQueryProcessor, useSourceProcessor } from "@/hooks/useMetricsProcessor";
|
||||||
import { useExpressionsQueryProcessor, useExpressionsSourceProcessor } from "@/hooks/useExpressionsProcessor";
|
import { useExpressionsQueryProcessor, useExpressionsSourceProcessor } 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";
|
||||||
@ -185,7 +183,7 @@ limitations under the License. -->
|
|||||||
}
|
}
|
||||||
arr = json.data.metrics;
|
arr = json.data.metrics;
|
||||||
}
|
}
|
||||||
states.metricList = (arr || []).filter((d: { catalog: string; type: string }) => {
|
states.metricList = (arr || []).filter((d: { type: string }) => {
|
||||||
if (states.isList) {
|
if (states.isList) {
|
||||||
if (d.type === MetricsType.REGULAR_VALUE || d.type === MetricsType.LABELED_VALUE) {
|
if (d.type === MetricsType.REGULAR_VALUE || d.type === MetricsType.LABELED_VALUE) {
|
||||||
return d;
|
return d;
|
||||||
@ -335,8 +333,7 @@ limitations under the License. -->
|
|||||||
if (!(metrics && metrics[0] && metricTypes && metricTypes[0])) {
|
if (!(metrics && metrics[0] && metricTypes && metricTypes[0])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const catalog = await useGetMetricEntity(metrics[0], metricTypes[0]);
|
const params = useQueryProcessor({ ...states, metricConfig });
|
||||||
const params = useQueryProcessor({ ...states, metricConfig, catalog });
|
|
||||||
if (!params) {
|
if (!params) {
|
||||||
emit("update", {});
|
emit("update", {});
|
||||||
return;
|
return;
|
||||||
|
@ -76,7 +76,7 @@ limitations under the License. -->
|
|||||||
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, useGetMetricEntity } from "@/hooks/useMetricsProcessor";
|
import { useQueryProcessor, useSourceProcessor } from "@/hooks/useMetricsProcessor";
|
||||||
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";
|
||||||
@ -113,10 +113,7 @@ limitations under the License. -->
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function queryMetrics() {
|
async function queryMetrics() {
|
||||||
const metricTypes: string[] = props.data.metricTypes || [];
|
const params = await useQueryProcessor({ ...props.data });
|
||||||
const metrics = props.data.metrics || [];
|
|
||||||
const catalog = await useGetMetricEntity(metrics[0], metricTypes[0]);
|
|
||||||
const params = await useQueryProcessor({ ...props.data, catalog });
|
|
||||||
|
|
||||||
if (!params) {
|
if (!params) {
|
||||||
state.source = {};
|
state.source = {};
|
||||||
|
Loading…
Reference in New Issue
Block a user