From b1005cd84de11cffaa16e02486294ea1ed68c017 Mon Sep 17 00:00:00 2001 From: Alexander Wert Date: Thu, 17 Jun 2021 11:23:07 +0200 Subject: [PATCH 1/2] Added mobile device distribution config + fixed mobile field names --- .../configurations/constants/constants.ts | 17 +------ .../configurations/constants/labels.ts | 9 +++- .../configurations/default_configs.ts | 5 ++ .../configurations/lens_attributes.ts | 44 ++++++++++++++-- .../mobile/device_distribution_config.ts | 51 +++++++++++++++++++ .../mobile/distribution_config.ts | 22 ++------ .../mobile/kpi_over_time_config.ts | 25 +++------ .../configurations/mobile/mobile_fields.ts | 19 +++++++ .../series_builder/series_builder.tsx | 1 + .../shared/exploratory_view/types.ts | 3 +- 10 files changed, 137 insertions(+), 59 deletions(-) create mode 100644 x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/device_distribution_config.ts create mode 100644 x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/mobile_fields.ts diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/constants/constants.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/constants/constants.ts index 7a79cde88ae13..77a99c3d30d41 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/constants/constants.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/constants/constants.ts @@ -11,18 +11,13 @@ import { AGENT_HOST_LABEL, BROWSER_FAMILY_LABEL, BROWSER_VERSION_LABEL, - CARRIER_LOCATION, - CARRIER_NAME, CLS_LABEL, - CONNECTION_TYPE, CORE_WEB_VITALS_LABEL, DEVICE_LABEL, - DEVICE_MODEL, ENVIRONMENT_LABEL, FCP_LABEL, FID_LABEL, HOST_NAME_LABEL, - HOST_OS, KIP_OVER_TIME_LABEL, KPI_LABEL, LCP_LABEL, @@ -34,12 +29,10 @@ import { MONITOR_TYPE_LABEL, OBSERVER_LOCATION_LABEL, OS_LABEL, - OS_PLATFORM, PERF_DIST_LABEL, PORT_LABEL, REQUEST_METHOD, SERVICE_NAME_LABEL, - SERVICE_VERSION, TAGS_LABEL, TBT_LABEL, URL_LABEL, @@ -80,16 +73,7 @@ export const FieldLabels: Record = { 'performance.metric': METRIC_LABEL, 'Business.KPI': KPI_LABEL, - - 'labels.net_connection_carrier_name': CARRIER_NAME, 'http.request.method': REQUEST_METHOD, - 'labels.net_connection_type': CONNECTION_TYPE, - 'host.os.full': HOST_OS, - 'service.version': SERVICE_VERSION, - 'host.os.platform': OS_PLATFORM, - 'labels.device_model': DEVICE_MODEL, - // eslint-disable-next-line @typescript-eslint/naming-convention - 'labels.net_connection_carrier_isoCountryCode': CARRIER_LOCATION, }; export const DataViewLabels: Record = { @@ -100,4 +84,5 @@ export const DataViewLabels: Record = { export const USE_BREAK_DOWN_COLUMN = 'USE_BREAK_DOWN_COLUMN'; export const FILTER_RECORDS = 'FILTER_RECORDS'; +export const TERMS_COLUMN = 'TERMS_COLUMN'; export const OPERATION_COLUMN = 'operation'; diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/constants/labels.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/constants/labels.ts index 6d397d893e48b..571fc657f7449 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/constants/labels.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/constants/labels.ts @@ -284,9 +284,16 @@ export const CPU_USAGE = i18n.translate('xpack.observability.expView.fieldLabels defaultMessage: 'CPU Usage', }); -export const TRANSACTION_PER_MINUTE = i18n.translate( +export const TRANSACTIONS_PER_MINUTE = i18n.translate( 'xpack.observability.expView.fieldLabels.transactionPerMinute', { defaultMessage: 'Transactions per minute', } ); + +export const NUMBER_OF_DEVICES = i18n.translate( + 'xpack.observability.expView.fieldLabels.numberOfDevices', + { + defaultMessage: 'Number of Devices', + } +); diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/default_configs.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/default_configs.ts index d1660c9256fa3..1162fa9dabef0 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/default_configs.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/default_configs.ts @@ -14,6 +14,8 @@ import { IndexPattern } from '../../../../../../../../src/plugins/data/common'; import { getCoreWebVitalsConfig } from './rum/core_web_vitals_config'; import { getMobileKPIConfig } from './mobile/kpi_over_time_config'; import { getMobileKPIDistributionConfig } from './mobile/distribution_config'; +import { getMobileDeviceDistributionConfig } from './mobile/device_distribution_config'; + interface Props { reportType: keyof typeof ReportViewTypes; @@ -40,6 +42,9 @@ export const getDefaultConfigs = ({ reportType, dataType, indexPattern }: Props) if (reportType === 'dist') { return getMobileKPIDistributionConfig({ indexPattern }); } + if (reportType === 'mdd') { + return getMobileDeviceDistributionConfig({ indexPattern }); + } return getMobileKPIConfig({ indexPattern }); default: return getKPITrendsLensConfig({ indexPattern }); diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.ts index 01dcdd18ba0c7..a7104d75fb401 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.ts @@ -25,13 +25,14 @@ import { FieldBasedIndexPatternColumn, SumIndexPatternColumn, TermsIndexPatternColumn, + CardinalityIndexPatternColumn, } from '../../../../../../lens/public'; import { buildPhraseFilter, buildPhrasesFilter, IndexPattern, } from '../../../../../../../../src/plugins/data/common'; -import { FieldLabels, FILTER_RECORDS, USE_BREAK_DOWN_COLUMN } from './constants'; +import { FieldLabels, FILTER_RECORDS, USE_BREAK_DOWN_COLUMN, TERMS_COLUMN } from './constants'; import { ColumnFilter, DataSeries, UrlFilter, URLReportDefinition } from '../types'; function getLayerReferenceName(layerId: string) { @@ -186,6 +187,11 @@ export class LensAttributes { }; } + getCardinalityColumn(sourceField: string, + label?: string) { + return this.getNumberOperationColumn(sourceField, 'unique_count', label); + } + getNumberColumn( sourceField: string, columnType?: string, @@ -193,7 +199,7 @@ export class LensAttributes { label?: string ) { if (columnType === 'operation' || operationType) { - if (operationType === 'median' || operationType === 'average' || operationType === 'sum') { + if (operationType === 'median' || operationType === 'average' || operationType === 'sum' || operationType === 'unique_count') { return this.getNumberOperationColumn(sourceField, operationType, label); } if (operationType?.includes('th')) { @@ -205,9 +211,9 @@ export class LensAttributes { getNumberOperationColumn( sourceField: string, - operationType: 'average' | 'median' | 'sum', + operationType: 'average' | 'median' | 'sum' | 'unique_count', label?: string - ): AvgIndexPatternColumn | MedianIndexPatternColumn | SumIndexPatternColumn { + ): AvgIndexPatternColumn | MedianIndexPatternColumn | SumIndexPatternColumn | CardinalityIndexPatternColumn { return { ...buildNumberColumn(sourceField), label: @@ -237,7 +243,7 @@ export class LensAttributes { params: { percentile: Number(percentileValue.split('th')[0]) }, }; } - + getDateHistogramColumn(sourceField: string): DateHistogramIndexPatternColumn { return { sourceField, @@ -250,6 +256,25 @@ export class LensAttributes { }; } + getTermsColumn(sourceField: string, label?: string) : TermsIndexPatternColumn{ + return { + operationType: 'terms', + sourceField: sourceField, + label: label || 'Top values of ' + sourceField, + dataType: 'string', + isBucketed: true, + scale: 'ordinal', + params: { + size: 10, + orderBy: { + type: 'alphabetical', + fallback: false + }, + orderDirection: 'desc', + } + }; + } + getXAxis() { const { xAxisColumn } = this.reportViewConfig; @@ -276,6 +301,12 @@ export class LensAttributes { } = this.getFieldMeta(sourceField); const { type: fieldType } = fieldMeta ?? {}; + if(columnType === TERMS_COLUMN){ + return this.getTermsColumn( + fieldName, columnLabel || label + ); + } + if (fieldName === 'Records' || columnType === FILTER_RECORDS) { return this.getRecordsColumn( columnLabel || label, @@ -290,6 +321,9 @@ export class LensAttributes { if (fieldType === 'number') { return this.getNumberColumn(fieldName, columnType, operationType, columnLabel || label); } + if (operationType === 'unique_count') { + return this.getCardinalityColumn(fieldName, columnLabel || label); + } // FIXME review my approach again return this.getDateHistogramColumn(fieldName); diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/device_distribution_config.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/device_distribution_config.ts new file mode 100644 index 0000000000000..92ae10cfb041f --- /dev/null +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/device_distribution_config.ts @@ -0,0 +1,51 @@ +/* + * 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 { ConfigProps, DataSeries } from '../../types'; +import { FieldLabels, USE_BREAK_DOWN_COLUMN } from '../constants'; +import { buildPhraseFilter } from '../utils'; +import { + SERVICE_NAME, +} from '../constants/elasticsearch_fieldnames'; +import { MOBILE_APP, NUMBER_OF_DEVICES } from '../constants/labels'; +import { MobileFields } from './mobile_fields'; + +export function getMobileDeviceDistributionConfig({ indexPattern }: ConfigProps): DataSeries { + return { + reportType: 'mobile-device-distribution', + defaultSeriesType: 'bar', + seriesTypes: ['bar', 'bar_horizontal' ], + xAxisColumn: { + sourceField: USE_BREAK_DOWN_COLUMN, + }, + yAxisColumns: [ + { + sourceField: 'labels.device_id', + operationType: 'unique_count', + label: NUMBER_OF_DEVICES, + }, + ], + hasOperationType: false, + defaultFilters: Object.keys(MobileFields), + breakdowns: Object.keys(MobileFields), + filters: [ + ...buildPhraseFilter('agent.name', 'iOS/swift', indexPattern), + ...buildPhraseFilter('processor.event', 'transaction', indexPattern), + ], + labels: { + ...FieldLabels, + ...MobileFields, + [SERVICE_NAME]: MOBILE_APP, + }, + reportDefinitions: [ + { + field: SERVICE_NAME, + required: true, + }, + ], + }; +} diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/distribution_config.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/distribution_config.ts index b11561b18a754..8ceace2d56970 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/distribution_config.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/distribution_config.ts @@ -15,7 +15,9 @@ import { SERVICE_NAME, TRANSACTION_DURATION, } from '../constants/elasticsearch_fieldnames'; + import { CPU_USAGE, MEMORY_USAGE, MOBILE_APP, RESPONSE_LATENCY } from '../constants/labels'; +import { MobileFields } from './mobile_fields'; export function getMobileKPIDistributionConfig({ indexPattern }: ConfigProps): DataSeries { return { @@ -32,28 +34,14 @@ export function getMobileKPIDistributionConfig({ indexPattern }: ConfigProps): D }, ], hasOperationType: false, - defaultFilters: [ - 'labels.net_connection_carrier_name', - 'labels.device_model', - 'labels.net_connection_type', - 'host.os.platform', - 'host.os.full', - 'service.version', - ], - breakdowns: [ - 'labels.net_connection_carrier_name', - 'labels.device_model', - 'labels.net_connection_type', - 'host.os.platform', - 'host.os.full', - 'service.version', - 'labels.net_connection_carrier_isoCountryCode', - ], + defaultFilters: Object.keys(MobileFields), + breakdowns: Object.keys(MobileFields), filters: [ ...buildPhrasesFilter('agent.name', ['iOS/swift', 'open-telemetry/swift'], indexPattern), ], labels: { ...FieldLabels, + ...MobileFields, [SERVICE_NAME]: MOBILE_APP, }, reportDefinitions: [ diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/kpi_over_time_config.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/kpi_over_time_config.ts index 6274d2ad79e43..1c87daa8d2ce9 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/kpi_over_time_config.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/kpi_over_time_config.ts @@ -20,8 +20,9 @@ import { MEMORY_USAGE, MOBILE_APP, RESPONSE_LATENCY, - TRANSACTION_PER_MINUTE, + TRANSACTIONS_PER_MINUTE, } from '../constants/labels'; +import { MobileFields } from './mobile_fields'; export function getMobileKPIConfig({ indexPattern }: ConfigProps): DataSeries { return { @@ -38,28 +39,14 @@ export function getMobileKPIConfig({ indexPattern }: ConfigProps): DataSeries { }, ], hasOperationType: true, - defaultFilters: [ - 'labels.net_connection_carrier_name', - 'labels.device_model', - 'labels.net_connection_type', - 'host.os.platform', - 'host.os.full', - 'service.version', - ], - breakdowns: [ - 'labels.net_connection_carrier_name', - 'labels.device_model', - 'labels.net_connection_type', - 'host.os.platform', - 'host.os.full', - 'service.version', - 'labels.net_connection_carrier_isoCountryCode', - ], + defaultFilters: Object.keys(MobileFields), + breakdowns: Object.keys(MobileFields), filters: [ ...buildPhrasesFilter('agent.name', ['iOS/swift', 'open-telemetry/swift'], indexPattern), ], labels: { ...FieldLabels, + ...MobileFields, [TRANSACTION_DURATION]: RESPONSE_LATENCY, [SERVICE_NAME]: MOBILE_APP, [METRIC_SYSTEM_MEMORY_USAGE]: MEMORY_USAGE, @@ -99,7 +86,7 @@ export function getMobileKPIConfig({ indexPattern }: ConfigProps): DataSeries { { field: RECORDS_FIELD, id: RECORDS_FIELD, - label: TRANSACTION_PER_MINUTE, + label: TRANSACTIONS_PER_MINUTE, columnFilters: [ { language: 'kuery', diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/mobile_fields.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/mobile_fields.ts new file mode 100644 index 0000000000000..2fcac0ac1d5ce --- /dev/null +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/mobile_fields.ts @@ -0,0 +1,19 @@ +import { + CARRIER_LOCATION, + CARRIER_NAME, + CONNECTION_TYPE, + DEVICE_MODEL, + HOST_OS, + OS_PLATFORM, + SERVICE_VERSION, + } from '../constants/labels'; + +export const MobileFields : Record = { + 'host.os.platform': OS_PLATFORM, + 'host.os.full': HOST_OS, + 'service.version': SERVICE_VERSION, + 'network.carrier.icc': CARRIER_LOCATION, + 'network.carrier.name': CARRIER_NAME, + 'network.connection_type': CONNECTION_TYPE, + 'labels.device_model': DEVICE_MODEL, +}; \ No newline at end of file diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/series_builder/series_builder.tsx b/x-pack/plugins/observability/public/components/shared/exploratory_view/series_builder/series_builder.tsx index 648809908e2e3..cb7aad65cb630 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/series_builder/series_builder.tsx +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/series_builder/series_builder.tsx @@ -32,6 +32,7 @@ export const ReportTypes: Record = T[keyof T]; @@ -45,7 +46,7 @@ export interface ReportDefinition { field?: string; label: string; description?: string; - columnType?: 'range' | 'operation' | 'FILTER_RECORDS'; + columnType?: 'range' | 'operation' | 'FILTER_RECORDS' | 'TERMS_COLUMN'; columnFilters?: ColumnFilter[]; timeScale?: string; }>; From c949862358617efb8b72a71b34da3d49b3a4dd06 Mon Sep 17 00:00:00 2001 From: Alexander Wert Date: Thu, 17 Jun 2021 11:37:14 +0200 Subject: [PATCH 2/2] fixing chart type options and label for distribution --- .../configurations/mobile/distribution_config.ts | 1 - .../configurations/mobile/kpi_over_time_config.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/distribution_config.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/distribution_config.ts index 8ceace2d56970..62dd38e55a32a 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/distribution_config.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/distribution_config.ts @@ -30,7 +30,6 @@ export function getMobileKPIDistributionConfig({ indexPattern }: ConfigProps): D yAxisColumns: [ { sourceField: RECORDS_FIELD, - label: 'Transactions', }, ], hasOperationType: false, diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/kpi_over_time_config.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/kpi_over_time_config.ts index 1c87daa8d2ce9..2ed4d95760db7 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/kpi_over_time_config.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/mobile/kpi_over_time_config.ts @@ -28,7 +28,7 @@ export function getMobileKPIConfig({ indexPattern }: ConfigProps): DataSeries { return { reportType: 'kpi-over-time', defaultSeriesType: 'line', - seriesTypes: ['line', 'bar'], + seriesTypes: ['line', 'bar', 'area'], xAxisColumn: { sourceField: '@timestamp', },