Skip to content

Commit

Permalink
[Infra UI] Fix section mapping bug in node detail page (elastic#41641)
Browse files Browse the repository at this point in the history
* [Infra UI] Fix section mapping bug in node detail page

* Fixing filter to match TSVB

* Adding an enum for the InfraMetricsQueryType

* removing unnecessary change

* Change id to InfraMetric to make less error prone

* Fixing type in Metrics Explorer
  • Loading branch information
simianhacker committed Jul 22, 2019
1 parent 933a3e5 commit 3788410
Show file tree
Hide file tree
Showing 35 changed files with 90 additions and 36 deletions.
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/infra/common/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ export enum InfraMetric {
nginxRequestRate = 'nginxRequestRate',
nginxActiveConnections = 'nginxActiveConnections',
nginxRequestsPerConnection = 'nginxRequestsPerConnection',
custom = 'custom',
}

// ====================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2383,7 +2383,8 @@
"description": "",
"isDeprecated": false,
"deprecationReason": null
}
},
{ "name": "custom", "description": "", "isDeprecated": false, "deprecationReason": null }
],
"possibleTypes": null
},
Expand Down
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/infra/public/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ export enum InfraMetric {
nginxRequestRate = 'nginxRequestRate',
nginxActiveConnections = 'nginxActiveConnections',
nginxRequestsPerConnection = 'nginxRequestsPerConnection',
custom = 'custom',
}

// ====================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const metricsSchema: any = gql`
nginxRequestRate
nginxActiveConnections
nginxRequestsPerConnection
custom
}
type InfraMetricData {
Expand Down
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/infra/server/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ export enum InfraMetric {
nginxRequestRate = 'nginxRequestRate',
nginxActiveConnections = 'nginxActiveConnections',
nginxRequestsPerConnection = 'nginxRequestsPerConnection',
custom = 'custom',
}

// ====================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export interface InfraMetricsAdapter {
): Promise<InfraMetricData[]>;
}

export enum InfraMetricModelQueryType {
lucene = 'lucene',
kuery = 'kuery',
}

