-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add 4 uptime metrics in prometheus #5506
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,31 @@ | |
help: "Is the certificate still valid? (1 = Yes, 0= No)", | ||
labelNames: commonLabels | ||
}); | ||
|
||
const monitorUptime1y = new PrometheusClient.Gauge({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please go through https://prometheus.io/docs/practices/naming/ and make sure that the new metrics are better "alligned" to what prometheus wants metrics to be like ^^ |
||
name: "monitor_uptime_1y", | ||
help: "Monitor Uptime 1y (%)", | ||
labelNames: commonLabels, | ||
}); | ||
|
||
const monitorUptime30d = new PrometheusClient.Gauge({ | ||
name: "monitor_uptime_30d", | ||
help: "Monitor Uptime 30d (%)", | ||
labelNames: commonLabels, | ||
}); | ||
|
||
const monitorUptime24h = new PrometheusClient.Gauge({ | ||
name: "monitor_uptime_24h", | ||
help: "Monitor Uptime 24h (%)", | ||
labelNames: commonLabels, | ||
}); | ||
|
||
const monitorAverageResponseTime = new PrometheusClient.Gauge({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please make sure that users + developers know that this is 24h ping times by adding the |
||
name: "monitor_average_response_time", | ||
help: "Monitor Average Response Time (ms)", | ||
labelNames: commonLabels, | ||
}); | ||
|
||
const monitorResponseTime = new PrometheusClient.Gauge({ | ||
name: "monitor_response_time", | ||
help: "Monitor Response Time (ms)", | ||
|
@@ -48,13 +73,13 @@ | |
}; | ||
} | ||
|
||
/** | ||
Check failure on line 76 in server/prometheus.js GitHub Actions / check-linters
|
||
* Update the metrics page | ||
* @param {object} heartbeat Heartbeat details | ||
* @param {object} tlsInfo TLS details | ||
* @returns {void} | ||
*/ | ||
update(heartbeat, tlsInfo) { | ||
update(heartbeat, tlsInfo, uptime) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please adress the linting error |
||
|
||
if (typeof tlsInfo !== "undefined") { | ||
try { | ||
|
@@ -80,6 +105,76 @@ | |
} | ||
} | ||
|
||
if (uptime) { | ||
if (typeof uptime.avgPing !== "undefined") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no clue what war crimes we did commit here. I have no clue why the whole We know what the type we pass into this function is.. |
||
try { | ||
if (typeof uptime.avgPing === "number") { | ||
monitorAverageResponseTime.set( | ||
this.monitorLabelValues, | ||
uptime.avgPing | ||
); | ||
} else { | ||
// Is it good? | ||
monitorAverageResponseTime.set( | ||
this.monitorLabelValues, | ||
-1 | ||
); | ||
} | ||
} catch (e) { | ||
log.error("prometheus", "Caught error"); | ||
log.error("prometheus", e); | ||
} | ||
} | ||
if (typeof uptime.data24h !== "undefined") { | ||
try { | ||
if (typeof uptime.data24h === "number") { | ||
monitorUptime24h.set( | ||
this.monitorLabelValues, | ||
uptime.data24h | ||
); | ||
} else { | ||
// Is it good? | ||
monitorUptime24h.set(this.monitorLabelValues, -1); | ||
} | ||
} catch (e) { | ||
log.error("prometheus", "Caught error"); | ||
log.error("prometheus", e); | ||
} | ||
} | ||
if (typeof uptime.data30d !== "undefined") { | ||
try { | ||
if (typeof uptime.data30d === "number") { | ||
monitorUptime30d.set( | ||
this.monitorLabelValues, | ||
uptime.data30d | ||
); | ||
} else { | ||
// Is it good? | ||
monitorUptime30d.set(this.monitorLabelValues, -1); | ||
} | ||
} catch (e) { | ||
log.error("prometheus", "Caught error"); | ||
log.error("prometheus", e); | ||
} | ||
} | ||
if (typeof uptime.data1y !== "undefined") { | ||
try { | ||
if (typeof uptime.data1y === "number") { | ||
monitorUptime1y.set( | ||
this.monitorLabelValues, | ||
uptime.data1y | ||
); | ||
} else { | ||
// Is it good? | ||
monitorUptime1y.set(this.monitorLabelValues, -1); | ||
} | ||
} catch (e) { | ||
log.error("prometheus", "Caught error"); | ||
log.error("prometheus", e); | ||
} | ||
} | ||
} | ||
|
||
if (heartbeat) { | ||
try { | ||
monitorStatus.set(this.monitorLabelValues, heartbeat.status); | ||
|
@@ -110,6 +205,10 @@ | |
try { | ||
monitorCertDaysRemaining.remove(this.monitorLabelValues); | ||
monitorCertIsValid.remove(this.monitorLabelValues); | ||
monitorUptime1y.remove(this.monitorLabelValues); | ||
monitorUptime30d.remove(this.monitorLabelValues); | ||
monitorUptime24h.remove(this.monitorLabelValues); | ||
monitorAverageResponseTime.remove(this.monitorLabelValues); | ||
monitorResponseTime.remove(this.monitorLabelValues); | ||
monitorStatus.remove(this.monitorLabelValues); | ||
} catch (e) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the performance impact of this?
This makes doing a ping substancially more exspensive...
Unsure if this is an isssue.
Have you tested this?