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] Show only hosts with metrics collected by system module in…
… the hosts view (elastic#177239) Closes elastic#176403 ## Summary This PR adds a filter for the `event.module` to be `system` because the Hosts View is only compatible with the metrics-system indices - I added a [comment](elastic#176403 (comment)) to explain the change in the query. It adds infra client as part of the synthtrace and a scenario to test the change ## Testing - Use the new synthtrace scenario: `node scripts/synthtrace --clean infra_hosts_with_apm_hosts.ts` - By default there should be `10` host visible on the host view and 3 separate services in APM (the APM hosts should not be visible) - The scenario can be used with different numbers of services/hosts for example: `node scripts/synthtrace --clean --scenarioOpts.numServices=5 --scenarioOpts.numHosts=5 infra_hosts_with_apm_hosts.ts` - 5 hosts shown on Infrastructure > Hosts (the APM hosts should not be visible) ![image](https://github.com/elastic/kibana/assets/14139027/d8763a24-95c2-43cd-991b-23edd102f47a) - 5 services shown on APM > Services ![image](https://github.com/elastic/kibana/assets/14139027/0638cfdb-3d6f-4f72-915d-d67764bc9349) - Use remote cluster (with APM) - The hosts with `0` metrics coming from APM should not be visible: <img width="1920" alt="image" src="https://github.com/elastic/kibana/assets/14139027/af69efc0-bbd9-47ae-8431-2a56fa0626c4">
- Loading branch information
1 parent
0dcd8f3
commit 7658baf
Showing
12 changed files
with
195 additions
and
9 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
32 changes: 32 additions & 0 deletions
32
packages/kbn-apm-synthtrace/src/cli/utils/get_infra_es_client.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,32 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { Client } from '@elastic/elasticsearch'; | ||
import { InfraSynthtraceEsClient } from '../../lib/infra/infra_synthtrace_es_client'; | ||
import { Logger } from '../../lib/utils/create_logger'; | ||
import { RunOptions } from './parse_run_cli_flags'; | ||
|
||
export function getInfraEsClient({ | ||
target, | ||
logger, | ||
concurrency, | ||
}: Pick<RunOptions, 'concurrency'> & { | ||
target: string; | ||
logger: Logger; | ||
}) { | ||
const client = new Client({ | ||
node: target, | ||
}); | ||
|
||
return new InfraSynthtraceEsClient({ | ||
client, | ||
logger, | ||
concurrency, | ||
refreshAfterIndex: true, | ||
}); | ||
} |
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
82 changes: 82 additions & 0 deletions
82
packages/kbn-apm-synthtrace/src/scenarios/infra_hosts_with_apm_hosts.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,82 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
import { InfraDocument, apm, Instance, infra, ApmFields } from '@kbn/apm-synthtrace-client'; | ||
import { Scenario } from '../cli/scenario'; | ||
import { withClient } from '../lib/utils/with_client'; | ||
import { getSynthtraceEnvironment } from '../lib/utils/get_synthtrace_environment'; | ||
|
||
const ENVIRONMENT = getSynthtraceEnvironment(__filename); | ||
|
||
const scenario: Scenario<InfraDocument | ApmFields> = async (runOptions) => { | ||
return { | ||
generate: ({ range, clients: { infraEsClient, apmEsClient } }) => { | ||
const { numServices = 3, numHosts = 10 } = runOptions.scenarioOpts || {}; | ||
const { logger } = runOptions; | ||
|
||
// Infra hosts Data logic | ||
|
||
const HOSTS = Array(numHosts) | ||
.fill(0) | ||
.map((_, idx) => infra.host(`my-host-${idx}`)); | ||
|
||
const hosts = range | ||
.interval('30s') | ||
.rate(1) | ||
.generator((timestamp) => | ||
HOSTS.flatMap((host) => [ | ||
host.cpu().timestamp(timestamp), | ||
host.memory().timestamp(timestamp), | ||
host.network().timestamp(timestamp), | ||
host.load().timestamp(timestamp), | ||
host.filesystem().timestamp(timestamp), | ||
host.diskio().timestamp(timestamp), | ||
]) | ||
); | ||
|
||
// APM Simple Trace | ||
|
||
const instances = [...Array(numServices).keys()].map((index) => | ||
apm | ||
.service({ name: `synth-node-${index}`, environment: ENVIRONMENT, agentName: 'nodejs' }) | ||
.instance('instance') | ||
); | ||
const instanceSpans = (instance: Instance) => { | ||
const metricsets = range | ||
.interval('30s') | ||
.rate(1) | ||
.generator((timestamp) => | ||
instance | ||
.appMetrics({ | ||
'system.memory.actual.free': 800, | ||
'system.memory.total': 1000, | ||
'system.cpu.total.norm.pct': 0.6, | ||
'system.process.cpu.total.norm.pct': 0.7, | ||
}) | ||
.timestamp(timestamp) | ||
); | ||
|
||
return [metricsets]; | ||
}; | ||
|
||
return [ | ||
withClient( | ||
infraEsClient, | ||
logger.perf('generating_infra_hosts', () => hosts) | ||
), | ||
withClient( | ||
apmEsClient, | ||
logger.perf('generating_apm_events', () => | ||
instances.flatMap((instance) => instanceSpans(instance)) | ||
) | ||
), | ||
]; | ||
}, | ||
}; | ||
}; | ||
|
||
export default scenario; |
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
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