Get metric indices (#131898)

* Get metric indices

* Infra plugin is required
This commit is contained in:
Katerina Patticha 2022-05-10 18:30:04 +02:00 committed by GitHub
parent ce29dabec6
commit 14ee59ca1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View file

@ -0,0 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { SavedObjectsClientContract } from '@kbn/core/server';
import { APMRouteHandlerResources } from '../../routes/typings';
export async function getMetricIndices({
infraPlugin,
savedObjectsClient,
}: {
infraPlugin: Required<APMRouteHandlerResources['plugins']['infra']>;
savedObjectsClient: SavedObjectsClientContract;
}): Promise<string> {
const infra = await infraPlugin.start();
const metricIndices = await infra.getMetricIndices(savedObjectsClient);
return metricIndices;
}

View file

@ -49,6 +49,7 @@ import {
FleetSetupContract as FleetPluginSetup,
FleetStartContract as FleetPluginStart,
} from '@kbn/fleet-plugin/server';
import { InfraPluginStart, InfraPluginSetup } from '@kbn/infra-plugin/server';
import { APMConfig } from '.';
import { ApmIndicesConfig } from './routes/settings/apm_indices/get_apm_indices';
import { APMEventClient } from './lib/helpers/create_es_client/create_apm_event_client';
@ -71,6 +72,7 @@ export interface APMPluginSetupDependencies {
licensing: LicensingPluginSetup;
observability: ObservabilityPluginSetup;
ruleRegistry: RuleRegistryPluginSetupContract;
infra: InfraPluginSetup;
// optional dependencies
actions?: ActionsPlugin['setup'];
@ -92,6 +94,7 @@ export interface APMPluginStartDependencies {
licensing: LicensingPluginStart;
observability: undefined;
ruleRegistry: RuleRegistryPluginStartContract;
infra: InfraPluginStart;
// optional dependencies
actions?: ActionsPlugin['start'];