[8.12] [ML] Fix registering of the ML alerting rules with the basic license (#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)](https://github.com/elastic/kibana/pull/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":"dmitrii.arnautov@elastic.co"},"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=\"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=\"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=\"891c44f4-ec7c-412b-afcb-e6084193eaed\">","sha":"19b82f8b61b284dd55308eed15f3fc37ea41c1ac"}}]}]
BACKPORT-->

Co-authored-by: Dima Arnautov <dmitrii.arnautov@elastic.co>
This commit is contained in:
Kibana Machine 2023-12-20 08:46:45 -05:00 committed by GitHub
parent 2d5140a07f
commit ddcf10b7d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
@ -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, {