diff --git a/server/model/monitor.js b/server/model/monitor.js index bafc0d2d..628f17a6 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -477,6 +477,12 @@ class Monitor extends BeanModel { stop() { clearTimeout(this.heartbeatInterval); this.isStop = true; + + this.prometheus().remove(); + } + + prometheus() { + return new Prometheus(this); } /** diff --git a/server/prometheus.js b/server/prometheus.js index f91b0a13..86ad381b 100644 --- a/server/prometheus.js +++ b/server/prometheus.js @@ -86,6 +86,16 @@ class Prometheus { } } + remove() { + try { + monitor_cert_days_remaining.remove(this.monitorLabelValues); + monitor_cert_is_valid.remove(this.monitorLabelValues); + monitor_response_time.remove(this.monitorLabelValues); + monitor_status.remove(this.monitorLabelValues); + } catch (e) { + console.error(e); + } + } } module.exports = { diff --git a/server/server.js b/server/server.js index 9a5e1028..f3e8db0f 100644 --- a/server/server.js +++ b/server/server.js @@ -579,6 +579,9 @@ exports.entryPage = "dashboard"; throw new Error("Permission denied."); } + // Reset Prometheus labels + monitorList[monitor.id]?.prometheus()?.remove(); + bean.name = monitor.name; bean.type = monitor.type; bean.url = monitor.url;