Skip to content

Commit

Permalink
[Infra UI] Add kubernetes charts to the host detail view (#166383)
Browse files Browse the repository at this point in the history
closes #162944
## Summary

This PR adds the Kubernetes Overview section to the Host Detail view.

**Old view**
<img width="778" alt="image"
src="https://github.com/elastic/kibana/assets/2767137/2c6c3341-7aa3-48e4-a5d5-e9580b2e2c13">

**New view**
<img width="778" alt="image"
src="https://github.com/elastic/kibana/assets/2767137/357ef56d-b783-41ed-8d7f-e9a3369d13b0">

There was some reog in the formulas folder too, separating nginx and
kubernetes from hosts formulas.

### How to test

- Start a local Kibana pointing to a oblt cluster
- Navigate to `Infrastructure` > `Hosts`
- Click on a `gke` host to navigate to the detail view
  • Loading branch information
crespocarlos authored Sep 20, 2023
1 parent 1de3917 commit f94b4c2
Show file tree
Hide file tree
Showing 42 changed files with 624 additions and 280 deletions.
76 changes: 0 additions & 76 deletions x-pack/plugins/infra/public/common/visualizations/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,81 +5,5 @@
* 2.0.
*/

import {
cpuUsage,
cpuUsageIowait,
cpuUsageIrq,
cpuUsageNice,
cpuUsageSoftirq,
cpuUsageSteal,
cpuUsageUser,
cpuUsageSystem,
diskIORead,
diskIOWrite,
diskReadThroughput,
diskWriteThroughput,
diskSpaceAvailability,
diskSpaceAvailable,
diskUsage,
logRate,
normalizedLoad1m,
load1m,
load5m,
load15m,
memoryUsage,
memoryFree,
memoryUsed,
memoryFreeExcludingCache,
memoryCache,
nginxActiveConnections,
nginxRequestRate,
nginxRequestsPerConnection,
nginxSuccessStatusCodes,
nginxRedirectStatusCodes,
nginxClientErrorStatusCodes,
nginxServerErrorStatusCodes,
rx,
tx,
hostCount,
} from './lens/formulas/host';

export const hostLensFormulas = {
cpuUsage,
cpuUsageIowait,
cpuUsageIrq,
cpuUsageNice,
cpuUsageSoftirq,
cpuUsageSteal,
cpuUsageUser,
cpuUsageSystem,
diskIORead,
diskIOWrite,
diskReadThroughput,
diskWriteThroughput,
diskSpaceAvailability,
diskSpaceAvailable,
diskUsage,
hostCount,
logRate,
normalizedLoad1m,
load1m,
load5m,
load15m,
memoryUsage,
memoryFree,
memoryUsed,
memoryFreeExcludingCache,
memoryCache,
nginxActiveConnections,
nginxRequestRate,
nginxRequestsPerConnection,
nginxSuccessStatusCodes,
nginxRedirectStatusCodes,
nginxClientErrorStatusCodes,
nginxServerErrorStatusCodes,
rx,
tx,
};

export const HOST_METRICS_DOC_HREF = 'https://ela.st/docs-infra-host-metrics';
export const HOST_METRICS_DOTTED_LINES_DOC_HREF = 'https://ela.st/docs-infra-why-dotted';
8 changes: 1 addition & 7 deletions x-pack/plugins/infra/public/common/visualizations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,5 @@
* 2.0.
*/

export type {
HostsLensFormulas,
HostsLensMetricChartFormulas,
HostsLensLineChartFormulas,
} from './types';

export * from './lens/dashboards';
export { hostLensFormulas } from './constants';
export * from './lens/formulas';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { i18n } from '@kbn/i18n';
import type { TypedLensByValueInput } from '@kbn/lens-plugin/public';
import { hostLensFormulas } from '../../../../constants';
import { hostLensFormulas } from '../../../formulas';
import type { MetricChartLayerParams } from '../../../../types';
import { METRICS_TOOLTIP } from '../../translations';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* 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 { i18n } from '@kbn/i18n';
import { kubernetesLensFormulas } from '../../../formulas';
import { XY_OVERRIDES } from '../../constants';
import type { XYConfig } from '../metric_charts/types';

export const kubernetesCharts: XYConfig[] = [
{
id: 'nodeCpuCapacity',
title: i18n.translate('xpack.infra.assetDetails.metricsCharts.kubernetes.nodeCpuCapacity', {
defaultMessage: 'Node CPU Capacity',
}),

layers: [
{
data: [kubernetesLensFormulas.nodeCpuCapacity, kubernetesLensFormulas.nodeCpuUsed],
type: 'visualization',
options: {
seriesType: 'area',
},
},
],
dataViewOrigin: 'metrics',
overrides: {
settings: XY_OVERRIDES.settings,
},
},
{
id: 'nodeMemoryCapacity',
title: i18n.translate('xpack.infra.assetDetails.metricsCharts.nginx.nodeMemoryCapacity', {
defaultMessage: 'Node Memory Capacity',
}),

layers: [
{
data: [kubernetesLensFormulas.nodeMemoryCapacity, kubernetesLensFormulas.nodeMemoryUsed],
type: 'visualization',
options: {
seriesType: 'area',
},
},
],
dataViewOrigin: 'metrics',
overrides: {
settings: XY_OVERRIDES.settings,
},
},
{
id: 'nodeDiskCapacity',
title: i18n.translate('xpack.infra.assetDetails.metricsCharts.nginx.nodeDiskCapacity', {
defaultMessage: 'Node Disk Capacity',
}),

layers: [
{
data: [kubernetesLensFormulas.nodeDiskCapacity, kubernetesLensFormulas.nodeDiskUsed],
type: 'visualization',
options: {
seriesType: 'area',
},
},
],
dataViewOrigin: 'metrics',
overrides: {
settings: XY_OVERRIDES.settings,
},
},
{
id: 'nodePodCapacity',
title: i18n.translate('xpack.infra.assetDetails.metricsCharts.nginx.nodePodCapacity', {
defaultMessage: 'Node Pod Capacity',
}),

layers: [
{
data: [kubernetesLensFormulas.nodePodCapacity, kubernetesLensFormulas.nodePodUsed],
type: 'visualization',
options: {
seriesType: 'area',
},
},
],
dataViewOrigin: 'metrics',
overrides: {
settings: XY_OVERRIDES.settings,
},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,81 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import {
nginxActiveConnections,
nginxRequestRate,
nginxRequestsPerConnection,
nginxResponseStatusCodes,
} from '../metric_charts/nginx';

import { i18n } from '@kbn/i18n';
import { nginxLensFormulas } from '../../../formulas';
import { XY_OVERRIDES } from '../../constants';
import type { XYConfig } from '../metric_charts/types';

export const nginxStubstatusCharts: XYConfig[] = [
nginxActiveConnections,
nginxRequestRate,
nginxRequestsPerConnection,
{
id: 'requestRate',
title: i18n.translate('xpack.infra.assetDetails.metricsCharts.nginx.requestRate', {
defaultMessage: 'Request Rate',
}),

layers: [
{
data: [nginxLensFormulas.requestRate],
type: 'visualization',
},
],
dataViewOrigin: 'metrics',
},
{
id: 'activeConnections',
title: i18n.translate('xpack.infra.assetDetails.metricsCharts.nginx.activeConnections', {
defaultMessage: 'Active Connections',
}),

layers: [
{
data: [nginxLensFormulas.activeConnections],
type: 'visualization',
},
],
dataViewOrigin: 'metrics',
},
{
id: 'requestsPerConnection',
title: i18n.translate('xpack.infra.assetDetails.metricsCharts.nginx.requestsPerConnection', {
defaultMessage: 'Requests Per Connection',
}),

layers: [
{
data: [nginxLensFormulas.requestsPerConnection],
type: 'visualization',
},
],
dataViewOrigin: 'metrics',
},
];

export const nginxAccessCharts: XYConfig[] = [nginxResponseStatusCodes];
export const nginxAccessCharts: XYConfig[] = [
{
id: 'responseStatusCodes',
title: i18n.translate('xpack.infra.assetDetails.metricsCharts.nginx.responseStatusCodes', {
defaultMessage: 'Response Status Codes',
}),

layers: [
{
data: [
nginxLensFormulas.successStatusCodes,
nginxLensFormulas.redirectStatusCodes,
nginxLensFormulas.clientErrorStatusCodes,
nginxLensFormulas.serverErrorStatusCodes,
],
options: {
seriesType: 'area',
},
type: 'visualization',
},
],
overrides: {
settings: XY_OVERRIDES.settings,
},
dataViewOrigin: 'metrics',
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,20 @@
import { hostMetricFlyoutCharts, hostMetricChartsFullPage } from './host/host_metric_charts';
import { hostKPICharts, KPIChartProps } from './host/host_kpi_charts';
import { nginxAccessCharts, nginxStubstatusCharts } from './host/nginx_charts';
import { kubernetesCharts } from './host/kubernetes_charts';

export { type KPIChartProps };
export const assetDetailsDashboards = {
host: { hostMetricFlyoutCharts, hostMetricChartsFullPage, hostKPICharts },
nginx: { nginxStubstatusCharts, nginxAccessCharts },
host: { hostMetricFlyoutCharts, hostMetricChartsFullPage, hostKPICharts, keyField: 'host.name' },
nginx: {
nginxStubstatusCharts,
nginxAccessCharts,
keyField: 'host.name',
dependsOn: ['nginx.stubstatus', 'nginx.access'],
},
kubernetes: {
kubernetesCharts,
keyField: 'kubernetes.node.name',
dependsOn: ['kubernetes.node'],
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { i18n } from '@kbn/i18n';
import { hostLensFormulas } from '../../../../constants';
import { hostLensFormulas } from '../../../formulas';
import { REFERENCE_LINE, XY_OVERRIDES } from '../../constants';
import type { XYConfig } from './types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { i18n } from '@kbn/i18n';
import { hostLensFormulas } from '../../../../constants';
import { hostLensFormulas } from '../../../formulas';
import { XY_OVERRIDES } from '../../constants';
import type { XYConfig } from './types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { i18n } from '@kbn/i18n';
import { hostLensFormulas } from '../../../../constants';
import { hostLensFormulas } from '../../../formulas';
import type { XYConfig } from './types';

export const logRate: XYConfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { i18n } from '@kbn/i18n';
import { hostLensFormulas } from '../../../../constants';
import { hostLensFormulas } from '../../../formulas';
import { XY_OVERRIDES } from '../../constants';
import type { XYConfig } from './types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { i18n } from '@kbn/i18n';
import { hostLensFormulas } from '../../../../constants';
import { hostLensFormulas } from '../../../formulas';
import { XY_OVERRIDES } from '../../constants';
import type { XYConfig } from './types';

Expand Down
Loading

0 comments on commit f94b4c2

Please sign in to comment.