Skip to content

feat(prometheus): expose domain expiry days as a metric (#7083)#7168

Open
dharunashokkumar wants to merge 3 commits intolouislam:masterfrom
dharunashokkumar:feat/prometheus-domain-expiry-7083
Open

feat(prometheus): expose domain expiry days as a metric (#7083)#7168
dharunashokkumar wants to merge 3 commits intolouislam:masterfrom
dharunashokkumar:feat/prometheus-domain-expiry-7083

Conversation

@dharunashokkumar
Copy link
Copy Markdown
Contributor

@dharunashokkumar dharunashokkumar commented Mar 19, 2026

Adds monitor_domain_expiry_days_remaining gauge so users can alert on expiring domains via Prometheus/Grafana.

Summary

In this pull request, the following changes are made:

  • Added a new monitor_domain_expiry_days_remaining Prometheus gauge in server/prometheus.js, following the same pattern as the
    existing monitor_cert_days_remaining metric.

    • Wired domain expiry days from the existing RDAP check in server/model/monitor.js into the prometheus update call, so the metric gets
      populated each heartbeat cycle.

    No UI changes, no new dependencies.

Please follow this checklist to avoid unnecessary back and forth (click to expand)
  • ⚠️ If there are Breaking change (a fix or feature that alters existing functionality in a way that could cause issues) I have called them out
  • 🧠 I have disclosed any use of LLMs/AI in this contribution and reviewed all generated content.
    I understand that I am responsible for and able to explain every line of code I submit.
  • 🔍 Any UI changes adhere to visual style of this project.
  • 🛠️ I have self-reviewed and self-tested my code to ensure it works as expected.
  • 📝 I have commented my code, especially in hard-to-understand areas (e.g., using JSDoc for methods).
  • 🤖 I added or updated automated tests where appropriate.
  • 📄 Documentation updates are included (if applicable).
  • 🧰 Dependency updates are listed and explained.
  • ⚠️ CI passes and is green.

Screenshots for Visual Changes

  • UI Modifications: Highlight any changes made to the user interface.
  • Before & After: Include screenshots or comparisons (if applicable).
Event Before After
UP Before After
DOWN Before After
Certificate-expiry Before After
Testing Before After

Adds monitor_domain_expiry_days_remaining gauge so users can alert on expiring domains via Prometheus/Grafana.
Copilot AI review requested due to automatic review settings March 19, 2026 17:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Prometheus gauge to expose “days remaining until domain expiry” per monitor so users can alert via Prometheus/Grafana.

Changes:

  • Added monitor_domain_expiry_days_remaining gauge and wired it into the Prometheus update/remove lifecycle.
  • Plumbed domain expiry “days remaining” from the existing domain expiry/RDAP flow in Monitor into the Prometheus update call.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
server/prometheus.js Defines and updates/removes the new Prometheus gauge and extends update() to accept domain expiry info.
server/model/monitor.js Collects domain expiry “days remaining” during heartbeat and passes it to Prometheus.

Comment on lines +1046 to +1049
const domain = await DomainExpiry.findByDomainNameOrCreate(supportInfo.domain);
if (domain) {
domainExpiryInfo = { daysRemaining: domain.daysRemaining };
}
Comment on lines 155 to +162
* @param {object} heartbeat Heartbeat details
* @param {object} tlsInfo TLS details
* @param {{data24h: UptimeDataResult, data30d: UptimeDataResult, data1y:UptimeDataResult} | null} uptime the uptime and average response rate over a variety of fixed windows
* @param {object} domainExpiryInfo Domain expiry details
* @param {number} domainExpiryInfo.daysRemaining Number of days until domain expires
* @returns {void}
*/
update(heartbeat, tlsInfo, uptime) {
update(heartbeat, tlsInfo, uptime, domainExpiryInfo) {
Comment on lines +188 to +192
monitorDomainExpiryDaysRemaining.set(this.monitorLabelValues, domainExpiryInfo.daysRemaining);
}
} catch (e) {
log.error("prometheus", "Caught error", e);
}
* @returns {void}
*/
update(heartbeat, tlsInfo, uptime) {
update(heartbeat, tlsInfo, uptime, domainExpiryInfo) {
@filips123
Copy link
Copy Markdown

Maybe this could be renamed to just monitor_domain_days_remaining so it's consistent with monitor_cert_days_remaining? "Days remaining" kinda implies that domain will expire, so extra "expiry" seems unnecessary.

And maybe also an extra monitor_domain_is_valid metric?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Domain Expiry to Prometheus metrics

3 participants