Commit b24c5392 by Torkel Ödegaard

feat(elasticsearch): began work on supporting extended stats metric agg, it…

feat(elasticsearch): began work on supporting extended stats metric agg, it gives you standard deviation and more
parent 52eeefa6
...@@ -213,6 +213,15 @@ function (angular, _, config, kbn, moment, ElasticQueryBuilder) { ...@@ -213,6 +213,15 @@ function (angular, _, config, kbn, moment, ElasticQueryBuilder) {
} }
break; break;
} }
case 'extended_stats': {
var stats = bucket[metric.id];
for (var statIndex in metric.stats) {
var statName = metric.stats[statIndex];
addMetricPoint(seriesName + ' ' + statName, stats[statName], bucket.key)
}
break;
}
default: { default: {
seriesName += ' ' + metric.field + ' ' + metric.type; seriesName += ' ' + metric.field + ' ' + metric.type;
value = bucket[metric.id].value; value = bucket[metric.id].value;
......
...@@ -20,22 +20,29 @@ function (angular, _, queryDef) { ...@@ -20,22 +20,29 @@ function (angular, _, queryDef) {
$rootScope.onAppEvent('elastic-query-updated', function() { $rootScope.onAppEvent('elastic-query-updated', function() {
$scope.index = _.indexOf(metricAggs, $scope.agg); $scope.index = _.indexOf(metricAggs, $scope.agg);
$scope.isFirst = $scope.index === 0;
$scope.isSingle = metricAggs.length === 1;
$scope.validateModel(); $scope.validateModel();
}); });
$scope.validateModel = function() { $scope.validateModel = function() {
$scope.isFirst = $scope.index === 0;
$scope.isSingle = metricAggs.length === 1;
$scope.settingsLinkText = ''; $scope.settingsLinkText = '';
if (!$scope.agg.field) { if (!$scope.agg.field) {
$scope.agg.field = 'select field'; $scope.agg.field = 'select field';
} }
if ($scope.agg.type === 'percentiles') { switch($scope.agg.type) {
$scope.agg.settings.percents = $scope.agg.settings.percents || [25,50,75,95,99]; case 'percentiles': {
$scope.settingsLinkText = 'values: ' + $scope.agg.settings.percents.join(','); $scope.agg.settings.percents = $scope.agg.settings.percents || [25,50,75,95,99];
$scope.settingsLinkText = 'values: ' + $scope.agg.settings.percents.join(',');
break;
}
case 'extended_stats': {
$scope.agg.stats = $scope.agg.stats || ['std_deviation'];
$scope.settingsLinkText = 'stats: ' + $scope.agg.stats.join(',');
}
} }
} }
...@@ -57,6 +64,7 @@ function (angular, _, queryDef) { ...@@ -57,6 +64,7 @@ function (angular, _, queryDef) {
}, 0); }, 0);
metricAggs.splice(addIndex, 0, {type: "count", field: "select field", id: (id+1).toString()}); metricAggs.splice(addIndex, 0, {type: "count", field: "select field", id: (id+1).toString()});
$scope.onChange();
}; };
$scope.removeMetricAgg = function() { $scope.removeMetricAgg = function() {
......
...@@ -11,7 +11,7 @@ function (_) { ...@@ -11,7 +11,7 @@ function (_) {
{text: "Sum of", value: 'sum' }, {text: "Sum of", value: 'sum' },
{text: "Max of", value: 'max' }, {text: "Max of", value: 'max' },
{text: "Min of", value: 'min' }, {text: "Min of", value: 'min' },
{text: "Standard Deviations", value: 'std_dev' }, {text: "Extended Stats", value: 'extended_stats' },
{text: "Percentiles", value: 'percentiles' }, {text: "Percentiles", value: 'percentiles' },
], ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment