Skip to content

Commit

Permalink
[8.6] [Monitoring] Read expiryDateMS from the right path in License r…
Browse files Browse the repository at this point in the history
…ule (#148129) (#148212)

# Backport

This will backport the following commits from `main` to `8.6`:
- [[Monitoring] Read expiryDateMS from the right path in License rule
(#148129)](#148129)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Milton
Hultgren","email":"milton.hultgren@elastic.co"},"sourceCommit":{"committedDate":"2022-12-29T17:28:13Z","message":"[Monitoring]
Read expiryDateMS from the right path in License rule (#148129)\n\nThe
license details have been placed under the `meta` property but
the\r\ncontext messages were not updated to read correctly from that
path, this\r\nPR fixes that little
issue.","sha":"0b83a2a61a1a560bc8394574d50db4e9ced00731","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Infra
Monitoring UI","release_note:skip","Feature:Stack
Monitoring","backport:all-open","v8.7.0"],"number":148129,"url":"#148129
Read expiryDateMS from the right path in License rule (#148129)\n\nThe
license details have been placed under the `meta` property but
the\r\ncontext messages were not updated to read correctly from that
path, this\r\nPR fixes that little
issue.","sha":"0b83a2a61a1a560bc8394574d50db4e9ced00731"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"#148129
Read expiryDateMS from the right path in License rule (#148129)\n\nThe
license details have been placed under the `meta` property but
the\r\ncontext messages were not updated to read correctly from that
path, this\r\nPR fixes that little
issue.","sha":"0b83a2a61a1a560bc8394574d50db4e9ced00731"}}]}]
BACKPORT-->

Co-authored-by: Milton Hultgren <milton.hultgren@elastic.co>
  • Loading branch information
kibanamachine and miltonhultgren committed Jan 4, 2023
1 parent a02f42b commit d3a625e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion x-pack/plugins/monitoring/common/types/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ export interface AlertThreadPoolRejectionsState extends AlertNodeState {
}

export interface AlertLicenseState extends AlertState {
expiryDateMS: number;
meta: {
expiryDateMS: number;
};
}

export interface AlertNodesChangedState extends AlertState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class LicenseExpirationRule extends BaseRule {
// Logic in the base alert assumes that all alerts will operate against multiple nodes/instances (such as a CPU alert against ES nodes)
// However, some alerts operate on the state of the cluster itself and are only concerned with a single state
const state: AlertLicenseState = alertStates[0] as AlertLicenseState;
const $duration = moment.duration(+new Date() - state.expiryDateMS);
const $duration = moment.duration(+new Date() - state.meta.expiryDateMS);
const actionText = i18n.translate('xpack.monitoring.alerts.licenseExpiration.action', {
defaultMessage: 'Please update your license.',
});
Expand Down

0 comments on commit d3a625e

Please sign in to comment.