forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Infra UI] Add APM to Metadata Endpoint (elastic#42197)
* [Infra UI] Add APM to Metadata Endpoint - Adds APM feature to metadata - Closes elastic#42167 - Based on elastic#41836 * migrating to new http api
- Loading branch information
1 parent
b8fa391
commit 8a6b6dd
Showing
8 changed files
with
17,892 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
x-pack/legacy/plugins/infra/server/routes/metadata/lib/has_apm_data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
InfraFrameworkRequest, | ||
InfraBackendFrameworkAdapter, | ||
} from '../../../lib/adapters/framework'; | ||
import { InfraSourceConfiguration } from '../../../lib/sources'; | ||
import { getIdFieldName } from './get_id_field_name'; | ||
|
||
export const hasAPMData = async ( | ||
framework: InfraBackendFrameworkAdapter, | ||
req: InfraFrameworkRequest, | ||
sourceConfiguration: InfraSourceConfiguration, | ||
nodeId: string, | ||
nodeType: 'host' | 'pod' | 'container' | ||
) => { | ||
const config = framework.config(req); | ||
const apmIndex = config.get('apm_oss.transactionIndices') || 'apm-*'; | ||
// There is a bug in APM ECS data where host.name is not set. | ||
// This will fixed with: https://github.com/elastic/apm-server/issues/2502 | ||
const nodeFieldName = | ||
nodeType === 'host' ? 'host.hostname' : getIdFieldName(sourceConfiguration, nodeType); | ||
const params = { | ||
allowNoIndices: true, | ||
ignoreUnavailable: true, | ||
terminateAfter: 1, | ||
index: apmIndex, | ||
body: { | ||
size: 0, | ||
query: { | ||
bool: { | ||
filter: [ | ||
{ | ||
match: { [nodeFieldName]: nodeId }, | ||
}, | ||
{ | ||
exists: { field: 'service.name' }, | ||
}, | ||
{ | ||
exists: { field: 'transaction.type' }, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}; | ||
const response = await framework.callWithRequest<{}, {}>(req, 'search', params); | ||
return response.hits.total.value !== 0; | ||
}; |
Oops, something went wrong.