diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.test.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.test.ts index e07880b8da161..9ccc19c11516d 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.test.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/lens_attributes.test.ts @@ -43,13 +43,23 @@ describe('Lens Attribute', () => { }); it('should return main y axis', function () { - expect(lnsAttr.getMainYAxis(layerConfig)).toEqual({ + expect(lnsAttr.getMainYAxis(layerConfig, 'layer0', '')).toEqual({ dataType: 'number', isBucketed: false, label: 'Pages loaded', - operationType: 'count', + operationType: 'formula', + params: { + format: { + id: 'percent', + params: { + decimals: 0, + }, + }, + formula: 'count() / overall_sum(count())', + isFormulaBroken: false, + }, + references: ['y-axis-column-layer0X4'], scale: 'ratio', - sourceField: 'Records', }); }); @@ -203,7 +213,15 @@ describe('Lens Attribute', () => { it('should return first layer', function () { expect(lnsAttr.getLayers()).toEqual({ layer0: { - columnOrder: ['x-axis-column-layer0', 'y-axis-column-layer0'], + columnOrder: [ + 'x-axis-column-layer0', + 'y-axis-column-layer0', + 'y-axis-column-layer0X0', + 'y-axis-column-layer0X1', + 'y-axis-column-layer0X2', + 'y-axis-column-layer0X3', + 'y-axis-column-layer0X4', + ], columns: { 'x-axis-column-layer0': { dataType: 'number', @@ -226,16 +244,98 @@ describe('Lens Attribute', () => { }, 'y-axis-column-layer0': { dataType: 'number', + filter: { + language: 'kuery', + query: + 'transaction.type: page-load and processor.event: transaction and transaction.type : *', + }, isBucketed: false, label: 'Pages loaded', + operationType: 'formula', + params: { + format: { + id: 'percent', + params: { + decimals: 0, + }, + }, + formula: + "count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *') / overall_sum(count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *'))", + isFormulaBroken: false, + }, + references: ['y-axis-column-layer0X4'], + scale: 'ratio', + }, + 'y-axis-column-layer0X0': { + customLabel: true, + dataType: 'number', + filter: { + language: 'kuery', + query: + 'transaction.type: page-load and processor.event: transaction and transaction.type : *', + }, + isBucketed: false, + label: 'Part of count() / overall_sum(count())', operationType: 'count', scale: 'ratio', sourceField: 'Records', + }, + 'y-axis-column-layer0X1': { + customLabel: true, + dataType: 'number', filter: { language: 'kuery', query: 'transaction.type: page-load and processor.event: transaction and transaction.type : *', }, + isBucketed: false, + label: 'Part of count() / overall_sum(count())', + operationType: 'count', + scale: 'ratio', + sourceField: 'Records', + }, + 'y-axis-column-layer0X2': { + customLabel: true, + dataType: 'number', + isBucketed: false, + label: 'Part of count() / overall_sum(count())', + operationType: 'math', + params: { + tinymathAst: 'y-axis-column-layer0X1', + }, + references: ['y-axis-column-layer0X1'], + scale: 'ratio', + }, + 'y-axis-column-layer0X3': { + customLabel: true, + dataType: 'number', + isBucketed: false, + label: 'Part of count() / overall_sum(count())', + operationType: 'overall_sum', + references: ['y-axis-column-layer0X2'], + scale: 'ratio', + }, + 'y-axis-column-layer0X4': { + customLabel: true, + dataType: 'number', + isBucketed: false, + label: 'Part of count() / overall_sum(count())', + operationType: 'math', + params: { + tinymathAst: { + args: ['y-axis-column-layer0X0', 'y-axis-column-layer0X3'], + location: { + max: 30, + min: 0, + }, + name: 'divide', + text: + "count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *') / overall_sum(count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *'))", + type: 'function', + }, + }, + references: ['y-axis-column-layer0X0', 'y-axis-column-layer0X3'], + scale: 'ratio', }, }, incompleteColumns: {}, @@ -299,7 +399,16 @@ describe('Lens Attribute', () => { ]); expect(lnsAttr.layers.layer0).toEqual({ - columnOrder: ['x-axis-column-layer0', 'breakdown-column-layer0', 'y-axis-column-layer0'], + columnOrder: [ + 'x-axis-column-layer0', + 'breakdown-column-layer0', + 'y-axis-column-layer0', + 'y-axis-column-layer0X0', + 'y-axis-column-layer0X1', + 'y-axis-column-layer0X2', + 'y-axis-column-layer0X3', + 'y-axis-column-layer0X4', + ], columns: { 'breakdown-column-layer0': { dataType: 'string', @@ -326,7 +435,13 @@ describe('Lens Attribute', () => { operationType: 'range', params: { maxBars: 'auto', - ranges: [{ from: 0, label: '', to: 1000 }], + ranges: [ + { + from: 0, + label: '', + to: 1000, + }, + ], type: 'histogram', }, scale: 'interval', @@ -334,16 +449,98 @@ describe('Lens Attribute', () => { }, 'y-axis-column-layer0': { dataType: 'number', + filter: { + language: 'kuery', + query: + 'transaction.type: page-load and processor.event: transaction and transaction.type : *', + }, isBucketed: false, label: 'Pages loaded', + operationType: 'formula', + params: { + format: { + id: 'percent', + params: { + decimals: 0, + }, + }, + formula: + "count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *') / overall_sum(count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *'))", + isFormulaBroken: false, + }, + references: ['y-axis-column-layer0X4'], + scale: 'ratio', + }, + 'y-axis-column-layer0X0': { + customLabel: true, + dataType: 'number', + filter: { + language: 'kuery', + query: + 'transaction.type: page-load and processor.event: transaction and transaction.type : *', + }, + isBucketed: false, + label: 'Part of count() / overall_sum(count())', operationType: 'count', scale: 'ratio', sourceField: 'Records', + }, + 'y-axis-column-layer0X1': { + customLabel: true, + dataType: 'number', filter: { language: 'kuery', query: 'transaction.type: page-load and processor.event: transaction and transaction.type : *', }, + isBucketed: false, + label: 'Part of count() / overall_sum(count())', + operationType: 'count', + scale: 'ratio', + sourceField: 'Records', + }, + 'y-axis-column-layer0X2': { + customLabel: true, + dataType: 'number', + isBucketed: false, + label: 'Part of count() / overall_sum(count())', + operationType: 'math', + params: { + tinymathAst: 'y-axis-column-layer0X1', + }, + references: ['y-axis-column-layer0X1'], + scale: 'ratio', + }, + 'y-axis-column-layer0X3': { + customLabel: true, + dataType: 'number', + isBucketed: false, + label: 'Part of count() / overall_sum(count())', + operationType: 'overall_sum', + references: ['y-axis-column-layer0X2'], + scale: 'ratio', + }, + 'y-axis-column-layer0X4': { + customLabel: true, + dataType: 'number', + isBucketed: false, + label: 'Part of count() / overall_sum(count())', + operationType: 'math', + params: { + tinymathAst: { + args: ['y-axis-column-layer0X0', 'y-axis-column-layer0X3'], + location: { + max: 30, + min: 0, + }, + name: 'divide', + text: + "count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *') / overall_sum(count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *'))", + type: 'function', + }, + }, + references: ['y-axis-column-layer0X0', 'y-axis-column-layer0X3'], + scale: 'ratio', }, }, incompleteColumns: {}, diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/synthetics/data_distribution_config.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/synthetics/data_distribution_config.ts index 149bb7e7aa574..982d29df694d8 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/synthetics/data_distribution_config.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/synthetics/data_distribution_config.ts @@ -6,7 +6,7 @@ */ import { ConfigProps, SeriesConfig } from '../../types'; -import { FieldLabels, RECORDS_FIELD } from '../constants'; +import { FieldLabels, RECORDS_PERCENTAGE_FIELD } from '../constants'; import { buildExistsFilter } from '../utils'; import { MONITORS_DURATION_LABEL, PINGS_LABEL } from '../constants/labels'; @@ -23,7 +23,7 @@ export function getSyntheticsDistributionConfig({ }, yAxisColumns: [ { - sourceField: RECORDS_FIELD, + sourceField: RECORDS_PERCENTAGE_FIELD, label: PINGS_LABEL, }, ], diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute.ts b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute.ts index edf2a42415820..569d68ad4ebff 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute.ts +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/configurations/test_data/sample_attribute.ts @@ -17,7 +17,15 @@ export const sampleAttribute = { indexpattern: { layers: { layer0: { - columnOrder: ['x-axis-column-layer0', 'y-axis-column-layer0'], + columnOrder: [ + 'x-axis-column-layer0', + 'y-axis-column-layer0', + 'y-axis-column-layer0X0', + 'y-axis-column-layer0X1', + 'y-axis-column-layer0X2', + 'y-axis-column-layer0X3', + 'y-axis-column-layer0X4', + ], columns: { 'x-axis-column-layer0': { sourceField: 'transaction.duration.us', @@ -34,8 +42,47 @@ export const sampleAttribute = { }, 'y-axis-column-layer0': { dataType: 'number', + filter: { + language: 'kuery', + query: + 'transaction.type: page-load and processor.event: transaction and transaction.type : *', + }, isBucketed: false, label: 'Pages loaded', + operationType: 'formula', + params: { + format: { + id: 'percent', + params: { + decimals: 0, + }, + }, + formula: + "count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *') / overall_sum(count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *'))", + isFormulaBroken: false, + }, + references: ['y-axis-column-layer0X4'], + scale: 'ratio', + }, + 'y-axis-column-layer0X0': { + customLabel: true, + dataType: 'number', + filter: { + language: 'kuery', + query: + 'transaction.type: page-load and processor.event: transaction and transaction.type : *', + }, + isBucketed: false, + label: 'Part of count() / overall_sum(count())', + operationType: 'count', + scale: 'ratio', + sourceField: 'Records', + }, + 'y-axis-column-layer0X1': { + customLabel: true, + dataType: 'number', + isBucketed: false, + label: 'Part of count() / overall_sum(count())', operationType: 'count', scale: 'ratio', sourceField: 'Records', @@ -45,6 +92,49 @@ export const sampleAttribute = { 'transaction.type: page-load and processor.event: transaction and transaction.type : *', }, }, + 'y-axis-column-layer0X2': { + customLabel: true, + dataType: 'number', + isBucketed: false, + label: 'Part of count() / overall_sum(count())', + operationType: 'math', + params: { + tinymathAst: 'y-axis-column-layer0X1', + }, + references: ['y-axis-column-layer0X1'], + scale: 'ratio', + }, + 'y-axis-column-layer0X3': { + customLabel: true, + dataType: 'number', + isBucketed: false, + label: 'Part of count() / overall_sum(count())', + operationType: 'overall_sum', + references: ['y-axis-column-layer0X2'], + scale: 'ratio', + }, + 'y-axis-column-layer0X4': { + customLabel: true, + dataType: 'number', + isBucketed: false, + label: 'Part of count() / overall_sum(count())', + operationType: 'math', + params: { + tinymathAst: { + args: ['y-axis-column-layer0X0', 'y-axis-column-layer0X3'], + location: { + max: 30, + min: 0, + }, + name: 'divide', + text: + "count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *') / overall_sum(count(kql='transaction.type: page-load and processor.event: transaction and transaction.type : *'))", + type: 'function', + }, + }, + references: ['y-axis-column-layer0X0', 'y-axis-column-layer0X3'], + scale: 'ratio', + }, }, incompleteColumns: {}, }, @@ -70,7 +160,7 @@ export const sampleAttribute = { }, ], }, - query: { query: '', language: 'kuery' }, + query: { query: 'transaction.duration.us < 60000000', language: 'kuery' }, filters: [], }, };