Skip to content

Commit

Permalink
[Exploratory View]Additional metrics for kpi over time (elastic#96532)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 authored Apr 12, 2021
1 parent c401211 commit a2c47ef
Show file tree
Hide file tree
Showing 41 changed files with 585 additions and 512 deletions.
1 change: 1 addition & 0 deletions x-pack/plugins/lens/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type {
IndexPatternPersistedState,
PersistedIndexPatternLayer,
IndexPatternColumn,
FieldBasedIndexPatternColumn,
OperationType,
IncompleteColumn,
FiltersIndexPatternColumn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { IndexPatternAggRestrictions } from '../../../../../src/plugins/data/pub
import { DragDropIdentifier } from '../drag_drop/providers';

export {
FieldBasedIndexPatternColumn,
IndexPatternColumn,
OperationType,
IncompleteColumn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import { ConfigProps, DataSeries } from '../../types';
import { FieldLabels } from '../constants';
import { buildPhraseFilter } from '../utils';
import { OperationType } from '../../../../../../../lens/public';

export function getServiceLatencyLensConfig({ seriesId, indexPattern }: ConfigProps): DataSeries {
return {
Expand All @@ -20,11 +19,11 @@ export function getServiceLatencyLensConfig({ seriesId, indexPattern }: ConfigPr
sourceField: '@timestamp',
},
yAxisColumn: {
operationType: 'average' as OperationType,
operationType: 'average',
sourceField: 'transaction.duration.us',
label: 'Latency',
},
hasMetricType: true,
hasOperationType: true,
defaultFilters: [
'user_agent.name',
'user_agent.os.name',
Expand All @@ -37,7 +36,7 @@ export function getServiceLatencyLensConfig({ seriesId, indexPattern }: ConfigPr
'client.geo.country_name',
'user_agent.device.name',
],
filters: [buildPhraseFilter('transaction.type', 'request', indexPattern)],
filters: buildPhraseFilter('transaction.type', 'request', indexPattern),
labels: { ...FieldLabels },
reportDefinitions: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,25 @@
import { ConfigProps, DataSeries } from '../../types';
import { FieldLabels } from '../constants/constants';
import { buildPhraseFilter } from '../utils';
import { OperationType } from '../../../../../../../lens/public';

export function getServiceThroughputLensConfig({
seriesId,
indexPattern,
}: ConfigProps): DataSeries {
return {
id: seriesId,
reportType: 'service-latency',
reportType: 'service-throughput',
defaultSeriesType: 'line',
seriesTypes: ['line', 'bar'],
xAxisColumn: {
sourceField: '@timestamp',
},
yAxisColumn: {
operationType: 'average' as OperationType,
operationType: 'average',
sourceField: 'transaction.duration.us',
label: 'Throughput',
},
hasMetricType: true,
hasOperationType: true,
defaultFilters: [
'user_agent.name',
'user_agent.os.name',
Expand All @@ -40,7 +39,7 @@ export function getServiceThroughputLensConfig({
'client.geo.country_name',
'user_agent.device.name',
],
filters: [buildPhraseFilter('transaction.type', 'request', indexPattern)],
filters: buildPhraseFilter('transaction.type', 'request', indexPattern),
labels: { ...FieldLabels },
reportDefinitions: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import { AppDataType, ReportViewTypeId } from '../../types';
import { CLS_FIELD, FCP_FIELD, FID_FIELD, LCP_FIELD, TBT_FIELD } from './elasticsearch_fieldnames';

export const DEFAULT_TIME = { from: 'now-1h', to: 'now' };

export const FieldLabels: Record<string, string> = {
'user_agent.name': 'Browser family',
'user_agent.version': 'Browser version',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

export enum URL_KEYS {
METRIC_TYPE = 'mt',
OPERATION_TYPE = 'op',
REPORT_TYPE = 'rt',
SERIES_TYPE = 'st',
BREAK_DOWN = 'bd',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,37 @@ describe('Lens Attribute', () => {
it('should return expected field type', function () {
expect(JSON.stringify(lnsAttr.getFieldMeta('transaction.type'))).toEqual(
JSON.stringify({
count: 0,
name: 'transaction.type',
type: 'string',
esTypes: ['keyword'],
scripted: false,
searchable: true,
aggregatable: true,
readFromDocValues: true,
fieldMeta: {
count: 0,
name: 'transaction.type',
type: 'string',
esTypes: ['keyword'],
scripted: false,
searchable: true,
aggregatable: true,
readFromDocValues: true,
},
fieldName: 'transaction.type',
columnType: null,
})
);
});

it('should return expected field type for custom field with default value', function () {
expect(JSON.stringify(lnsAttr.getFieldMeta('performance.metric'))).toEqual(
JSON.stringify({
count: 0,
name: 'transaction.duration.us',
type: 'number',
esTypes: ['long'],
scripted: false,
searchable: true,
aggregatable: true,
readFromDocValues: true,
fieldMeta: {
count: 0,
name: 'transaction.duration.us',
type: 'number',
esTypes: ['long'],
scripted: false,
searchable: true,
aggregatable: true,
readFromDocValues: true,
},
fieldName: 'transaction.duration.us',
columnType: null,
})
);
});
Expand All @@ -76,20 +84,45 @@ describe('Lens Attribute', () => {

expect(JSON.stringify(lnsAttr.getFieldMeta('performance.metric'))).toEqual(
JSON.stringify({
count: 0,
name: LCP_FIELD,
type: 'number',
esTypes: ['scaled_float'],
scripted: false,
searchable: true,
aggregatable: true,
readFromDocValues: true,
fieldMeta: {
count: 0,
name: LCP_FIELD,
type: 'number',
esTypes: ['scaled_float'],
scripted: false,
searchable: true,
aggregatable: true,
readFromDocValues: true,
},
fieldName: LCP_FIELD,
})
);
});

it('should return expected number column', function () {
expect(lnsAttr.getNumberColumn('transaction.duration.us')).toEqual({
it('should return expected number range column', function () {
expect(lnsAttr.getNumberRangeColumn('transaction.duration.us')).toEqual({
dataType: 'number',
isBucketed: true,
label: 'Page load time (Seconds)',
operationType: 'range',
params: {
maxBars: 'auto',
ranges: [
{
from: 0,
label: '',
to: 1000,
},
],
type: 'histogram',
},
scale: 'interval',
sourceField: 'transaction.duration.us',
});
});

it('should return expected number operation column', function () {
expect(lnsAttr.getNumberRangeColumn('transaction.duration.us')).toEqual({
dataType: 'number',
isBucketed: true,
label: 'Page load time (Seconds)',
Expand Down
Loading

0 comments on commit a2c47ef

Please sign in to comment.