And the error handling
This commit is contained in:
parent
8bec3b80f4
commit
99def687d3
@ -53,7 +53,7 @@ export default function Component({ service }) {
|
|||||||
|
|
||||||
const { metrics = [], refreshInterval = 10000 } = widget;
|
const { metrics = [], refreshInterval = 10000 } = widget;
|
||||||
|
|
||||||
const prometheusmetricErrors = [];
|
let prometheusmetricError;
|
||||||
|
|
||||||
const prometheusmetricData = new Map(
|
const prometheusmetricData = new Map(
|
||||||
metrics.slice(0, 4).map((metric) => {
|
metrics.slice(0, 4).map((metric) => {
|
||||||
@ -65,15 +65,14 @@ export default function Component({ service }) {
|
|||||||
refreshInterval: Math.max(1000, metric.refreshInterval ?? refreshInterval),
|
refreshInterval: Math.max(1000, metric.refreshInterval ?? refreshInterval),
|
||||||
});
|
});
|
||||||
if (resultError) {
|
if (resultError) {
|
||||||
prometheusmetricErrors.push(resultError);
|
prometheusmetricError = resultError;
|
||||||
}
|
}
|
||||||
return [metric.key ?? metric.label, resultData];
|
return [metric.key ?? metric.label, resultData];
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (prometheusmetricErrors.length) {
|
if (prometheusmetricError) {
|
||||||
// Only shows first metric query error in the container
|
return <Container service={service} error={prometheusmetricError} />;
|
||||||
return <Container service={service} error={prometheusmetricErrors[0]} />;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!prometheusmetricData) {
|
if (!prometheusmetricData) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user