export enum InfraMetricModelMetricType {
avg = 'avg',
max = 'max',
Expand All @@ -42,7 +47,7 @@ export enum InfraMetricModelMetricType {
}

export interface InfraMetricModel {
id: string;
id: InfraMetric;
requires: string[];
index_pattern: string | string[];
interval: string;
Expand All @@ -60,7 +65,7 @@ export interface InfraMetricModelSeries {
terms_field?: string;
terms_size?: number;
terms_order_by?: string;
filter?: string;
filter?: { query: string; language: InfraMetricModelQueryType };
}

export interface InfraMetricModelBasicMetric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ export class KibanaMetricsAdapter implements InfraMetricsAdapter {

const requests = options.metrics.map(metricId => {
const model = metricModels[metricId](timeField, indexPattern, interval);
const filters = [{ match: { [nodeField]: options.nodeId } }];
const filters = model.map_field_to
? [{ match: { [model.map_field_to]: options.nodeId } }]
: [{ match: { [nodeField]: options.nodeId } }];
return this.framework.makeTSVBRequest(req, model, timerange, filters);
});
return Promise.all(requests)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/

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

export const containerCpuKernel: InfraMetricModelCreator = (timeField, indexPattern, interval) => ({
id: 'containerCpuKernel',
id: InfraMetric.containerCpuKernel,
requires: ['docker.cpu'],
index_pattern: indexPattern,
interval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/

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

export const containerCpuUsage: InfraMetricModelCreator = (timeField, indexPattern, interval) => ({
id: 'containerCpuUsage',
id: InfraMetric.containerCpuUsage,
requires: ['docker.cpu'],
index_pattern: indexPattern,
interval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
*/

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

export const containerDiskIOBytes: InfraMetricModelCreator = (
timeField,
indexPattern,
interval
) => ({
id: 'containerDiskIOBytes',
id: InfraMetric.containerDiskIOBytes,
requires: ['docker.disk'],
index_pattern: indexPattern,
interval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/

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

export const containerDiskIOOps: InfraMetricModelCreator = (timeField, indexPattern, interval) => ({
id: 'containerDiskIOOps',
id: InfraMetric.containerDiskIOOps,
requires: ['docker.disk'],
index_pattern: indexPattern,
interval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/

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

export const containerMemory: InfraMetricModelCreator = (timeField, indexPattern, interval) => ({
id: 'containerMemory',
id: InfraMetric.containerMemory,
requires: ['docker.memory'],
index_pattern: indexPattern,
interval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
*/

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

export const containerNetworkTraffic: InfraMetricModelCreator = (
timeField,
indexPattern,
interval
) => ({
id: 'containerNetworkTraffic',
id: InfraMetric.containerNetworkTraffic,
requires: ['docker.network'],
index_pattern: indexPattern,
interval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
*/

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

export const containerOverview: InfraMetricModelCreator = (timeField, indexPattern, interval) => ({
id: 'containerOverview',
id: InfraMetric.containerOverview,
requires: ['docker'],
index_pattern: indexPattern,
interval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import {
InfraMetricModelMetricType,
InfraMetricModel,
} from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';

export const hostCpuUsage: InfraMetricModelCreator = (
timeField,
indexPattern,
interval
): InfraMetricModel => ({
id: 'hostCpuUsage',
id: InfraMetric.hostCpuUsage,
requires: ['system.cpu'],
index_pattern: indexPattern,
interval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import {
InfraMetricModelMetricType,
InfraMetricModel,
} from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';

export const hostFilesystem: InfraMetricModelCreator = (
timeField,
indexPattern,
interval
): InfraMetricModel => ({
id: 'hostFilesystem',
id: InfraMetric.hostFilesystem,
requires: ['system.filesystem'],
filter: 'system.filesystem.device_name:\\/*',
index_pattern: indexPattern,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import {
InfraMetricModelMetricType,
InfraMetricModel,
} from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';

export const hostK8sCpuCap: InfraMetricModelCreator = (
timeField,
indexPattern,
interval
): InfraMetricModel => ({
id: 'hostK8sCpuCap',
id: InfraMetric.hostK8sCpuCap,
map_field_to: 'kubernetes.node.name',
requires: ['kubernetes.node'],
index_pattern: indexPattern,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import {
InfraMetricModelMetricType,
InfraMetricModel,
} from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';

export const hostK8sDiskCap: InfraMetricModelCreator = (
timeField,
indexPattern,
interval
): InfraMetricModel => ({
id: 'hostK8sDiskCap',
id: InfraMetric.hostK8sDiskCap,
map_field_to: 'kubernetes.node.name',
requires: ['kubernetes.node'],
index_pattern: indexPattern,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import {
InfraMetricModelMetricType,
InfraMetricModel,
} from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';

export const hostK8sMemoryCap: InfraMetricModelCreator = (
timeField,
indexPattern,
interval
): InfraMetricModel => ({
id: 'hostK8sMemoryCap',
id: InfraMetric.hostK8sMemoryCap,
map_field_to: 'kubernetes.node.name',
requires: ['kubernetes.node'],
index_pattern: indexPattern,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import {
InfraMetricModelMetricType,
InfraMetricModel,
} from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';

export const hostK8sOverview: InfraMetricModelCreator = (
timeField,
indexPattern,
interval
): InfraMetricModel => ({
id: 'hostK8sOverview',
id: InfraMetric.hostK8sOverview,
requires: ['kubernetes'],
index_pattern: indexPattern,
interval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import {
InfraMetricModelMetricType,
InfraMetricModel,
} from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';

export const hostK8sPodCap: InfraMetricModelCreator = (
timeField,
indexPattern,
interval
): InfraMetricModel => ({
id: 'hostK8sPodCap',
id: InfraMetric.hostK8sPodCap,
requires: ['kubernetes.node'],
map_field_to: 'kubernetes.node.name',
index_pattern: indexPattern,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import {
InfraMetricModelMetricType,
InfraMetricModel,
} from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';

export const hostLoad: InfraMetricModelCreator = (
timeField,
indexPattern,
interval
): InfraMetricModel => ({
id: 'hostLoad',
id: InfraMetric.hostLoad,
requires: ['system.cpu'],
index_pattern: indexPattern,
interval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import {
InfraMetricModelMetricType,
InfraMetricModel,
} from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';

export const hostMemoryUsage: InfraMetricModelCreator = (
timeField,
indexPattern,
interval
): InfraMetricModel => ({
id: 'hostMemoryUsage',
id: InfraMetric.hostMemoryUsage,
requires: ['system.memory'],
index_pattern: indexPattern,
interval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import {
InfraMetricModelMetricType,
InfraMetricModel,
} from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';

export const hostNetworkTraffic: InfraMetricModelCreator = (
timeField,
indexPattern,
interval
): InfraMetricModel => ({
id: 'hostNetworkTraffic',
id: InfraMetric.hostNetworkTraffic,
requires: ['system.network'],
index_pattern: indexPattern,
interval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import {
InfraMetricModelMetricType,
InfraMetricModel,
} from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';

export const hostSystemOverview: InfraMetricModelCreator = (
timeField,
indexPattern,
interval
): InfraMetricModel => ({
id: 'hostSystemOverview',
id: InfraMetric.hostSystemOverview,
requires: ['system.cpu', 'system.memory', 'system.load', 'system.network'],
index_pattern: indexPattern,
interval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import {
InfraMetricModelMetricType,
InfraMetricModel,
} from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';

export const nginxActiveConnections: InfraMetricModelCreator = (
timeField,
indexPattern,
interval
): InfraMetricModel => ({
id: 'nginxActiveConnections',
id: InfraMetric.nginxActiveConnections,
requires: ['nginx.stubstatus'],
index_pattern: indexPattern,
interval,
Expand Down
Loading

0 comments on commit 3788410

Please sign in to comment.