Skip to content

added expiry date in license #129732

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

scarlet2131
Copy link

@scarlet2131 scarlet2131 commented Jun 19, 2025

Description

Adds expiry_in_days field to _license API response for easier license monitoring

This PR implements the enhancement requested in issue #129726 to add an expiry_in_days field to the _license API response. This field shows the number of days until license expiry as a float (e.g., "30.2"), making it much easier for users and monitoring tools to check license status without manual date calculations.

Changes Made

  • Added getDaysUntilExpiry() method in LicenseUtils.java to calculate days until license expiry
  • Added EXPIRY_IN_DAYS field constant in License.java
  • Enhanced toXContent() method in License.java to include the new field in JSON response
  • Added comprehensive unit tests in LicenseUtilsTests.java covering all scenarios

Example API Response

Before:

{
  "license": {
    "status": "active",
    "type": "trial",
    "expiry_date": "2025-07-19T22:05:12.332Z",
    "expiry_date_in_millis": 1542665112332
  }
}

After:

{
  "license": {
    "status": "active", 
    "type": "trial",
    "expiry_date": "2025-07-19T22:05:12.332Z",
    "expiry_date_in_millis": 1542665112332,
    "expiry_in_days": "30.2"
  }
}

Testing

  • ✅ Unit tests pass: ./gradlew :x-pack:plugin:core:test --tests "org.elasticsearch.license.LicenseUtilsTests.testGetDaysUntilExpiry"
  • ✅ All existing functionality preserved
  • ✅ Backward compatible - no breaking changes
Screenshot 2025-06-19 at 2 33 29 PM

Checklist Response

  • Contributor License Agreement: Yes, signed
  • Contributor Guidelines: Yes, followed the guidelines in CONTRIBUTING.md
  • Built locally: Yes, built and tested with gradle check
  • PR against main: Yes, this PR is against the main branch
  • Supported OS/Architecture: Yes, developed on macOS which is supported
  • Not for class submission: This is an open source contribution, not for academic credit

Resolves #129726

@elasticsearchmachine elasticsearchmachine added needs:triage Requires assignment of a team area label v9.1.0 external-contributor Pull request authored by a developer outside the Elasticsearch team labels Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external-contributor Pull request authored by a developer outside the Elasticsearch team needs:triage Requires assignment of a team area label v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Observability] Add expiry_in_days to _license API for easier monitoring
2 participants