diff --git a/x-pack/legacy/plugins/infra/common/graphql/types.ts b/x-pack/legacy/plugins/infra/common/graphql/types.ts index 5f085f67e73fa..c93d51e1efc83 100644 --- a/x-pack/legacy/plugins/infra/common/graphql/types.ts +++ b/x-pack/legacy/plugins/infra/common/graphql/types.ts @@ -560,6 +560,7 @@ export enum InfraMetric { nginxRequestRate = 'nginxRequestRate', nginxActiveConnections = 'nginxActiveConnections', nginxRequestsPerConnection = 'nginxRequestsPerConnection', + custom = 'custom', } // ==================================================== diff --git a/x-pack/legacy/plugins/infra/public/graphql/introspection.json b/x-pack/legacy/plugins/infra/public/graphql/introspection.json index 02557715a9b66..d919353f1cbe3 100644 --- a/x-pack/legacy/plugins/infra/public/graphql/introspection.json +++ b/x-pack/legacy/plugins/infra/public/graphql/introspection.json @@ -2383,7 +2383,8 @@ "description": "", "isDeprecated": false, "deprecationReason": null - } + }, + { "name": "custom", "description": "", "isDeprecated": false, "deprecationReason": null } ], "possibleTypes": null }, diff --git a/x-pack/legacy/plugins/infra/public/graphql/types.ts b/x-pack/legacy/plugins/infra/public/graphql/types.ts index 5f085f67e73fa..c93d51e1efc83 100644 --- a/x-pack/legacy/plugins/infra/public/graphql/types.ts +++ b/x-pack/legacy/plugins/infra/public/graphql/types.ts @@ -560,6 +560,7 @@ export enum InfraMetric { nginxRequestRate = 'nginxRequestRate', nginxActiveConnections = 'nginxActiveConnections', nginxRequestsPerConnection = 'nginxRequestsPerConnection', + custom = 'custom', } // ==================================================== diff --git a/x-pack/legacy/plugins/infra/server/graphql/metrics/schema.gql.ts b/x-pack/legacy/plugins/infra/server/graphql/metrics/schema.gql.ts index 3218bffe95945..00422f5dd0774 100644 --- a/x-pack/legacy/plugins/infra/server/graphql/metrics/schema.gql.ts +++ b/x-pack/legacy/plugins/infra/server/graphql/metrics/schema.gql.ts @@ -35,6 +35,7 @@ export const metricsSchema: any = gql` nginxRequestRate nginxActiveConnections nginxRequestsPerConnection + custom } type InfraMetricData { diff --git a/x-pack/legacy/plugins/infra/server/graphql/types.ts b/x-pack/legacy/plugins/infra/server/graphql/types.ts index d161dfac59f31..b09d93f4338fa 100644 --- a/x-pack/legacy/plugins/infra/server/graphql/types.ts +++ b/x-pack/legacy/plugins/infra/server/graphql/types.ts @@ -588,6 +588,7 @@ export enum InfraMetric { nginxRequestRate = 'nginxRequestRate', nginxActiveConnections = 'nginxActiveConnections', nginxRequestsPerConnection = 'nginxRequestsPerConnection', + custom = 'custom', } // ==================================================== diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/adapter_types.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/adapter_types.ts index d5b58a3fb59f3..49d72e1b4794b 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/adapter_types.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/adapter_types.ts @@ -29,6 +29,11 @@ export interface InfraMetricsAdapter { ): Promise; } +export enum InfraMetricModelQueryType { + lucene = 'lucene', + kuery = 'kuery', +} + export enum InfraMetricModelMetricType { avg = 'avg', max = 'max', @@ -42,7 +47,7 @@ export enum InfraMetricModelMetricType { } export interface InfraMetricModel { - id: string; + id: InfraMetric; requires: string[]; index_pattern: string | string[]; interval: string; @@ -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 { diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts index b91c2912188ce..79a6f368aed09 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts @@ -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) diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_cpu_kernel.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_cpu_kernel.ts index 3fd1144b6770b..1aff438aaf07a 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_cpu_kernel.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_cpu_kernel.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_cpu_usage.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_cpu_usage.ts index bdb52b8a9d7b5..81290cec4805f 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_cpu_usage.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_cpu_usage.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_disk_io_bytes.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_disk_io_bytes.ts index 348407ee0c9f8..9e028b918ec9e 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_disk_io_bytes.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_disk_io_bytes.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_diskio_ops.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_diskio_ops.ts index 84cec24e539b5..561cdf519353e 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_diskio_ops.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_diskio_ops.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_memory.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_memory.ts index 9844fde182fe7..dc984f5475328 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_memory.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_memory.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_network_traffic.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_network_traffic.ts index 9c1ea8920f218..a993d85cb4165 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_network_traffic.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_network_traffic.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_overview.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_overview.ts index 24d1a93540104..5e33f23a6983d 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_overview.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/container/container_overview.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_cpu_usage.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_cpu_usage.ts index 0736149236c2a..4988ee6b1ba0b 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_cpu_usage.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_cpu_usage.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_filesystem.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_filesystem.ts index 6673d9293c860..7377c830b21b1 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_filesystem.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_filesystem.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_cpu_cap.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_cpu_cap.ts index 21ef42a7dfc5c..d671148a9c210 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_cpu_cap.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_cpu_cap.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_disk_cap.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_disk_cap.ts index f501485945a22..5c64809192dd7 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_disk_cap.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_disk_cap.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_memory_cap.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_memory_cap.ts index 0381f86c7a49c..9977a97db043c 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_memory_cap.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_memory_cap.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_overview.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_overview.ts index e6739b02ec4a4..9930c3f046066 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_overview.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_overview.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_pod_cap.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_pod_cap.ts index 95817a9a61b76..3efd57a77e97d 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_pod_cap.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_k8s_pod_cap.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_load.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_load.ts index 4b397ca750772..587998e73b93d 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_load.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_load.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_memory_usage.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_memory_usage.ts index 8ac9a73a0e9e6..cf1d64f51ffb3 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_memory_usage.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_memory_usage.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_network_traffic.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_network_traffic.ts index 3095338ee5343..15edff3f11011 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_network_traffic.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_network_traffic.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_system_overview.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_system_overview.ts index bf4080f625d16..1caa78fb5da88 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_system_overview.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/host/host_system_overview.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/nginx/nginx_active_connections.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/nginx/nginx_active_connections.ts index 87c810c25d090..9d8b30c8bf967 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/nginx/nginx_active_connections.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/nginx/nginx_active_connections.ts @@ -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, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/nginx/nginx_hits.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/nginx/nginx_hits.ts index 7d09c1e8e367f..bc7340bd8ac23 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/nginx/nginx_hits.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/nginx/nginx_hits.ts @@ -8,14 +8,17 @@ import { InfraMetricModelCreator, InfraMetricModelMetricType, InfraMetricModel, + InfraMetricModelQueryType, } from '../../adapter_types'; +import { InfraMetric } from '../../../../../graphql/types'; + export const nginxHits: InfraMetricModelCreator = ( timeField, indexPattern, interval ): InfraMetricModel => ({ - id: 'nginxHits', + id: InfraMetric.nginxHits, requires: ['nginx.access'], index_pattern: indexPattern, interval, @@ -31,7 +34,10 @@ export const nginxHits: InfraMetricModelCreator = ( }, ], split_mode: 'filter', - filter: 'http.response.status_code:[200 TO 299]', + filter: { + query: 'http.response.status_code:[200 TO 299]', + language: InfraMetricModelQueryType.lucene, + }, }, { id: '300s', @@ -42,7 +48,10 @@ export const nginxHits: InfraMetricModelCreator = ( }, ], split_mode: 'filter', - filter: 'http.response.status_code:[300 TO 399]', + filter: { + query: 'http.response.status_code:[300 TO 399]', + language: InfraMetricModelQueryType.lucene, + }, }, { id: '400s', @@ -53,7 +62,10 @@ export const nginxHits: InfraMetricModelCreator = ( }, ], split_mode: 'filter', - filter: 'http.response.status_code:[400 TO 499]', + filter: { + query: 'http.response.status_code:[400 TO 499]', + language: InfraMetricModelQueryType.lucene, + }, }, { id: '500s', @@ -64,7 +76,10 @@ export const nginxHits: InfraMetricModelCreator = ( }, ], split_mode: 'filter', - filter: 'http.response.status_code:[500 TO 599]', + filter: { + query: 'http.response.status_code:[500 TO 599]', + language: InfraMetricModelQueryType.lucene, + }, }, ], }); diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/nginx/nginx_request_rate.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/nginx/nginx_request_rate.ts index a3cdd23f430e8..b3d6118e057af 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/nginx/nginx_request_rate.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/nginx/nginx_request_rate.ts @@ -9,13 +9,14 @@ import { InfraMetricModelMetricType, InfraMetricModel, } from '../../adapter_types'; +import { InfraMetric } from '../../../../../graphql/types'; export const nginxRequestRate: InfraMetricModelCreator = ( timeField, indexPattern, interval ): InfraMetricModel => ({ - id: 'nginxRequestRate', + id: InfraMetric.nginxRequestRate, requires: ['nginx.stubstatus'], index_pattern: indexPattern, interval, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/nginx/nginx_requests_per_connection.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/nginx/nginx_requests_per_connection.ts index 97b766cec3171..65114cdda0606 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/nginx/nginx_requests_per_connection.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/nginx/nginx_requests_per_connection.ts @@ -9,13 +9,14 @@ import { InfraMetricModelMetricType, InfraMetricModel, } from '../../adapter_types'; +import { InfraMetric } from '../../../../../graphql/types'; export const nginxRequestsPerConnection: InfraMetricModelCreator = ( timeField, indexPattern, interval ): InfraMetricModel => ({ - id: 'nginxRequestsPerConnection', + id: InfraMetric.nginxRequestsPerConnection, requires: ['nginx.stubstatus'], index_pattern: indexPattern, interval, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_cpu_usage.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_cpu_usage.ts index 4e186dc9e4cdc..d4c0fce42b51c 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_cpu_usage.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_cpu_usage.ts @@ -9,13 +9,14 @@ import { InfraMetricModelMetricType, InfraMetricModel, } from '../../adapter_types'; +import { InfraMetric } from '../../../../../graphql/types'; export const podCpuUsage: InfraMetricModelCreator = ( timeField, indexPattern, interval ): InfraMetricModel => ({ - id: 'podCpuUsage', + id: InfraMetric.podCpuUsage, requires: ['kubernetes.pod'], index_pattern: indexPattern, interval, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_log_usage.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_log_usage.ts index a424b417688de..b1f184672fa73 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_log_usage.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_log_usage.ts @@ -9,13 +9,14 @@ import { InfraMetricModelMetricType, InfraMetricModel, } from '../../adapter_types'; +import { InfraMetric } from '../../../../../graphql/types'; export const podLogUsage: InfraMetricModelCreator = ( timeField, indexPattern, interval ): InfraMetricModel => ({ - id: 'podLogUsage', + id: InfraMetric.podLogUsage, requires: ['kubernetes.pod'], index_pattern: indexPattern, interval, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_memory_usage.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_memory_usage.ts index eea2062ad52f1..720e11b2b6068 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_memory_usage.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_memory_usage.ts @@ -9,13 +9,14 @@ import { InfraMetricModelMetricType, InfraMetricModel, } from '../../adapter_types'; +import { InfraMetric } from '../../../../../graphql/types'; export const podMemoryUsage: InfraMetricModelCreator = ( timeField, indexPattern, interval ): InfraMetricModel => ({ - id: 'podMemoryUsage', + id: InfraMetric.podMemoryUsage, requires: ['kubernetes.pod'], index_pattern: indexPattern, interval, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_network_traffic.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_network_traffic.ts index ff462d57ddd4e..9547fe75e6bbc 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_network_traffic.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_network_traffic.ts @@ -9,13 +9,14 @@ import { InfraMetricModelMetricType, InfraMetricModel, } from '../../adapter_types'; +import { InfraMetric } from '../../../../../graphql/types'; export const podNetworkTraffic: InfraMetricModelCreator = ( timeField, indexPattern, interval ): InfraMetricModel => ({ - id: 'podNetworkTraffic', + id: InfraMetric.podNetworkTraffic, requires: ['kubernetes.pod'], index_pattern: indexPattern, interval, diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_overview.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_overview.ts index f475e18fcec17..bcdfa350f6aeb 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_overview.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/pod/pod_overview.ts @@ -9,13 +9,14 @@ import { InfraMetricModelMetricType, InfraMetricModel, } from '../../adapter_types'; +import { InfraMetric } from '../../../../../graphql/types'; export const podOverview: InfraMetricModelCreator = ( timeField, indexPattern, interval ): InfraMetricModel => ({ - id: 'podOverview', + id: InfraMetric.podOverview, requires: ['kubernetes.pod'], index_pattern: indexPattern, interval, diff --git a/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/create_metrics_model.ts b/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/create_metrics_model.ts index b5159479aec08..dd8e0edad7672 100644 --- a/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/create_metrics_model.ts +++ b/x-pack/legacy/plugins/infra/server/routes/metrics_explorer/lib/create_metrics_model.ts @@ -6,9 +6,10 @@ import { InfraMetricModel, InfraMetricModelMetricType } from '../../../lib/adapters/metrics'; import { MetricsExplorerAggregation, MetricsExplorerRequest } from '../types'; +import { InfraMetric } from '../../../graphql/types'; export const createMetricModel = (options: MetricsExplorerRequest): InfraMetricModel => { return { - id: 'custom', + id: InfraMetric.custom, requires: [], index_pattern: options.indexPattern, interval: options.timerange.interval,