mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
External target metrics
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
525d439e7c
commit
ecdf6667cf
@ -130,5 +130,65 @@ describe("HorizontalPodAutoscalerApi", () => {
|
|||||||
|
|
||||||
expect(hpa.getMetricValues(hpa.getMetrics()[0])).toEqual("unknown / 10k");
|
expect(hpa.getMetricValues(hpa.getMetrics()[0])).toEqual("unknown / 10k");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should return correct external metrics with average value", () => {
|
||||||
|
const hpa = new HorizontalPodAutoscaler(
|
||||||
|
{
|
||||||
|
...hpaV2,
|
||||||
|
spec: {
|
||||||
|
...hpaV2.spec,
|
||||||
|
metrics: [
|
||||||
|
{
|
||||||
|
type: HpaMetricType.External,
|
||||||
|
external: {
|
||||||
|
metric: {
|
||||||
|
name: "queue_messages_ready",
|
||||||
|
selector: {
|
||||||
|
matchLabels: {queue: 'worker_tasks'}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
target: {
|
||||||
|
type: "AverageValue",
|
||||||
|
averageValue: "30"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(hpa.getMetricValues(hpa.getMetrics()[0])).toEqual("unknown / 30 (avg)");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return correct external metrics with value", () => {
|
||||||
|
const hpa = new HorizontalPodAutoscaler(
|
||||||
|
{
|
||||||
|
...hpaV2,
|
||||||
|
spec: {
|
||||||
|
...hpaV2.spec,
|
||||||
|
metrics: [
|
||||||
|
{
|
||||||
|
type: HpaMetricType.External,
|
||||||
|
external: {
|
||||||
|
metric: {
|
||||||
|
name: "queue_messages_ready",
|
||||||
|
selector: {
|
||||||
|
matchLabels: {queue: 'worker_tasks'}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
target: {
|
||||||
|
type: "Value",
|
||||||
|
value: "30"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(hpa.getMetricValues(hpa.getMetrics()[0])).toEqual("unknown / 30");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -37,10 +37,21 @@ export interface ContainerResourceMetricSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ExternalMetricSource {
|
export interface ExternalMetricSource {
|
||||||
metricName: string;
|
metricName?: string;
|
||||||
metricSelector?: LabelSelector;
|
metricSelector?: LabelSelector;
|
||||||
targetAverageValue?: string;
|
targetAverageValue?: string;
|
||||||
targetValue?: string;
|
targetValue?: string;
|
||||||
|
|
||||||
|
// autoscaling/v2
|
||||||
|
metric?: {
|
||||||
|
name?: string;
|
||||||
|
selector?: LabelSelector;
|
||||||
|
},
|
||||||
|
target?: {
|
||||||
|
type: string;
|
||||||
|
value?: string;
|
||||||
|
averageValue?: string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ObjectMetricSource {
|
export interface ObjectMetricSource {
|
||||||
@ -364,8 +375,8 @@ function getExternalMetricValue(currentMetric: ExternalMetricStatus | undefined,
|
|||||||
?? currentMetric?.currentAverageValue
|
?? currentMetric?.currentAverageValue
|
||||||
),
|
),
|
||||||
target: (
|
target: (
|
||||||
targetMetric?.targetValue
|
targetMetric?.target?.value
|
||||||
?? targetMetric?.targetAverageValue
|
?? `${targetMetric?.target?.averageValue} (avg)`
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user