From 9e8ee08c15eb92d1c46c8843152fad50c3c16fec Mon Sep 17 00:00:00 2001 From: limbo <43649186+HUAHUAI23@users.noreply.github.com> Date: Thu, 9 Nov 2023 12:40:10 +0800 Subject: [PATCH] fix(services): fix runtime exporter metrics data caching issue (#1663) * Fix metrics data caching issue * chore --- build/charts/laf-server/templates/rumtime-exporter.yaml | 1 + services/runtime-exporter/src/handler/get-runtime-metrics.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/build/charts/laf-server/templates/rumtime-exporter.yaml b/build/charts/laf-server/templates/rumtime-exporter.yaml index d78fe63f15..a68f323a1a 100644 --- a/build/charts/laf-server/templates/rumtime-exporter.yaml +++ b/build/charts/laf-server/templates/rumtime-exporter.yaml @@ -68,6 +68,7 @@ spec: - interval: 60s path: "/runtime/metrics/{{ .Values.default_region.runtime_exporter_secret}}" scrapeTimeout: 10s + honorLabels: true namespaceSelector: matchNames: - {{ .Release.Namespace }} diff --git a/services/runtime-exporter/src/handler/get-runtime-metrics.ts b/services/runtime-exporter/src/handler/get-runtime-metrics.ts index e6980a4346..17c3ee41d2 100644 --- a/services/runtime-exporter/src/handler/get-runtime-metrics.ts +++ b/services/runtime-exporter/src/handler/get-runtime-metrics.ts @@ -62,6 +62,9 @@ const getRuntimeMetrics: RequestHandler = async (req, res) => { return res.status(403).send('forbidden') } + // Clear the metrics data generated by the last request + register.clear() + const runtimeMetrics = await ClusterService.getRuntimePodMetricsForAllNamespaces()