Skip to content

feat: add percentage-based certificate expiry notifications#6840

Open
AnuragEkkati wants to merge 6 commits intolouislam:masterfrom
AnuragEkkati:feature/cert-expiry-percentage
Open

feat: add percentage-based certificate expiry notifications#6840
AnuragEkkati wants to merge 6 commits intolouislam:masterfrom
AnuragEkkati:feature/cert-expiry-percentage

Conversation

@AnuragEkkati
Copy link
Contributor

Summary

In this pull request, the following changes are made:

  • Add support for lifetime percentage thresholds in addition to days
  • Calculate percentRemaining for certificates based on total lifetime
  • Support dashboard tag colors to use 25% threshold. Fallback 7 days
  • Provide option in UI settings to configure percentage thresholds (1-100%)
  • Gracefully handle certificates without validFrom (Globalping monitors)

This feature fixes #6821

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.

AI Usage

Used Cursor AI IDE to review the changes and highlight corner conditions to be explored.

Screenshots for Visual Changes

Notifications Tab:
Screenshot 2026-01-28 at 5 14 54 PM

Webhook Notification:
Screenshot 2026-01-28 at 5 14 24 PM

Status Page :
Tested by configuring 95% of cert validity if it turns red ( reverted to 25% in code )
Screenshot 2026-01-28 at 4 58 52 PM

Stdout Logs:
Screenshot 2026-01-28 at 5 13 57 PM

- Add support for lifetime percentage thresholds in addition to days
- Calculate percentRemaining for certificates based on total lifetime
- Support dashboard tag colors to use 25% threshold. Fallback 7 days
- Provide option in UI settings to configure percentage thresholds (1-100%)
- Gracefully handle certificates without validFrom (Globalping monitors)

This feature fixes louislam#6821
@AnuragEkkati AnuragEkkati force-pushed the feature/cert-expiry-percentage branch from c726d50 to 0930867 Compare January 30, 2026 01:08
@ManInDark
Copy link

        link.totalDays = dayjs.utc(link.validTo).diff(dayjs.utc(link.validFrom), "day"); 
         link.percentRemaining = link.totalDays > 0 ? Math.round((link.daysRemaining / link.totalDays) * 100) : 0;

If I understand this correctly, you first convert the total and remaining time to a daycount and then calculate the percentage.

I belive this could cause issues with extremely short lived certificates. For example step-ca recommends validity periods of only one day. If I understand the code correctly it would show 100% and then immediately 0%.

Though If the library supports floating point days, this isn't an issue.

@AnuragEkkati
Copy link
Contributor Author

@CommanderStorm can you please review or assign reviewer for this when you find time.

Thanks

@AnuragEkkati
Copy link
Contributor Author

@CommanderStorm can you please assign some reviewer to this PR when you find time.

Thanks

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.

Support for shortlived certificates

2 participants