Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add top_hit metric #7302

Merged
merged 46 commits into from
Jan 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
22bab62
add top_hits aggregation
scampi May 26, 2016
8aef2b8
support nested fields
scampi Jun 11, 2016
9791ac5
added choice of the order and select by default the index pattern ass…
scampi Jun 14, 2016
692f41c
improved parameters name and changed aggregation from latest to top t…
scampi Jun 22, 2016
39cddab
made variable a constant
scampi Jul 1, 2016
c6494cc
use shorter name for variable
scampi Jul 27, 2016
b365ddc
prevent to sort terms on top_hits
scampi Aug 28, 2016
be44e90
Added the top_hits agg to line/pie/tile vis. Added support for functi…
scampi Sep 19, 2016
43767f0
simplified tests
scampi Oct 11, 2016
53469d5
changed as per code review
scampi Oct 11, 2016
20be950
Top Hit should support all field types on the metric vis
scampi Oct 17, 2016
20cbb12
renamed metric to top hit
scampi Oct 17, 2016
b99d6c7
check if there is any result from buckets
scampi Oct 18, 2016
f79cdc1
support scripted fields
scampi Oct 23, 2016
82060ce
Merge branch 'master' of github.com:elastic/kibana into latest-value
scampi Nov 1, 2016
2577298
Merge branch 'master' of github.com:elastic/kibana into latest-value
scampi Nov 12, 2016
6a2bc01
- added logic for trying to get the field value from the source or fr…
scampi Nov 13, 2016
991864c
improved loops in getValuesAtPath method
scampi Nov 16, 2016
bc1c90a
Merge branch 'master' of github.com:elastic/kibana into latest-value
scampi Nov 17, 2016
d697f11
do not try to get the doc_values field of an IP field
scampi Nov 18, 2016
c2249e5
improved field tests on the onlyAggregatable option
scampi Nov 18, 2016
f4200e1
use indexPattern.formatField to get all the values at a given path
scampi Nov 19, 2016
2dda53d
do not show the analyzed warning
scampi Nov 19, 2016
eda9610
support to sort on scripted field
scampi Nov 19, 2016
b465438
corrected tests and rely on the field's formatter instead of trying t…
scampi Nov 20, 2016
19e2104
do not rely on init_default_field_props to set the doc_values property
scampi Nov 21, 2016
fd323f3
added test for the doc_values property
scampi Nov 23, 2016
cfed72e
Merge branch 'master' of github.com:elastic/kibana into latest-value
scampi Dec 5, 2016
3090182
- corrected source formatter
scampi Dec 5, 2016
0d924fc
set the default value of the showAnalyzedWarning in fieldparam
scampi Dec 8, 2016
7f85803
added description of the showAnalyzedWarning option
scampi Dec 8, 2016
ef95ceb
use aggParam object to access the options of the field parameter
scampi Dec 9, 2016
b64f92a
flattenHit: support object in array
scampi Dec 10, 2016
bebb905
Merge branch 'master' of github.com:elastic/kibana into latest-value
scampi Dec 15, 2016
e18a30d
added aggregation option to support multivalued fields and top_hits a…
scampi Dec 17, 2016
3d5fa02
Merge branch 'master' of github.com:elastic/kibana into latest-value
scampi Dec 17, 2016
2a2fa67
disable concatenate aggregation type for visualizations other than ta…
scampi Dec 17, 2016
eb70e84
corrected display of arrays in the metric vis
scampi Dec 17, 2016
d19ba56
removed condition on the IP field type when retrieving doc values
scampi Dec 17, 2016
66d3b31
- do not set a default value for the aggregate with property since it is
scampi Dec 21, 2016
1bd4727
filter out incompatble aggregate options and auto select the option i…
scampi Dec 28, 2016
5babf9a
simplified condition
scampi Dec 28, 2016
7372fce
lint
scampi Dec 30, 2016
67088c8
Merge branch 'master' of github.com:elastic/kibana into latest-value
scampi Jan 3, 2017
0791be7
fix min/max/sum/average aggregate of elements having only null/undefi…
scampi Jan 3, 2017
c967a23
added top_hits metric to heatmap visualization
scampi Jan 3, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core_plugins/kbn_vislib_vis_types/public/heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function HeatmapVisType(Private) {
title: 'Value',
min: 1,
max: 1,
aggFilter: ['count', 'avg', 'median', 'sum', 'min', 'max', 'cardinality', 'std_dev'],
aggFilter: ['count', 'avg', 'median', 'sum', 'min', 'max', 'cardinality', 'std_dev', 'top_hits'],
defaults: [
{ schema: 'metric', type: 'count' }
]
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/kbn_vislib_vis_types/public/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default function HistogramVisType(Private) {
title: 'Dot Size',
min: 0,
max: 1,
aggFilter: ['count', 'avg', 'sum', 'min', 'max', 'cardinality']
aggFilter: ['count', 'avg', 'sum', 'min', 'max', 'cardinality', 'top_hits']
},
{
group: 'buckets',
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/kbn_vislib_vis_types/public/pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function HistogramVisType(Private) {
title: 'Slice Size',
min: 1,
max: 1,
aggFilter: ['sum', 'count', 'cardinality'],
aggFilter: ['sum', 'count', 'cardinality', 'top_hits'],
defaults: [
{ schema: 'metric', type: 'count' }
]
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/kbn_vislib_vis_types/public/tile_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default function TileMapVisType(Private, getAppState, courier, config) {
title: 'Value',
min: 1,
max: 1,
aggFilter: ['count', 'avg', 'sum', 'min', 'max', 'cardinality'],
aggFilter: ['count', 'avg', 'sum', 'min', 'max', 'cardinality', 'top_hits'],
defaults: [
{ schema: 'metric', type: 'count' }
]
Expand Down
13 changes: 10 additions & 3 deletions src/core_plugins/kibana/public/visualize/editor/agg_params.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,18 @@ uiModules
// build collection of agg params html
type.params.forEach(function (param, i) {
let aggParam;
let fields;
// if field param exists, compute allowed fields
if (param.name === 'field') {
fields = $aggParamEditorsScope.indexedFields;
} else if (param.type === 'field') {
fields = $aggParamEditorsScope[`${param.name}Options`] = param.getFieldOptions($scope.agg);
}

if ($aggParamEditorsScope.indexedFields) {
const hasIndexedFields = $aggParamEditorsScope.indexedFields.length > 0;
if (fields) {
const hasIndexedFields = fields.length > 0;
const isExtraParam = i > 0;
if (!hasIndexedFields && isExtraParam) { // don't draw the rest of the options if their are no indexed fields.
if (!hasIndexedFields && isExtraParam) { // don't draw the rest of the options if there are no indexed fields.
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@ describe('metric vis', function () {
$scope.processTableGroups({
tables: [{
columns: [{ title: 'Count' }],
rows: [[4301021]],
aggConfig: function () {
return {
fieldFormatter: function () {
return formatter;
}
};
}
rows: [[ { toString: () => formatter(4301021) } ]]
}]
});

Expand All @@ -44,14 +37,7 @@ describe('metric vis', function () {
{ title: '1st percentile of bytes' },
{ title: '99th percentile of bytes' }
],
rows: [[182, 445842.4634666484]],
aggConfig: function () {
return {
fieldFormatter: function () {
return formatter;
}
};
}
rows: [[ { toString: () => formatter(182) }, { toString: () => formatter(445842.4634666484) } ]]
}]
});

Expand Down
13 changes: 7 additions & 6 deletions src/core_plugins/metric_vis/public/metric_vis_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@ module.controller('KbnMetricVisController', function ($scope, $element, Private)
$scope.processTableGroups = function (tableGroups) {
tableGroups.tables.forEach(function (table) {
table.columns.forEach(function (column, i) {
const fieldFormatter = table.aggConfig(column).fieldFormatter();
let value = table.rows[0][i];

value = isInvalid(value) ? '?' : fieldFormatter(value);
const value = table.rows[0][i];

metrics.push({
label: column.title,
value: value
value: value.toString('html')
});
});
});
};

$scope.$watch('esResponse', function (resp) {
if (resp) {
const options = {
asAggConfigResults: true
};

metrics.length = 0;
$scope.processTableGroups(tabifyAggResponse($scope.vis, resp));
$scope.processTableGroups(tabifyAggResponse($scope.vis, resp, options));
$element.trigger('renderComplete');
}
});
Expand Down
5 changes: 4 additions & 1 deletion src/fixtures/logstash_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function stubbedLogstashFields() {
// | | |aggregatable
// | | | |searchable
// name type | | | | |metadata
['bytes', 'number', true, true, true, true, { count: 10 } ],
['bytes', 'number', true, true, true, true, { count: 10, docValues: true } ],
['ssl', 'boolean', true, true, true, true, { count: 20 } ],
['@timestamp', 'date', true, true, true, true, { count: 30 } ],
['time', 'date', true, true, true, true, { count: 30 } ],
Expand All @@ -20,6 +20,7 @@ function stubbedLogstashFields() {
['geo.coordinates', 'geo_point', true, true, true, true ],
['extension', 'string', true, true, true, true ],
['machine.os', 'string', true, true, true, true ],
['machine.os.raw', 'string', true, false, true, true, { docValues: true } ],
['geo.src', 'string', true, true, true, true ],
['_id', 'string', false, false, true, true ],
['_type', 'string', false, false, true, true ],
Expand All @@ -41,6 +42,7 @@ function stubbedLogstashFields() {
] = row;

const {
docValues = false,
count = 0,
script,
lang = script ? 'expression' : undefined,
Expand All @@ -50,6 +52,7 @@ function stubbedLogstashFields() {
return {
name,
type,
doc_values: docValues,
indexed,
analyzed,
aggregatable,
Expand Down
1 change: 1 addition & 0 deletions src/test_utils/stub_index_pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import getComputedFields from 'ui/index_patterns/_get_computed_fields';
import RegistryFieldFormatsProvider from 'ui/registry/field_formats';
import IndexPatternsFlattenHitProvider from 'ui/index_patterns/_flatten_hit';
import IndexPatternsFieldProvider from 'ui/index_patterns/_field';

export default function (Private) {
const fieldFormats = Private(RegistryFieldFormatsProvider);
const flattenHit = Private(IndexPatternsFlattenHitProvider);
Expand Down
13 changes: 0 additions & 13 deletions src/ui/public/agg_types/__tests__/buckets/_terms.js

This file was deleted.

156 changes: 156 additions & 0 deletions src/ui/public/agg_types/__tests__/buckets/terms.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import expect from 'expect.js';
import ngMock from 'ng_mock';
import AggTypesIndexProvider from 'ui/agg_types/index';

describe('Terms Agg', function () {
describe('order agg editor UI', function () {

let $rootScope;

function init({ responseValueAggs = [] }) {
ngMock.module('kibana');
ngMock.inject(function (Private, $controller, _$rootScope_) {
const terms = Private(AggTypesIndexProvider).byName.terms;
const orderAggController = terms.params.byName.orderAgg.controller;

$rootScope = _$rootScope_;
$rootScope.agg = {
id: 'test',
params: {},
type: terms,
vis: {
aggs: []
}
};
$rootScope.responseValueAggs = responseValueAggs;
$controller(orderAggController, { $scope: $rootScope });
$rootScope.$digest();
});
}

it('defaults to the first metric agg', function () {
init({
responseValueAggs: [
{
id: 'agg1',
type: {
name: 'count'
}
},
{
id: 'agg2',
type: {
name: 'count'
}
}
]
});
expect($rootScope.agg.params.orderBy).to.be('agg1');
});

it('defaults to the first metric agg that is compatible with the terms bucket', function () {
init({
responseValueAggs: [
{
id: 'agg1',
type: {
name: 'top_hits'
}
},
{
id: 'agg2',
type: {
name: 'percentiles'
}
},
{
id: 'agg3',
type: {
name: 'median'
}
},
{
id: 'agg4',
type: {
name: 'std_dev'
}
},
{
id: 'agg5',
type: {
name: 'count'
}
}
]
});
expect($rootScope.agg.params.orderBy).to.be('agg5');
});

it('defaults to the _term metric if no agg is compatible', function () {
init({
responseValueAggs: [
{
id: 'agg1',
type: {
name: 'top_hits'
}
}
]
});
expect($rootScope.agg.params.orderBy).to.be('_term');
});

it('selects _term if there are no metric aggs', function () {
init({});
expect($rootScope.agg.params.orderBy).to.be('_term');
});

it('selects _term if the selected metric becomes incompatible', function () {
init({
responseValueAggs: [
{
id: 'agg1',
type: {
name: 'count'
}
}
]
});
expect($rootScope.agg.params.orderBy).to.be('agg1');
$rootScope.responseValueAggs = [
{
id: 'agg1',
type: {
name: 'top_hits'
}
}
];
$rootScope.$digest();
expect($rootScope.agg.params.orderBy).to.be('_term');
});

it('selects _term if the selected metric is removed', function () {
init({
responseValueAggs: [
{
id: 'agg1',
type: {
name: 'count'
}
}
]
});
expect($rootScope.agg.params.orderBy).to.be('agg1');
$rootScope.responseValueAggs = [];
$rootScope.$digest();
expect($rootScope.agg.params.orderBy).to.be('_term');
});

it('adds "custom metric" option');
it('lists all metric agg responses');
it('lists individual values of a multi-value metric');
it('displays a metric editor if "custom metric" is selected');
it('saves the "custom metric" to state and refreshes from it');
it('invalidates the form if the metric agg form is not complete');
});
});
Loading