Skip to content

Commit

Permalink
Merge branch '7.x' into backport/7.x/pr-103744
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Aug 19, 2021
2 parents 4038c8b + 50e484b commit 8d1b7d7
Show file tree
Hide file tree
Showing 11 changed files with 205 additions and 183 deletions.
4 changes: 4 additions & 0 deletions docs/settings/monitoring-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ For more information, see
monitoring back-end does not run and {kib} stats are not sent to the monitoring
cluster.

| `monitoring.ui.ccs.enabled`
| Set to `true` (default) to enable {ref}/modules-cross-cluster-search.html[cross-cluster search] of your monitoring data. The {ref}/modules-remote-clusters.html#remote-cluster-settings[`remote_cluster_client`] role must exist on each node.


| `monitoring.ui.elasticsearch.hosts`
| Specifies the location of the {es} cluster where your monitoring data is stored.
By default, this is the same as <<elasticsearch-hosts, `elasticsearch.hosts`>>. This setting enables
Expand Down
32 changes: 14 additions & 18 deletions x-pack/plugins/alerting/server/rules_client/rules_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import Semver from 'semver';
import Boom from '@hapi/boom';
import { omit, isEqual, map, uniq, pick, truncate, trim } from 'lodash';
import { i18n } from '@kbn/i18n';
Expand Down Expand Up @@ -297,11 +298,13 @@ export class RulesClient {
);

const createTime = Date.now();
const legacyId = Semver.lt(this.kibanaVersion, '8.0.0') ? id : null;
const notifyWhen = getAlertNotifyWhenType(data.notifyWhen, data.throttle);

const rawAlert: RawAlert = {
...data,
...this.apiKeyAsAlertAttributes(createdAPIKey, username),
legacyId,
actions,
createdBy: username,
updatedBy: username,
Expand Down Expand Up @@ -1539,36 +1542,29 @@ export class RulesClient {
notifyWhen,
scheduledTaskId,
params,
...rawAlert
legacyId, // exclude from result because it is an internal variable
executionStatus,
schedule,
actions,
...partialRawAlert
}: Partial<RawAlert>,
references: SavedObjectReference[] | undefined
): PartialAlert<Params> {
// Not the prettiest code here, but if we want to use most of the
// alert fields from the rawAlert using `...rawAlert` kind of access, we
// need to specifically delete the executionStatus as it's a different type
// in RawAlert and Alert. Probably next time we need to do something similar
// here, we should look at redesigning the implementation of this method.
const rawAlertWithoutExecutionStatus: Partial<Omit<RawAlert, 'executionStatus'>> = {
...rawAlert,
};
delete rawAlertWithoutExecutionStatus.executionStatus;
const executionStatus = alertExecutionStatusFromRaw(this.logger, id, rawAlert.executionStatus);

return {
id,
notifyWhen,
...rawAlertWithoutExecutionStatus,
...partialRawAlert,
// we currently only support the Interval Schedule type
// Once we support additional types, this type signature will likely change
schedule: rawAlert.schedule as IntervalSchedule,
actions: rawAlert.actions
? this.injectReferencesIntoActions(id, rawAlert.actions, references || [])
: [],
schedule: schedule as IntervalSchedule,
actions: actions ? this.injectReferencesIntoActions(id, actions, references || []) : [],
params: this.injectReferencesIntoParams(id, ruleType, params, references || []) as Params,
...(updatedAt ? { updatedAt: new Date(updatedAt) } : {}),
...(createdAt ? { createdAt: new Date(createdAt) } : {}),
...(scheduledTaskId ? { scheduledTaskId } : {}),
...(executionStatus ? { executionStatus } : {}),
...(executionStatus
? { executionStatus: alertExecutionStatusFromRaw(this.logger, id, executionStatus) }
: {}),
};
}

Expand Down
Loading

0 comments on commit 8d1b7d7

Please sign in to comment.