Skip to content

Commit

Permalink
[Infra UI] Refactor Inventory Models (elastic#46403)
Browse files Browse the repository at this point in the history
* [Infra UI] Refactor Inventory DSL

* Updating types

* Adding types

* moving from metric_models to inventory_models

* Fixing Kubernetes toolbars

* Add models to index file

* Removing snapshot metric aggregations in favor of inventory models

* Removing TSVB models and replacing with inventory models

* Fixing the glorious types

* Removing obsolete layouts

* removing obsolete message

* removing toolbar
  • Loading branch information
simianhacker committed Nov 18, 2019
1 parent 14579af commit 42b7ac6
Show file tree
Hide file tree
Showing 104 changed files with 1,897 additions and 1,931 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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 { layout } from './layout';
import { metrics } from './metrics';
import { InventoryModel } from '../types';

export const container: InventoryModel = {
id: 'container',
requiredModules: ['docker'],
layout,
metrics,
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,26 @@
*/

import { i18n } from '@kbn/i18n';
import { InfraMetric } from '../../../graphql/types';
import { InfraFormatterType } from '../../../lib/lib';
import { nginxLayoutCreator } from './nginx';
import {
InfraMetricLayoutCreator,
InfraMetricLayoutSectionType,
InfraMetricLayoutVisualizationType,
} from './types';
import { InventoryDetailLayoutCreator } from '../types';
import { nginxLayoutCreator } from '../shared/layouts/nginx';

export const containerLayoutCreator: InfraMetricLayoutCreator = theme => [
export const layout: InventoryDetailLayoutCreator = theme => [
{
id: 'containerOverview',
label: i18n.translate('xpack.infra.metricDetailPage.containerMetricsLayout.layoutLabel', {
defaultMessage: 'Container',
}),
sections: [
{
id: InfraMetric.containerOverview,
id: 'containerOverview',
label: i18n.translate(
'xpack.infra.metricDetailPage.containerMetricsLayout.overviewSection.sectionLabel',
{
defaultMessage: 'Overview',
}
),
requires: ['docker.cpu', 'docker.memory', 'docker.network'],
type: InfraMetricLayoutSectionType.gauges,
type: 'gauges',
visConfig: {
seriesOverrides: {
cpu: {
Expand All @@ -41,7 +35,7 @@ export const containerLayoutCreator: InfraMetricLayoutCreator = theme => [
}
),
color: theme.eui.euiColorFullShade,
formatter: InfraFormatterType.percent,
formatter: 'percent',
gaugeMax: 1,
},
memory: {
Expand All @@ -52,7 +46,7 @@ export const containerLayoutCreator: InfraMetricLayoutCreator = theme => [
}
),
color: theme.eui.euiColorFullShade,
formatter: InfraFormatterType.percent,
formatter: 'percent',
gaugeMax: 1,
},
rx: {
Expand All @@ -63,7 +57,7 @@ export const containerLayoutCreator: InfraMetricLayoutCreator = theme => [
}
),
color: theme.eui.euiColorFullShade,
formatter: InfraFormatterType.bits,
formatter: 'bits',
formatterTemplate: '{{value}}/s',
},
tx: {
Expand All @@ -74,76 +68,64 @@ export const containerLayoutCreator: InfraMetricLayoutCreator = theme => [
}
),
color: theme.eui.euiColorFullShade,
formatter: InfraFormatterType.bits,
formatter: 'bits',
formatterTemplate: '{{value}}/s',
},
},
},
},
{
id: InfraMetric.containerCpuUsage,
id: 'containerCpuUsage',
label: i18n.translate(
'xpack.infra.metricDetailPage.containerMetricsLayout.cpuUsageSection.sectionLabel',
{
defaultMessage: 'CPU Usage',
}
),
requires: ['docker.cpu'],
type: InfraMetricLayoutSectionType.chart,
type: 'chart',
visConfig: {
stacked: true,
type: InfraMetricLayoutVisualizationType.area,
formatter: InfraFormatterType.percent,
type: 'area',
formatter: 'percent',
seriesOverrides: {
cpu: {
color: theme.eui.euiColorVis1,
name: i18n.translate(
'xpack.infra.metricDetailPage.containerMetricsLayout.cpuUsageSection.seriesLabel.cpu',
{ defaultMessage: 'cpu' }
),
},
cpu: { color: theme.eui.euiColorVis1 },
},
},
},
{
id: InfraMetric.containerMemory,
id: 'containerMemory',
label: i18n.translate(
'xpack.infra.metricDetailPage.containerMetricsLayout.memoryUsageSection.sectionLabel',
{
defaultMessage: 'Memory Usage',
}
),
requires: ['docker.memory'],
type: InfraMetricLayoutSectionType.chart,
type: 'chart',
visConfig: {
stacked: true,
type: InfraMetricLayoutVisualizationType.area,
formatter: InfraFormatterType.percent,
type: 'area',
formatter: 'percent',
seriesOverrides: {
memory: {
color: theme.eui.euiColorVis1,
name: i18n.translate(
'xpack.infra.metricDetailPage.containerMetricsLayout.memoryUsageSection.seriesLabel.memory',
{ defaultMessage: 'memory' }
),
},
memory: { color: theme.eui.euiColorVis1 },
},
},
},
{
id: InfraMetric.containerNetworkTraffic,
id: 'containerNetworkTraffic',
label: i18n.translate(
'xpack.infra.metricDetailPage.containerMetricsLayout.networkTrafficSection.sectionLabel',
{
defaultMessage: 'Network Traffic',
}
),
requires: ['docker.network'],
type: InfraMetricLayoutSectionType.chart,
type: 'chart',
visConfig: {
formatter: InfraFormatterType.bits,
formatter: 'bits',
formatterTemplate: '{{value}}/s',
type: InfraMetricLayoutVisualizationType.area,
type: 'area',
seriesOverrides: {
rx: {
color: theme.eui.euiColorVis1,
Expand All @@ -167,19 +149,19 @@ export const containerLayoutCreator: InfraMetricLayoutCreator = theme => [
},
},
{
id: InfraMetric.containerDiskIOOps,
id: 'containerDiskIOOps',
label: i18n.translate(
'xpack.infra.metricDetailPage.containerMetricsLayout.diskIoOpsSection.sectionLabel',
{
defaultMessage: 'Disk IO (Ops)',
}
),
requires: ['docker.diskio'],
type: InfraMetricLayoutSectionType.chart,
type: 'chart',
visConfig: {
formatter: InfraFormatterType.number,
formatter: 'number',
formatterTemplate: '{{value}}/s',
type: InfraMetricLayoutVisualizationType.area,
type: 'area',
seriesOverrides: {
read: {
color: theme.eui.euiColorVis1,
Expand All @@ -203,19 +185,19 @@ export const containerLayoutCreator: InfraMetricLayoutCreator = theme => [
},
},
{
id: InfraMetric.containerDiskIOBytes,
id: 'containerDiskIOBytes',
label: i18n.translate(
'xpack.infra.metricDetailPage.containerMetricsLayout.diskIoBytesSection.sectionLabel',
{
defaultMessage: 'Disk IO (Bytes)',
}
),
requires: ['docker.diskio'],
type: InfraMetricLayoutSectionType.chart,
type: 'chart',
visConfig: {
formatter: InfraFormatterType.bytes,
formatter: 'bytes',
formatterTemplate: '{{value}}/s',
type: InfraMetricLayoutVisualizationType.area,
type: 'area',
seriesOverrides: {
read: {
color: theme.eui.euiColorVis1,
Expand Down
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;
* you may not use this file except in compliance with the Elastic License.
*/

import { InventoryMetrics } from '../../types';
import { cpu } from './snapshot/cpu';
import { memory } from './snapshot/memory';
import { rx } from './snapshot/rx';
import { tx } from './snapshot/tx';

import { containerOverview } from './tsvb/container_overview';
import { containerCpuUsage } from './tsvb/container_cpu_usage';
import { containerCpuKernel } from './tsvb/container_cpu_kernel';
import { containerDiskIOOps } from './tsvb/container_diskio_ops';
import { containerDiskIOBytes } from './tsvb/container_disk_io_bytes';
import { containerMemory } from './tsvb/container_memory';
import { containerNetworkTraffic } from './tsvb/container_network_traffic';

export const metrics: InventoryMetrics = {
tsvb: {
containerOverview,
containerCpuUsage,
containerCpuKernel,
containerDiskIOOps,
containerDiskIOBytes,
containerNetworkTraffic,
containerMemory,
},
snapshot: { cpu, memory, rx, tx },
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/

export const count = () => {
return {
count: {
bucket_script: {
buckets_path: { count: '_count' },
script: {
source: 'count * 1',
lang: 'expression',
},
gap_policy: 'skip',
},
import { SnapshotModel } from '../../../types';

export const cpu: SnapshotModel = {
cpu: {
avg: {
field: 'docker.cpu.total.pct',
},
};
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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 { SnapshotModel } from '../../../types';

export const memory: SnapshotModel = { memory: { avg: { field: 'docker.memory.usage.pct' } } };
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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 { networkTrafficWithInterfaces } from '../../../shared/metrics/snapshot/network_traffic_with_interfaces';
export const rx = networkTrafficWithInterfaces(
'rx',
'docker.network.in.bytes',
'docker.network.interface'
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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 { networkTrafficWithInterfaces } from '../../../shared/metrics/snapshot/network_traffic_with_interfaces';
export const tx = networkTrafficWithInterfaces(
'tx',
'docker.network.out.bytes',
'docker.network.interface'
);
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { InfraMetricModelCreator, InfraMetricModelMetricType } from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';
import { TSVBMetricModelCreator, TSVBMetricModel } from '../../../types';

export const containerCpuKernel: InfraMetricModelCreator = (timeField, indexPattern, interval) => ({
id: InfraMetric.containerCpuKernel,
export const containerCpuKernel: TSVBMetricModelCreator = (
timeField,
indexPattern,
interval
): TSVBMetricModel => ({
id: 'containerCpuKernel',
requires: ['docker.cpu'],
index_pattern: indexPattern,
interval,
Expand All @@ -22,7 +25,7 @@ export const containerCpuKernel: InfraMetricModelCreator = (timeField, indexPatt
{
field: 'docker.cpu.kernel.pct',
id: 'avg-cpu-kernel',
type: InfraMetricModelMetricType.avg,
type: 'avg',
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { InfraMetricModelCreator, InfraMetricModelMetricType } from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';
import { TSVBMetricModelCreator, TSVBMetricModel } from '../../../types';

export const containerCpuUsage: InfraMetricModelCreator = (timeField, indexPattern, interval) => ({
id: InfraMetric.containerCpuUsage,
export const containerCpuUsage: TSVBMetricModelCreator = (
timeField,
indexPattern,
interval
): TSVBMetricModel => ({
id: 'containerCpuUsage',
requires: ['docker.cpu'],
index_pattern: indexPattern,
interval,
Expand All @@ -22,7 +25,7 @@ export const containerCpuUsage: InfraMetricModelCreator = (timeField, indexPatte
{
field: 'docker.cpu.total.pct',
id: 'avg-cpu-total',
type: InfraMetricModelMetricType.avg,
type: 'avg',
},
],
},
Expand Down
Loading

0 comments on commit 42b7ac6

Please sign in to comment.