Skip to content

Commit

Permalink
Changing feature id name
Browse files Browse the repository at this point in the history
  • Loading branch information
doakalexi committed Mar 20, 2024
1 parent 879913a commit ea9313d
Show file tree
Hide file tree
Showing 22 changed files with 161 additions and 161 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/alerting/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ export const INTERNAL_ALERTING_API_MAINTENANCE_WINDOW_PATH =
export const INTERNAL_ALERTING_API_GET_ACTIVE_MAINTENANCE_WINDOWS_PATH =
`${INTERNAL_ALERTING_API_MAINTENANCE_WINDOW_PATH}/_active` as const;

export const RULES_FEATURE_ID = 'alerts';
export const ALERTING_FEATURE_ID = 'alerts';
export const MONITORING_HISTORY_LIMIT = 200;
export const ENABLE_MAINTENANCE_WINDOWS = true;
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { SecurityPluginSetup } from '@kbn/security-plugin/server';
import { PluginStartContract as FeaturesPluginStart } from '@kbn/features-plugin/server';
import { Space } from '@kbn/spaces-plugin/server';
import { RegistryRuleType } from '../rule_type_registry';
import { RULES_FEATURE_ID, RuleTypeRegistry } from '../types';
import { ALERTING_FEATURE_ID, RuleTypeRegistry } from '../types';
import {
asFiltersByRuleTypeAndConsumer,
asFiltersBySpaceId,
Expand Down Expand Up @@ -130,7 +130,7 @@ export class AlertingAuthorization {

this.allPossibleConsumers = this.featuresIds.then((featuresIds) => {
return featuresIds.size
? asAuthorizedConsumers([RULES_FEATURE_ID, ...featuresIds], {
? asAuthorizedConsumers([ALERTING_FEATURE_ID, ...featuresIds], {
read: true,
all: true,
})
Expand Down Expand Up @@ -338,7 +338,7 @@ export class AlertingAuthorization {
>();
const allPossibleConsumers = await this.allPossibleConsumers;
const addLegacyConsumerPrivileges = (legacyConsumer: string) =>
legacyConsumer === RULES_FEATURE_ID || isEmpty(featuresIds);
legacyConsumer === ALERTING_FEATURE_ID || isEmpty(featuresIds);
for (const feature of fIds) {
const featureDef = this.features
.getKibanaFeatures()
Expand Down Expand Up @@ -504,6 +504,6 @@ export const getValidConsumer = ({
legacyConsumer: string;
producer: string;
}): string =>
legacyConsumer === RULES_FEATURE_ID || validLegacyConsumers.includes(legacyConsumer)
legacyConsumer === ALERTING_FEATURE_ID || validLegacyConsumers.includes(legacyConsumer)
? producer
: legacyConsumer;
4 changes: 2 additions & 2 deletions x-pack/plugins/alerting/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import { RulesClientFactory } from './rules_client_factory';
import { RulesSettingsClientFactory } from './rules_settings_client_factory';
import { MaintenanceWindowClientFactory } from './maintenance_window_client_factory';
import { ILicenseState, LicenseState } from './lib/license_state';
import { AlertingRequestHandlerContext, RULES_FEATURE_ID, RuleAlertData } from './types';
import { AlertingRequestHandlerContext, ALERTING_FEATURE_ID, RuleAlertData } from './types';
import { defineRoutes } from './routes';
import {
AlertInstanceContext,
Expand Down Expand Up @@ -320,7 +320,7 @@ export class AlertingPlugin {
}

// Usage counter for telemetry
this.usageCounter = plugins.usageCollection?.createUsageCounter(RULES_FEATURE_ID);
this.usageCounter = plugins.usageCollection?.createUsageCounter(ALERTING_FEATURE_ID);

const getSearchSourceMigrations = plugins.data.search.searchSource.getAllMigrations.bind(
plugins.data.search.searchSource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,77 +5,77 @@
* 2.0.
*/

import { RULES_FEATURE_ID } from './types';
import { ALERTING_FEATURE_ID } from './types';

export const ruleTypeIdWithValidLegacyConsumers: Record<string, string[]> = {
'example.always-firing': [RULES_FEATURE_ID],
'example.people-in-space': [RULES_FEATURE_ID],
transform_health: [RULES_FEATURE_ID],
'.index-threshold': [RULES_FEATURE_ID],
'.geo-containment': [RULES_FEATURE_ID],
'.es-query': [RULES_FEATURE_ID, 'discover'],
'xpack.ml.anomaly_detection_alert': [RULES_FEATURE_ID],
'xpack.ml.anomaly_detection_jobs_health': [RULES_FEATURE_ID],
'xpack.synthetics.alerts.monitorStatus': [RULES_FEATURE_ID],
'xpack.synthetics.alerts.tls': [RULES_FEATURE_ID],
'xpack.uptime.alerts.monitorStatus': [RULES_FEATURE_ID],
'xpack.uptime.alerts.tlsCertificate': [RULES_FEATURE_ID],
'xpack.uptime.alerts.durationAnomaly': [RULES_FEATURE_ID],
'xpack.uptime.alerts.tls': [RULES_FEATURE_ID],
'siem.eqlRule': [RULES_FEATURE_ID],
'siem.savedQueryRule': [RULES_FEATURE_ID],
'siem.indicatorRule': [RULES_FEATURE_ID],
'siem.mlRule': [RULES_FEATURE_ID],
'siem.queryRule': [RULES_FEATURE_ID],
'siem.thresholdRule': [RULES_FEATURE_ID],
'siem.newTermsRule': [RULES_FEATURE_ID],
'siem.notifications': [RULES_FEATURE_ID],
'slo.rules.burnRate': [RULES_FEATURE_ID],
'logs.alert.document.count': [RULES_FEATURE_ID],
'metrics.alert.inventory.threshold': [RULES_FEATURE_ID],
'metrics.alert.threshold': [RULES_FEATURE_ID],
monitoring_alert_cluster_health: [RULES_FEATURE_ID],
monitoring_alert_license_expiration: [RULES_FEATURE_ID],
monitoring_alert_cpu_usage: [RULES_FEATURE_ID],
monitoring_alert_missing_monitoring_data: [RULES_FEATURE_ID],
monitoring_alert_disk_usage: [RULES_FEATURE_ID],
monitoring_alert_thread_pool_search_rejections: [RULES_FEATURE_ID],
monitoring_alert_thread_pool_write_rejections: [RULES_FEATURE_ID],
monitoring_alert_jvm_memory_usage: [RULES_FEATURE_ID],
monitoring_alert_nodes_changed: [RULES_FEATURE_ID],
monitoring_alert_logstash_version_mismatch: [RULES_FEATURE_ID],
monitoring_alert_kibana_version_mismatch: [RULES_FEATURE_ID],
monitoring_alert_elasticsearch_version_mismatch: [RULES_FEATURE_ID],
monitoring_ccr_read_exceptions: [RULES_FEATURE_ID],
monitoring_shard_size: [RULES_FEATURE_ID],
'apm.transaction_duration': [RULES_FEATURE_ID],
'apm.anomaly': [RULES_FEATURE_ID],
'apm.error_rate': [RULES_FEATURE_ID],
'apm.transaction_error_rate': [RULES_FEATURE_ID],
'test.always-firing': [RULES_FEATURE_ID],
'test.always-firing-alert-as-data': [RULES_FEATURE_ID],
'test.authorization': [RULES_FEATURE_ID],
'test.cancellableRule': [RULES_FEATURE_ID],
'test.cumulative-firing': [RULES_FEATURE_ID],
'test.exceedsAlertLimit': [RULES_FEATURE_ID],
'test.failing': [RULES_FEATURE_ID],
'test.gold.noop': [RULES_FEATURE_ID],
'test.longRunning': [RULES_FEATURE_ID],
'test.multipleSearches': [RULES_FEATURE_ID],
'test.never-firing': [RULES_FEATURE_ID],
'test.noop': [RULES_FEATURE_ID],
'test.onlyContextVariables': [RULES_FEATURE_ID],
'test.onlyStateVariables': [RULES_FEATURE_ID],
'test.patternFiring': [RULES_FEATURE_ID],
'test.patternFiringAad': [RULES_FEATURE_ID],
'test.patternFiringAutoRecoverFalse': [RULES_FEATURE_ID],
'test.patternLongRunning': [RULES_FEATURE_ID],
'test.patternLongRunning.cancelAlertsOnRuleTimeout': [RULES_FEATURE_ID],
'test.patternSuccessOrFailure': [RULES_FEATURE_ID],
'test.restricted-noop': [RULES_FEATURE_ID],
'test.throw': [RULES_FEATURE_ID],
'test.unrestricted-noop': [RULES_FEATURE_ID],
'test.validation': [RULES_FEATURE_ID],
'example.always-firing': [ALERTING_FEATURE_ID],
'example.people-in-space': [ALERTING_FEATURE_ID],
transform_health: [ALERTING_FEATURE_ID],
'.index-threshold': [ALERTING_FEATURE_ID],
'.geo-containment': [ALERTING_FEATURE_ID],
'.es-query': [ALERTING_FEATURE_ID, 'discover'],
'xpack.ml.anomaly_detection_alert': [ALERTING_FEATURE_ID],
'xpack.ml.anomaly_detection_jobs_health': [ALERTING_FEATURE_ID],
'xpack.synthetics.alerts.monitorStatus': [ALERTING_FEATURE_ID],
'xpack.synthetics.alerts.tls': [ALERTING_FEATURE_ID],
'xpack.uptime.alerts.monitorStatus': [ALERTING_FEATURE_ID],
'xpack.uptime.alerts.tlsCertificate': [ALERTING_FEATURE_ID],
'xpack.uptime.alerts.durationAnomaly': [ALERTING_FEATURE_ID],
'xpack.uptime.alerts.tls': [ALERTING_FEATURE_ID],
'siem.eqlRule': [ALERTING_FEATURE_ID],
'siem.savedQueryRule': [ALERTING_FEATURE_ID],
'siem.indicatorRule': [ALERTING_FEATURE_ID],
'siem.mlRule': [ALERTING_FEATURE_ID],
'siem.queryRule': [ALERTING_FEATURE_ID],
'siem.thresholdRule': [ALERTING_FEATURE_ID],
'siem.newTermsRule': [ALERTING_FEATURE_ID],
'siem.notifications': [ALERTING_FEATURE_ID],
'slo.rules.burnRate': [ALERTING_FEATURE_ID],
'logs.alert.document.count': [ALERTING_FEATURE_ID],
'metrics.alert.inventory.threshold': [ALERTING_FEATURE_ID],
'metrics.alert.threshold': [ALERTING_FEATURE_ID],
monitoring_alert_cluster_health: [ALERTING_FEATURE_ID],
monitoring_alert_license_expiration: [ALERTING_FEATURE_ID],
monitoring_alert_cpu_usage: [ALERTING_FEATURE_ID],
monitoring_alert_missing_monitoring_data: [ALERTING_FEATURE_ID],
monitoring_alert_disk_usage: [ALERTING_FEATURE_ID],
monitoring_alert_thread_pool_search_rejections: [ALERTING_FEATURE_ID],
monitoring_alert_thread_pool_write_rejections: [ALERTING_FEATURE_ID],
monitoring_alert_jvm_memory_usage: [ALERTING_FEATURE_ID],
monitoring_alert_nodes_changed: [ALERTING_FEATURE_ID],
monitoring_alert_logstash_version_mismatch: [ALERTING_FEATURE_ID],
monitoring_alert_kibana_version_mismatch: [ALERTING_FEATURE_ID],
monitoring_alert_elasticsearch_version_mismatch: [ALERTING_FEATURE_ID],
monitoring_ccr_read_exceptions: [ALERTING_FEATURE_ID],
monitoring_shard_size: [ALERTING_FEATURE_ID],
'apm.transaction_duration': [ALERTING_FEATURE_ID],
'apm.anomaly': [ALERTING_FEATURE_ID],
'apm.error_rate': [ALERTING_FEATURE_ID],
'apm.transaction_error_rate': [ALERTING_FEATURE_ID],
'test.always-firing': [ALERTING_FEATURE_ID],
'test.always-firing-alert-as-data': [ALERTING_FEATURE_ID],
'test.authorization': [ALERTING_FEATURE_ID],
'test.cancellableRule': [ALERTING_FEATURE_ID],
'test.cumulative-firing': [ALERTING_FEATURE_ID],
'test.exceedsAlertLimit': [ALERTING_FEATURE_ID],
'test.failing': [ALERTING_FEATURE_ID],
'test.gold.noop': [ALERTING_FEATURE_ID],
'test.longRunning': [ALERTING_FEATURE_ID],
'test.multipleSearches': [ALERTING_FEATURE_ID],
'test.never-firing': [ALERTING_FEATURE_ID],
'test.noop': [ALERTING_FEATURE_ID],
'test.onlyContextVariables': [ALERTING_FEATURE_ID],
'test.onlyStateVariables': [ALERTING_FEATURE_ID],
'test.patternFiring': [ALERTING_FEATURE_ID],
'test.patternFiringAad': [ALERTING_FEATURE_ID],
'test.patternFiringAutoRecoverFalse': [ALERTING_FEATURE_ID],
'test.patternLongRunning': [ALERTING_FEATURE_ID],
'test.patternLongRunning.cancelAlertsOnRuleTimeout': [ALERTING_FEATURE_ID],
'test.patternSuccessOrFailure': [ALERTING_FEATURE_ID],
'test.restricted-noop': [ALERTING_FEATURE_ID],
'test.throw': [ALERTING_FEATURE_ID],
'test.unrestricted-noop': [ALERTING_FEATURE_ID],
'test.validation': [ALERTING_FEATURE_ID],
};

const getRuleTypeIdValidLegacyConsumers = (ruleTypeId: string): string[] => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { useState, useEffect, useRef } from 'react';
import { useParams, useLocation } from 'react-router-dom';
import { EuiSpacer, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { RULES_FEATURE_ID, RuleExecutionStatusErrorReasons } from '@kbn/alerting-plugin/common';
import { ALERTING_FEATURE_ID, RuleExecutionStatusErrorReasons } from '@kbn/alerting-plugin/common';
import type { BoolQuery } from '@kbn/es-query';
import type { AlertConsumers } from '@kbn/rule-data-utils';
import { useBreadcrumbs } from '@kbn/observability-shared-plugin/public';
Expand Down Expand Up @@ -186,7 +186,7 @@ export function RuleDetailsPage() {
const isEditable = isRuleEditable({ capabilities, rule, ruleType, ruleTypeRegistry });

const featureIds =
rule?.consumer === RULES_FEATURE_ID && ruleType?.producer
rule?.consumer === ALERTING_FEATURE_ID && ruleType?.producer
? [ruleType.producer as AlertConsumers]
: rule
? [rule.consumer as AlertConsumers]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common';
import { ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common';
import { AppMountParameters, CoreStart } from '@kbn/core/public';
import { __IntlProvider as IntlProvider } from '@kbn/i18n-react';
import { observabilityAIAssistantPluginMock } from '@kbn/observability-ai-assistant-plugin/public/mock';
Expand Down Expand Up @@ -85,10 +85,10 @@ describe('RulesPage with all capabilities', () => {
recoveryActionGroup: { id: 'recovered', name: 'Recovered' },
actionVariables: { context: [], state: [] },
defaultActionGroupId: 'default',
producer: RULES_FEATURE_ID,
producer: ALERTING_FEATURE_ID,
minimumLicenseRequired: 'basic',
authorizedConsumers: {
[RULES_FEATURE_ID]: { all: true },
[ALERTING_FEATURE_ID]: { all: true },
},
ruleTaskTimeout: '1m',
},
Expand All @@ -100,10 +100,10 @@ describe('RulesPage with all capabilities', () => {
recoveryActionGroup: { id: 'recovered', name: 'Recovered' },
actionVariables: { context: [], state: [] },
defaultActionGroupId: 'default',
producer: RULES_FEATURE_ID,
producer: ALERTING_FEATURE_ID,
minimumLicenseRequired: 'basic',
authorizedConsumers: {
[RULES_FEATURE_ID]: { all: true },
[ALERTING_FEATURE_ID]: { all: true },
},
ruleTaskTimeout: '1m',
},
Expand All @@ -115,10 +115,10 @@ describe('RulesPage with all capabilities', () => {
recoveryActionGroup: { id: 'recovered', name: 'Recovered' },
actionVariables: { context: [], state: [] },
defaultActionGroupId: 'default',
producer: RULES_FEATURE_ID,
producer: ALERTING_FEATURE_ID,
minimumLicenseRequired: 'basic',
authorizedConsumers: {
[RULES_FEATURE_ID]: { all: true },
[ALERTING_FEATURE_ID]: { all: true },
},
ruleTaskTimeout: '1m',
},
Expand Down Expand Up @@ -166,10 +166,10 @@ describe('RulesPage with show only capability', () => {
recoveryActionGroup: { id: 'recovered', name: 'Recovered' },
actionVariables: { context: [], state: [] },
defaultActionGroupId: 'default',
producer: RULES_FEATURE_ID,
producer: ALERTING_FEATURE_ID,
minimumLicenseRequired: 'basic',
authorizedConsumers: {
[RULES_FEATURE_ID]: { read: true, all: false },
[ALERTING_FEATURE_ID]: { read: true, all: false },
},
ruleTaskTimeout: '1m',
},
Expand All @@ -179,10 +179,10 @@ describe('RulesPage with show only capability', () => {
recoveryActionGroup: { id: 'recovered', name: 'Recovered' },
actionVariables: { context: [], state: [] },
defaultActionGroupId: 'default',
producer: RULES_FEATURE_ID,
producer: ALERTING_FEATURE_ID,
minimumLicenseRequired: 'basic',
authorizedConsumers: {
[RULES_FEATURE_ID]: { read: true, all: false },
[ALERTING_FEATURE_ID]: { read: true, all: false },
},
ruleTaskTimeout: '1m',
id: '2',
Expand All @@ -196,10 +196,10 @@ describe('RulesPage with show only capability', () => {
recoveryActionGroup: { id: 'recovered', name: 'Recovered' },
actionVariables: { context: [], state: [] },
defaultActionGroupId: 'default',
producer: RULES_FEATURE_ID,
producer: ALERTING_FEATURE_ID,
minimumLicenseRequired: 'basic',
authorizedConsumers: {
[RULES_FEATURE_ID]: { read: true, all: false },
[ALERTING_FEATURE_ID]: { read: true, all: false },
},
ruleTaskTimeout: '1m',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { EuiButton, EuiButtonEmpty, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common';
import { ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { useBreadcrumbs } from '@kbn/observability-shared-plugin/public';
Expand Down Expand Up @@ -64,7 +64,7 @@ export function RulesPage({ activeTab = RULES_TAB_NAME }: RulesPageProps) {

const authorizedRuleTypes = [...ruleTypes.values()];
const authorizedToCreateAnyRules = authorizedRuleTypes.some(
(ruleType) => ruleType.authorizedConsumers[RULES_FEATURE_ID]?.all
(ruleType) => ruleType.authorizedConsumers[ALERTING_FEATURE_ID]?.all
);

const tabs = [
Expand Down Expand Up @@ -143,7 +143,7 @@ export function RulesPage({ activeTab = RULES_TAB_NAME }: RulesPageProps) {

{addRuleFlyoutVisibility && (
<AddRuleFlyout
consumer={RULES_FEATURE_ID}
consumer={ALERTING_FEATURE_ID}
filteredRuleTypes={filteredRuleTypes}
validConsumers={observabilityRuleCreationValidConsumers}
initialSelectedConsumer={AlertConsumers.LOGS}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import { i18n } from '@kbn/i18n';
import { useQuery } from '@tanstack/react-query';
import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common';
import { ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common';
import { useMemo } from 'react';
import { loadRuleTypes } from '../lib/rule_api/rule_types';
import { useKibana } from '../../common/lib/kibana';
Expand Down Expand Up @@ -73,11 +73,11 @@ export const useLoadRuleTypesQuery = ({
const hasAnyAuthorizedRuleType = filteredIndex.size > 0;
const authorizedRuleTypes = useMemo(() => [...filteredIndex.values()], [filteredIndex]);
const authorizedToCreateAnyRules = authorizedRuleTypes.some(
(ruleType) => ruleType.authorizedConsumers[RULES_FEATURE_ID]?.all
(ruleType) => ruleType.authorizedConsumers[ALERTING_FEATURE_ID]?.all
);
const authorizedToReadAnyRules =
authorizedToCreateAnyRules ||
authorizedRuleTypes.some((ruleType) => ruleType.authorizedConsumers[RULES_FEATURE_ID]?.read);
authorizedRuleTypes.some((ruleType) => ruleType.authorizedConsumers[ALERTING_FEATURE_ID]?.read);

return {
ruleTypesState: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { RuleType, ActionVariables } from '../../types';
import { transformActionVariables } from './action_variables';
import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common';
import { ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common';

beforeEach(() => jest.resetAllMocks());

Expand Down Expand Up @@ -325,7 +325,7 @@ function getAlertType(actionVariables: ActionVariables): RuleType {
defaultActionGroupId: 'default',
recoveryActionGroup: { id: 'recovered', name: 'Recovered' },
authorizedConsumers: {},
producer: RULES_FEATURE_ID,
producer: ALERTING_FEATURE_ID,
minimumLicenseRequired: 'basic',
enabledInLicense: true,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { RuleType } from '../../../types';
import { httpServiceMock } from '@kbn/core/public/mocks';
import { loadRuleTypes } from './rule_types';
import { RULES_FEATURE_ID } from '@kbn/alerting-plugin/common';
import { ALERTING_FEATURE_ID } from '@kbn/alerting-plugin/common';

const http = httpServiceMock.createStartContract();

Expand All @@ -23,7 +23,7 @@ describe('loadRuleTypes', () => {
state: [{ name: 'var2', description: 'val2' }],
params: [{ name: 'var3', description: 'val3' }],
},
producer: RULES_FEATURE_ID,
producer: ALERTING_FEATURE_ID,
actionGroups: [{ id: 'default', name: 'Default' }],
recoveryActionGroup: { id: 'recovered', name: 'Recovered' },
defaultActionGroupId: 'default',
Expand Down
Loading

0 comments on commit ea9313d

Please sign in to comment.