Skip to content

Commit

Permalink
[8.12] [ML] Fix registering of the ML alerting rules with the basic l…
Browse files Browse the repository at this point in the history
…icense (#173644) (#173733)

# Backport

This will backport the following commits from `main` to `8.12`:
- [[ML] Fix registering of the ML alerting rules with the basic license
(#173644)](#173644)

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

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

<!--BACKPORT [{"author":{"name":"Dima
Arnautov","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-12-20T12:31:21Z","message":"[ML]
Fix registering of the ML alerting rules with the basic license
(#173644)\n\n## Summary\r\n\r\nFixes the license checks for registering
ML alerting rules, so that if\r\nthe user doesn't have the required
license to create a rule instance, we\r\nstill show the entry in the
list. The alerting framework disables the\r\nrule type if license
requirements aren't met.\r\n\r\n<img width=\"617\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/5236598/891c44f4-ec7c-412b-afcb-e6084193eaed\">","sha":"19b82f8b61b284dd55308eed15f3fc37ea41c1ac","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix",":ml","Feature:Anomaly
Detection","Feature:Alerting/RuleTypes","Team:ML","v8.12.0","v8.13.0"],"number":173644,"url":"https://github.com/elastic/kibana/pull/173644","mergeCommit":{"message":"[ML]
Fix registering of the ML alerting rules with the basic license
(#173644)\n\n## Summary\r\n\r\nFixes the license checks for registering
ML alerting rules, so that if\r\nthe user doesn't have the required
license to create a rule instance, we\r\nstill show the entry in the
list. The alerting framework disables the\r\nrule type if license
requirements aren't met.\r\n\r\n<img width=\"617\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/5236598/891c44f4-ec7c-412b-afcb-e6084193eaed\">","sha":"19b82f8b61b284dd55308eed15f3fc37ea41c1ac"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","labelRegex":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/173644","number":173644,"mergeCommit":{"message":"[ML]
Fix registering of the ML alerting rules with the basic license
(#173644)\n\n## Summary\r\n\r\nFixes the license checks for registering
ML alerting rules, so that if\r\nthe user doesn't have the required
license to create a rule instance, we\r\nstill show the entry in the
list. The alerting framework disables the\r\nrule type if license
requirements aren't met.\r\n\r\n<img width=\"617\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/5236598/891c44f4-ec7c-412b-afcb-e6084193eaed\">","sha":"19b82f8b61b284dd55308eed15f3fc37ea41c1ac"}}]}]
BACKPORT-->

Co-authored-by: Dima Arnautov <[email protected]>
  • Loading branch information
kibanamachine and darnautov authored Dec 20, 2023
1 parent 2d5140a commit ddcf10b
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions x-pack/plugins/ml/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,19 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
} = await import('./register_helper');
registerSearchLinks(this.appUpdater$, fullLicense, mlCapabilities, !this.isServerless);

if (
pluginsSetup.triggersActionsUi &&
((fullLicense && mlCapabilities.canUseMlAlerts && mlCapabilities.canGetJobs) ||
// Register rules for basic license to show them in the UI as disabled
!fullLicense)
) {
registerMlAlerts(
pluginsSetup.triggersActionsUi,
core.getStartServices,
pluginsSetup.alerting
);
}

if (fullLicense) {
registerMlUiActions(pluginsSetup.uiActions, core);

Expand All @@ -242,18 +255,6 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
registerCasesAttachments(pluginsSetup.cases, coreStart, pluginStart);
}

if (
pluginsSetup.triggersActionsUi &&
mlCapabilities.canUseMlAlerts &&
mlCapabilities.canGetJobs
) {
registerMlAlerts(
pluginsSetup.triggersActionsUi,
core.getStartServices,
pluginsSetup.alerting
);
}

if (pluginsSetup.maps) {
// Pass canGetJobs as minimum permission to show anomalies card in maps layers
await registerMapExtension(pluginsSetup.maps, core, {
Expand Down

0 comments on commit ddcf10b

Please sign in to comment.