remember prometheus instance and expose it
in preperation for #2491,#680 and #898
This commit is contained in:
parent
417efd9711
commit
f155ec9ba8
|
@ -200,7 +200,7 @@ class Monitor extends BeanModel {
|
||||||
let previousBeat = null;
|
let previousBeat = null;
|
||||||
let retries = 0;
|
let retries = 0;
|
||||||
|
|
||||||
let prometheus = new Prometheus(this);
|
this.prometheus = new Prometheus(this);
|
||||||
|
|
||||||
const beat = async () => {
|
const beat = async () => {
|
||||||
|
|
||||||
|
@ -729,7 +729,7 @@ class Monitor extends BeanModel {
|
||||||
await R.store(bean);
|
await R.store(bean);
|
||||||
|
|
||||||
log.debug("monitor", `[${this.name}] prometheus.update`);
|
log.debug("monitor", `[${this.name}] prometheus.update`);
|
||||||
prometheus.update(bean, tlsInfo);
|
this.prometheus.update(bean, tlsInfo);
|
||||||
|
|
||||||
previousBeat = bean;
|
previousBeat = bean;
|
||||||
|
|
||||||
|
@ -814,15 +814,15 @@ class Monitor extends BeanModel {
|
||||||
clearTimeout(this.heartbeatInterval);
|
clearTimeout(this.heartbeatInterval);
|
||||||
this.isStop = true;
|
this.isStop = true;
|
||||||
|
|
||||||
this.prometheus().remove();
|
this.prometheus.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a new prometheus instance
|
* Get prometheus instance
|
||||||
* @returns {Prometheus}
|
* @returns {Prometheus|undefined}
|
||||||
*/
|
*/
|
||||||
prometheus() {
|
getPrometheus() {
|
||||||
return new Prometheus(this);
|
return this.prometheus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -674,9 +674,6 @@ let needSetup = false;
|
||||||
throw new Error("Permission denied.");
|
throw new Error("Permission denied.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset Prometheus labels
|
|
||||||
server.monitorList[monitor.id]?.prometheus()?.remove();
|
|
||||||
|
|
||||||
bean.name = monitor.name;
|
bean.name = monitor.name;
|
||||||
bean.type = monitor.type;
|
bean.type = monitor.type;
|
||||||
bean.url = monitor.url;
|
bean.url = monitor.url;
|
||||||
|
|
Loading…
Reference in New Issue