mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-01 11:19:45 +00:00
feat: update expression metrics
This commit is contained in:
parent
e2670b872f
commit
94dc2f3642
@ -15,16 +15,24 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { MetricQueryTypes, Calculations } from "./data";
|
import { MetricQueryTypes, Calculations } from "./data";
|
||||||
|
import { ExpressionResultType } from "@/views/dashboard/data";
|
||||||
|
|
||||||
export function useListConfig(config: Indexable, index: string) {
|
export function useListConfig(config: Indexable, index: string) {
|
||||||
const i = Number(index);
|
const i = Number(index);
|
||||||
const types = [Calculations.Average, Calculations.ApdexAvg, Calculations.PercentageAvg];
|
const types = [Calculations.Average, Calculations.ApdexAvg, Calculations.PercentageAvg];
|
||||||
const calculation = config.metricConfig && config.metricConfig[i] && config.metricConfig[i].calculation;
|
const calculation = config.metricConfig && config.metricConfig[i] && config.metricConfig[i].calculation;
|
||||||
const isLinear =
|
const isLinear =
|
||||||
[MetricQueryTypes.ReadMetricsValues, MetricQueryTypes.ReadLabeledMetricsValues].includes(config.metricTypes[i]) &&
|
[
|
||||||
!types.includes(calculation);
|
MetricQueryTypes.ReadMetricsValues,
|
||||||
|
MetricQueryTypes.ReadLabeledMetricsValues,
|
||||||
|
ExpressionResultType.TIME_SERIES_VALUES,
|
||||||
|
].includes(config.metricTypes[i]) && !types.includes(calculation);
|
||||||
const isAvg =
|
const isAvg =
|
||||||
[MetricQueryTypes.ReadMetricsValues, MetricQueryTypes.ReadLabeledMetricsValues].includes(config.metricTypes[i]) &&
|
[
|
||||||
types.includes(calculation);
|
MetricQueryTypes.ReadMetricsValues,
|
||||||
|
MetricQueryTypes.ReadLabeledMetricsValues,
|
||||||
|
ExpressionResultType.TIME_SERIES_VALUES,
|
||||||
|
].includes(config.metricTypes[i]) && types.includes(calculation);
|
||||||
return {
|
return {
|
||||||
isLinear,
|
isLinear,
|
||||||
isAvg,
|
isAvg,
|
||||||
|
@ -22,6 +22,7 @@ import { useSelectorStore } from "@/store/modules/selectors";
|
|||||||
import { useAppStoreWithOut } from "@/store/modules/app";
|
import { useAppStoreWithOut } from "@/store/modules/app";
|
||||||
import type { Instance, Endpoint, Service } from "@/types/selector";
|
import type { Instance, Endpoint, Service } from "@/types/selector";
|
||||||
import type { MetricConfigOpt } from "@/types/dashboard";
|
import type { MetricConfigOpt } from "@/types/dashboard";
|
||||||
|
import type { E } from "vitest/dist/types-c441ef31";
|
||||||
|
|
||||||
export function useQueryProcessor(config: Indexable) {
|
export function useQueryProcessor(config: Indexable) {
|
||||||
if (!(config.metrics && config.metrics[0])) {
|
if (!(config.metrics && config.metrics[0])) {
|
||||||
@ -277,7 +278,7 @@ export function usePodsSource(
|
|||||||
const names: string[] = [];
|
const names: string[] = [];
|
||||||
const metricConfigArr: MetricConfigOpt[] = [];
|
const metricConfigArr: MetricConfigOpt[] = [];
|
||||||
const metricTypesArr: string[] = [];
|
const metricTypesArr: string[] = [];
|
||||||
const data = pods.map((d: Instance & Indexable, idx: number) => {
|
const data = pods.map((d: any, idx: number) => {
|
||||||
config.metrics.map((name: string, index: number) => {
|
config.metrics.map((name: string, index: number) => {
|
||||||
const c: any = (config.metricConfig && config.metricConfig[index]) || {};
|
const c: any = (config.metricConfig && config.metricConfig[index]) || {};
|
||||||
const key = name + idx + index;
|
const key = name + idx + index;
|
||||||
|
3
src/types/selector.d.ts
vendored
3
src/types/selector.d.ts
vendored
@ -21,6 +21,7 @@ export type Service = {
|
|||||||
layers?: string[];
|
layers?: string[];
|
||||||
normal?: boolean;
|
normal?: boolean;
|
||||||
group?: string;
|
group?: string;
|
||||||
|
merge?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Instance = {
|
export type Instance = {
|
||||||
@ -30,12 +31,14 @@ export type Instance = {
|
|||||||
instanceUUID?: string;
|
instanceUUID?: string;
|
||||||
attributes?: { name: string; value: string }[];
|
attributes?: { name: string; value: string }[];
|
||||||
id?: string;
|
id?: string;
|
||||||
|
merge?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Endpoint = {
|
export type Endpoint = {
|
||||||
id?: string;
|
id?: string;
|
||||||
label: string;
|
label: string;
|
||||||
value: string;
|
value: string;
|
||||||
|
merge?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Service = {
|
export type Service = {
|
||||||
|
@ -120,10 +120,18 @@ limitations under the License. -->
|
|||||||
endpoints.value = resp.data.pods || [];
|
endpoints.value = resp.data.pods || [];
|
||||||
queryEndpointMetrics(endpoints.value);
|
queryEndpointMetrics(endpoints.value);
|
||||||
}
|
}
|
||||||
async function queryEndpointMetrics(currentPods: Endpoint[]) {
|
async function queryEndpointMetrics(arr: Endpoint[]) {
|
||||||
if (!currentPods.length) {
|
if (!arr.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const currentPods = arr.map((d: Endpoint) => {
|
||||||
|
return {
|
||||||
|
id: d.id,
|
||||||
|
value: d.value,
|
||||||
|
label: d.label,
|
||||||
|
merge: d.merge,
|
||||||
|
};
|
||||||
|
});
|
||||||
if (props.config.metricMode === "Expression") {
|
if (props.config.metricMode === "Expression") {
|
||||||
queryEndpointExpressions(currentPods);
|
queryEndpointExpressions(currentPods);
|
||||||
return;
|
return;
|
||||||
|
@ -150,10 +150,21 @@ limitations under the License. -->
|
|||||||
queryInstanceMetrics(instances.value);
|
queryInstanceMetrics(instances.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function queryInstanceMetrics(currentInstances: Instance[]) {
|
async function queryInstanceMetrics(arr: Instance[]) {
|
||||||
if (!currentInstances.length) {
|
if (!arr.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const currentInstances = arr.map((d: Instance) => {
|
||||||
|
return {
|
||||||
|
id: d.id,
|
||||||
|
value: d.value,
|
||||||
|
label: d.label,
|
||||||
|
merge: d.merge,
|
||||||
|
language: d.language,
|
||||||
|
instanceUUID: d.instanceUUID,
|
||||||
|
attributes: d.attributes,
|
||||||
|
};
|
||||||
|
});
|
||||||
if (props.config.metricMode === "Expression") {
|
if (props.config.metricMode === "Expression") {
|
||||||
queryInstanceExpressions(currentInstances);
|
queryInstanceExpressions(currentInstances);
|
||||||
return;
|
return;
|
||||||
|
@ -191,10 +191,21 @@ limitations under the License. -->
|
|||||||
|
|
||||||
router.push(path);
|
router.push(path);
|
||||||
}
|
}
|
||||||
async function queryServiceMetrics(currentServices: Service[]) {
|
async function queryServiceMetrics(arr: Service[]) {
|
||||||
if (!currentServices.length) {
|
if (!arr.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const currentServices = arr.map((d: Service) => {
|
||||||
|
return {
|
||||||
|
id: d.id,
|
||||||
|
value: d.value,
|
||||||
|
label: d.label,
|
||||||
|
layers: d.layers,
|
||||||
|
group: d.group,
|
||||||
|
normal: d.normal,
|
||||||
|
merge: d.merge,
|
||||||
|
};
|
||||||
|
});
|
||||||
if (props.config.metricMode === "Expression") {
|
if (props.config.metricMode === "Expression") {
|
||||||
queryServiceExpressions(currentServices);
|
queryServiceExpressions(currentServices);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user