diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/index.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/index.ts index e34b3a880c1f0a..df82d44fb50419 100644 --- a/x-pack/plugins/apm/server/lib/apm_telemetry/index.ts +++ b/x-pack/plugins/apm/server/lib/apm_telemetry/index.ts @@ -57,7 +57,8 @@ export async function createApmTelemetry({ const collectAndStore = async () => { const config = await config$.pipe(take(1)).toPromise(); - const esClient = core.elasticsearch.dataClient; + const [{ elasticsearch }] = await core.getStartServices(); + const esClient = elasticsearch.legacy.client; const indices = await getApmIndices({ config, diff --git a/x-pack/plugins/observability/server/lib/annotations/bootstrap_annotations.ts b/x-pack/plugins/observability/server/lib/annotations/bootstrap_annotations.ts index 6ea9f82d11ab91..37e5ad42c3e7cc 100644 --- a/x-pack/plugins/observability/server/lib/annotations/bootstrap_annotations.ts +++ b/x-pack/plugins/observability/server/lib/annotations/bootstrap_annotations.ts @@ -39,7 +39,7 @@ export async function bootstrapAnnotations({ index, core, context }: Params) { getScopedAnnotationsClient: (requestContext: RequestHandlerContext, request: KibanaRequest) => { return createAnnotationsClient({ index, - apiCaller: core.elasticsearch.dataClient.asScoped(request).callAsCurrentUser, + apiCaller: requestContext.core.elasticsearch.dataClient.callAsCurrentUser, logger, license: requestContext.licensing?.license, }); diff --git a/x-pack/plugins/observability/server/lib/annotations/register_annotation_apis.ts b/x-pack/plugins/observability/server/lib/annotations/register_annotation_apis.ts index 21ebfcd6205e72..5bb6be39a20499 100644 --- a/x-pack/plugins/observability/server/lib/annotations/register_annotation_apis.ts +++ b/x-pack/plugins/observability/server/lib/annotations/register_annotation_apis.ts @@ -50,7 +50,7 @@ export function registerAnnotationAPIs({ }); } - const apiCaller = core.elasticsearch.dataClient.asScoped(request).callAsCurrentUser; + const apiCaller = context.core.elasticsearch.dataClient.callAsCurrentUser; const client = createAnnotationsClient({ index,