diff --git a/server/model/monitor.js b/server/model/monitor.js index bbeb0da0b..4bb859e9a 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -203,7 +203,7 @@ class Monitor extends BeanModel { let previousBeat = null; let retries = 0; - let prometheus = new Prometheus(this); + this.prometheus = new Prometheus(this); const beat = async () => { @@ -755,7 +755,7 @@ class Monitor extends BeanModel { await R.store(bean); log.debug("monitor", `[${this.name}] prometheus.update`); - prometheus.update(bean, tlsInfo); + this.prometheus.update(bean, tlsInfo); previousBeat = bean; @@ -840,15 +840,15 @@ class Monitor extends BeanModel { clearTimeout(this.heartbeatInterval); this.isStop = true; - this.prometheus().remove(); + this.prometheus.remove(); } /** - * Get a new prometheus instance - * @returns {Prometheus} + * Get prometheus instance + * @returns {Prometheus|undefined} */ - prometheus() { - return new Prometheus(this); + getPrometheus() { + return this.prometheus; } /** diff --git a/server/server.js b/server/server.js index 1073f3bef..18598171e 100644 --- a/server/server.js +++ b/server/server.js @@ -677,9 +677,6 @@ let needSetup = false; throw new Error("Permission denied."); } - // Reset Prometheus labels - server.monitorList[monitor.id]?.prometheus()?.remove(); - bean.name = monitor.name; bean.type = monitor.type; bean.url = monitor.url;