Skip to content

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 v9.2.0 and removed v9.1.0 labels Jun 19, 2025
@PeteGillinElastic PeteGillinElastic added :Security/License License functionality for commercial features and removed needs:triage Requires assignment of a team area label labels Jul 11, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Security Meta label for security team label Jul 11, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-security (Team:Security)

@tvernum tvernum self-assigned this Sep 15, 2025
@tvernum tvernum self-requested a review September 15, 2025 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>enhancement external-contributor Pull request authored by a developer outside the Elasticsearch team :Security/License License functionality for commercial features Team:Security Meta label for security team v9.3.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

4 participants