Skip to content

Commit

Permalink
[ObsUx] [Infra] Change container details view with asset details view (
Browse files Browse the repository at this point in the history
…#180436)

Part of #179844

### In this PR
- From Inventory, open asset details page view for Containers
- Show overview tab with CPU and Memory KPIs and metric charts
- Metadata tab with old fields, more metadata fields will be shown in
follow-up PR
- Added links to container metrics documentation, currently there are no
docs for K8s metrics just for docker containers

#### How to test
- The feature is under a FF, on inventory page go to settings and enable
`Container view`
- In containers inventory, select a container and click on 'Docker
container metrics' link (there's an
[issue](#180806) to reword this
links as K8s containers are also shown)
- Container details page should be shown with overview and metadata tabs
- On overview tab KPIs for CPU and Memory and Metrics section with CPU
and Memory charts should be displayed
<img width="937" alt="image"
src="https://github.com/elastic/kibana/assets/31922082/d2f25f2a-ea4f-4516-b216-38464682fd14">
  • Loading branch information
MiriamAparicio authored May 16, 2024
1 parent 2de84ce commit a4579a7
Show file tree
Hide file tree
Showing 81 changed files with 1,889 additions and 374 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.
*/

/* eslint-disable max-classes-per-file */
import { Entity, Fields } from '../entity';
import { Serializable } from '../serializable';

interface DockerContainerDocument extends Fields {
'container.id': string;
'metricset.name'?: string;
}

export class DockerContainer extends Entity<DockerContainerDocument> {
metrics() {
return new DockerContainerMetrics({
...this.fields,
'docker.cpu.total.pct': 25,
'docker.memory.usage.pct': 20,
});
}
}

export interface DockerContainerMetricsDocument extends DockerContainerDocument {
'docker.cpu.total.pct': number;
'docker.memory.usage.pct': number;
}

class DockerContainerMetrics extends Serializable<DockerContainerMetricsDocument> {}

export function dockerContainer(id: string): DockerContainer {
return new DockerContainer({
'container.id': id,
});
}
12 changes: 9 additions & 3 deletions packages/kbn-apm-synthtrace-client/src/lib/infra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@
* Side Public License, v 1.
*/

import { container, ContainerMetricsDocument } from './container';
import { dockerContainer, DockerContainerMetricsDocument } from './docker_container';
import { host, HostMetricsDocument } from './host';
import { k8sContainer, K8sContainerMetricsDocument } from './k8s_container';
import { pod, PodMetricsDocument } from './pod';

export type InfraDocument = HostMetricsDocument | PodMetricsDocument | ContainerMetricsDocument;
export type InfraDocument =
| HostMetricsDocument
| PodMetricsDocument
| DockerContainerMetricsDocument
| K8sContainerMetricsDocument;

export const infra = {
host,
pod,
container,
dockerContainer,
k8sContainer,
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,32 @@
import { Entity, Fields } from '../entity';
import { Serializable } from '../serializable';

interface ContainerDocument extends Fields {
interface K8sContainerDocument extends Fields {
'container.id': string;
'kubernetes.pod.uid': string;
'kubernetes.node.name': string;
'metricset.name'?: string;
}

export class Container extends Entity<ContainerDocument> {
export class K8sContainer extends Entity<K8sContainerDocument> {
metrics() {
return new ContainerMetrics({
return new K8sContainerMetrics({
...this.fields,
'kubernetes.container.cpu.usage.limit.pct': 46,
'kubernetes.container.memory.usage.limit.pct': 30,
});
}
}

export interface ContainerMetricsDocument extends ContainerDocument {
export interface K8sContainerMetricsDocument extends K8sContainerDocument {
'kubernetes.container.cpu.usage.limit.pct': number;
'kubernetes.container.memory.usage.limit.pct': number;
}

class ContainerMetrics extends Serializable<ContainerMetricsDocument> {}
class K8sContainerMetrics extends Serializable<K8sContainerMetricsDocument> {}

export function container(id: string, uid: string, nodeName: string) {
return new Container({
export function k8sContainer(id: string, uid: string, nodeName: string): K8sContainer {
return new K8sContainer({
'container.id': id,
'kubernetes.pod.uid': uid,
'kubernetes.node.name': nodeName,
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-apm-synthtrace-client/src/lib/infra/pod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/* eslint-disable max-classes-per-file */
import { Entity, Fields } from '../entity';
import { Serializable } from '../serializable';
import { container } from './container';
import { k8sContainer } from './k8s_container';

interface PodDocument extends Fields {
'kubernetes.pod.uid': string;
Expand All @@ -26,7 +26,7 @@ export class Pod extends Entity<PodDocument> {
}

container(id: string) {
return container(id, this.fields['kubernetes.pod.uid'], this.fields['kubernetes.node.name']);
return k8sContainer(id, this.fields['kubernetes.pod.uid'], this.fields['kubernetes.node.name']);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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, infra } from '@kbn/apm-synthtrace-client';

import { Scenario } from '../cli/scenario';
import { withClient } from '../lib/utils/with_client';

const scenario: Scenario<InfraDocument> = async (runOptions) => {
return {
generate: ({ range, clients: { infraEsClient } }) => {
const { numContainers = 5 } = runOptions.scenarioOpts || {};
const { logger } = runOptions;

const CONTAINERS = Array(numContainers)
.fill(0)
.map((_, idx) => infra.dockerContainer(`container-${idx}`));

const containers = range
.interval('30s')
.rate(1)
.generator((timestamp) =>
CONTAINERS.flatMap((container) => [container.metrics().timestamp(timestamp)])
);

return [
withClient(
infraEsClient,
logger.perf('generating_infra_docker_containers', () => containers)
),
];
},
};
};

export default scenario;
41 changes: 41 additions & 0 deletions packages/kbn-apm-synthtrace/src/scenarios/infra_k8s_containers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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, infra } from '@kbn/apm-synthtrace-client';

import { Scenario } from '../cli/scenario';
import { withClient } from '../lib/utils/with_client';

const scenario: Scenario<InfraDocument> = async (runOptions) => {
return {
generate: ({ range, clients: { infraEsClient } }) => {
const { numContainers = 5 } = runOptions.scenarioOpts || {};
const { logger } = runOptions;

const CONTAINERS = Array(numContainers)
.fill(0)
.map((_, idx) => infra.k8sContainer(`container-${idx}`, `pod-${idx}`, `node-${idx}`));

const containers = range
.interval('30s')
.rate(1)
.generator((timestamp) =>
CONTAINERS.flatMap((container) => [container.metrics().timestamp(timestamp)])
);

return [
withClient(
infraEsClient,
logger.perf('generating_infra_containers', () => containers)
),
];
},
};
};

export default scenario;
2 changes: 2 additions & 0 deletions packages/kbn-management/settings/setting_ids/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ export const OBSERVABILITY_ENABLE_COMPARISON_BY_DEFAULT_ID =
'observability:enableComparisonByDefault';
export const OBSERVABILITY_ENABLE_INFRASTRUCTURE_HOSTS_VIEW_ID =
'observability:enableInfrastructureHostsView';
export const OBSERVABILITY_ENABLE_CONTAINER_ASSET_VIEW_ID =
'observability:enableContainerAssetView';
export const OBSERVABILITY_ENABLE_INFRASTRUCTURE_ASSET_CUSTOM_DASHBOARDS_ID =
'observability:enableInfrastructureAssetCustomDashboards';
export const OBSERVABILITY_ENABLE_INSPECT_ES_QUERIES_ID = 'observability:enableInspectEsQueries';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,10 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'observability:enableInfrastructureContainerAssetView': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'observability:enableInfrastructureProfilingIntegration': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface UsageStats {
'observability:apmAWSLambdaPriceFactor': string;
'observability:apmAWSLambdaRequestCostPerMillion': number;
'observability:enableInfrastructureHostsView': boolean;
'observability:enableInfrastructureContainerAssetView': boolean;
'observability:enableInfrastructureProfilingIntegration': boolean;
'observability:enableInfrastructureAssetCustomDashboards': boolean;
'observability:apmAgentExplorerView': boolean;
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10404,6 +10404,12 @@
"description": "Non-default value of setting."
}
},
"observability:enableInfrastructureContainerAssetView":{
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"observability:enableInfrastructureProfilingIntegration": {
"type": "boolean",
"_meta": {
Expand Down
Loading

0 comments on commit a4579a7

Please sign in to comment.