Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Fallback to the default space ID #158634

Merged
merged 3 commits into from
Jun 5, 2023

Conversation

kpatticha
Copy link
Contributor

@kpatticha kpatticha commented May 29, 2023

closing #155329

files using space id
apm • server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts:
   19  import { createLifecycleRuleTypeFactory } from '@kbn/rule-registry-plugin/server';
   20: import { addSpaceIdToPath } from '@kbn/spaces-plugin/common';
   21  import { compact } from 'lodash';

   89        isExportable: true,
   90:       executor: async ({ params, services, spaceId }) => {
   91          if (!ml) {

  278  
  279:           const viewInAppUrl = addSpaceIdToPath(
  280              basePath.publicBaseUrl,
  281:             spaceId,
  282              relativeViewInAppUrl

apm • server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts:
   19  import { termQuery } from '@kbn/observability-plugin/server';
   20: import { addSpaceIdToPath } from '@kbn/spaces-plugin/common';
   21  import { firstValueFrom } from 'rxjs';

   88        isExportable: true,
   89:       executor: async ({ params: ruleParams, services, spaceId }) => {
   90:         console.log('spaceId executor====', spaceId);
   91          const predefinedGroupby = [SERVICE_NAME, SERVICE_ENVIRONMENT];

  189  
  190:             const viewInAppUrl = addSpaceIdToPath(
  191                basePath.publicBaseUrl,
  192:               spaceId,
  193                relativeViewInAppUrl

apm • server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts:
   22  import { createLifecycleRuleTypeFactory } from '@kbn/rule-registry-plugin/server';
   23: import { addSpaceIdToPath } from '@kbn/spaces-plugin/common';
   24  import { firstValueFrom } from 'rxjs';

  104      isExportable: true,
  105:     executor: async ({ params: ruleParams, services, spaceId }) => {
  106        const predefinedGroupby = [

  257            basePath,
  258:           spaceId,
  259            alertUuid

  261  
  262:         const viewInAppUrl = addSpaceIdToPath(
  263            basePath.publicBaseUrl,
  264:           spaceId,
  265            getAlertUrlTransaction(

apm • server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts:
   20  import { createLifecycleRuleTypeFactory } from '@kbn/rule-registry-plugin/server';
   21: import { addSpaceIdToPath } from '@kbn/spaces-plugin/common';
   22  import { firstValueFrom } from 'rxjs';

   98        isExportable: true,
   99:       executor: async ({ services, spaceId, params: ruleParams }) => {
  100:         console.log('error rate executor space', spaceId);
  101          const predefinedGroupby = [

  251  
  252:           const viewInAppUrl = addSpaceIdToPath(
  253              basePath.publicBaseUrl,
  254:             spaceId,
  255              relativeViewInAppUrl

apm • server/routes/service_groups/get_service_group_alerts.ts:
  24    logger,
  25:   spaceId,
  26  }: {

  30    logger: Logger;
  31:   spaceId?: string;
  32  }) {
  33:   if (!spaceId || serviceGroups.length === 0) {
  34      return {};

apm • server/routes/service_groups/route.ts:
  189          logger,
  190:         spaceId: activeSpace?.id ?? DEFAULT_SPACE_ID,
  191        }),

apm • server/saved_objects/migrations/migrate_legacy_apm_indices_to_space_aware.ts:
  79          // Skip default space since it was already updated
  80:         .filter(({ id: spaceId }) => spaceId !== 'default')
  81:         .map(({ id: spaceId }) => ({
  82            id: APM_INDEX_SETTINGS_SAVED_OBJECT_ID,
  83            type: APM_INDEX_SETTINGS_SAVED_OBJECT_TYPE,
  84:           initialNamespaces: [spaceId],
  85            attributes: savedObjectAttributes,

apm • public/components/app/settings/apm_indices/index.tsx:
  105    const { data: space } = useFetcher(() => {
  106:     return services.spaces?.getActiveSpace();
  107    }, [services.spaces]);

apm • server/routes/service_groups/route.ts:
  174          getApmEventClient(resources),
  175:         await spacesPluginStart?.spacesService.getActiveSpace(request),
  176        ]);


Notes

it's a bit challenging to ensure the other plugins return the default space or have the plugin as optional. How do we want to handle these cases, if there are any?

for example, alert returns default space when the plugin is disabled.

Relate link PR
#149044

@kpatticha kpatticha added release_note:skip Skip the PR/issue when compiling release notes apm:serverless v8.9.0 labels May 29, 2023
@kpatticha kpatticha requested a review from a team as a code owner May 29, 2023 20:54
@botelastic botelastic bot added the Team:APM All issues that need APM UI Team support label May 29, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:APM)

@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@@ -5,6 +5,8 @@ enterpriseSearch.enabled: false
xpack.cloudSecurityPosture.enabled: false
xpack.securitySolution.enabled: false

xpack.spaces.enabled: false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keeping it for testing.

@kpatticha kpatticha force-pushed the 155329-spaces-serverless branch from 1aa9ecd to 8ac039e Compare June 5, 2023 11:14
@kpatticha
Copy link
Contributor Author

kpatticha commented Jun 5, 2023

To unblock the progress of the PR, I removed the API testing setup from it as the security plugin is disabled by default in serverless and I encountered difficulties using synthrace for testing.

If you have any suggestions on how to test the change, please let me know. I'm considering using archives on the serverless platform, but I'm not sure if it's worth the extra effort.

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
securitySolution 414 418 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
securitySolution 498 502 +4
total +6

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@kpatticha kpatticha merged commit a1c78ad into elastic:main Jun 5, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:serverless backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:APM All issues that need APM UI Team support v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants