mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
changes implementation direction
moving average will now be based on another metric instead of having moving average on itself
This commit is contained in:
parent
b4763290de
commit
ad79df9b74
@ -13,6 +13,7 @@ function (angular, _, queryDef) {
|
||||
|
||||
$scope.metricAggTypes = queryDef.metricAggTypes;
|
||||
$scope.extendedStats = queryDef.extendedStats;
|
||||
$scope.mavgSourceOptions = [];
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.agg = metricAggs[$scope.index];
|
||||
@ -22,6 +23,7 @@ function (angular, _, queryDef) {
|
||||
$rootScope.onAppEvent('elastic-query-updated', function() {
|
||||
$scope.index = _.indexOf(metricAggs, $scope.agg);
|
||||
$scope.validateModel();
|
||||
$scope.updateMovingAverageOptions();
|
||||
}, $scope);
|
||||
|
||||
$scope.validateModel = function() {
|
||||
@ -36,7 +38,8 @@ function (angular, _, queryDef) {
|
||||
|
||||
switch($scope.agg.type) {
|
||||
case 'moving_avg': {
|
||||
$scope.agg.aggregation = $scope.agg.aggregation || 'sum';
|
||||
$scope.agg.mavgSource = $scope.agg.mavgSource || '';
|
||||
$scope.settingsLinkText = 'Moving average options';
|
||||
break;
|
||||
}
|
||||
case 'percentiles': {
|
||||
@ -69,6 +72,11 @@ function (angular, _, queryDef) {
|
||||
|
||||
$scope.toggleOptions = function() {
|
||||
$scope.showOptions = !$scope.showOptions;
|
||||
$scope.updateMovingAverageOptions();
|
||||
};
|
||||
|
||||
$scope.onChangeInternal = function() {
|
||||
$scope.onChange();
|
||||
};
|
||||
|
||||
$scope.onTypeChange = function() {
|
||||
@ -82,13 +90,6 @@ function (angular, _, queryDef) {
|
||||
return $scope.getFields({$fieldType: 'number'});
|
||||
};
|
||||
|
||||
$scope.getMetrics = function() {
|
||||
var aggs = [{ text: 'Sum', type: 'sum'}, { text: 'Average', type: 'avg'}];
|
||||
|
||||
return $q.when(aggs)
|
||||
.then(uiSegmentSrv.transformToSegments(false));
|
||||
};
|
||||
|
||||
$scope.addMetricAgg = function() {
|
||||
var addIndex = metricAggs.length;
|
||||
|
||||
@ -100,6 +101,10 @@ function (angular, _, queryDef) {
|
||||
$scope.onChange();
|
||||
};
|
||||
|
||||
$scope.updateMovingAverageOptions = function() {
|
||||
$scope.mvagSourceOptions = queryDef.getMovingAverageSourceOptions($scope.target);
|
||||
};
|
||||
|
||||
$scope.removeMetricAgg = function() {
|
||||
metricAggs.splice($scope.index, 1);
|
||||
$scope.onChange();
|
||||
|
@ -9,9 +9,6 @@
|
||||
<li ng-if="aggDef.requiresField">
|
||||
<metric-segment-model property="agg.field" get-options="getFieldsInternal()" on-change="onChange()" css-class="tight-form-item-xxlarge"></metric-segment-model>
|
||||
</li>
|
||||
<li ng-if="aggDef.requiresBucketsPath">
|
||||
<metric-segment-model property="agg.aggregation" get-options="getMetrics()" on-change="onChange()" css-class="tight-form-item-xxlarge"></metric-segment-model>
|
||||
</li>
|
||||
<li class="tight-form-item last" ng-if="settingsLinkText">
|
||||
<a ng-click="toggleOptions()">{{settingsLinkText}}</a>
|
||||
</li>
|
||||
@ -30,6 +27,17 @@
|
||||
|
||||
<div class="tight-form" ng-if="showOptions">
|
||||
<div class="tight-form-inner-box">
|
||||
<div class="tight-form last" ng-if="agg.type === 'moving_avg'">
|
||||
<ul class="tight-form-list">
|
||||
<li class="tight-form-item">
|
||||
Based on
|
||||
</li>
|
||||
<li>
|
||||
<metric-segment-model property="agg.mavgSource" options="mavgSourceOptions" on-change="onChangeInternal()" css-class="last"></metric-segment-model>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div class="tight-form last" ng-if="agg.type === 'percentiles'">
|
||||
<ul class="tight-form-list">
|
||||
<li class="tight-form-item">
|
||||
|
@ -169,14 +169,9 @@ function () {
|
||||
|
||||
var aggField = {};
|
||||
var metricAgg = null;
|
||||
|
||||
if (metric.type === 'moving_avg') {
|
||||
var subBucket = metric.id + "_mavg";
|
||||
|
||||
var af = {};
|
||||
af[metric.aggregation] = {field: metric.field};
|
||||
nestedAggs.aggs[subBucket] = af;
|
||||
|
||||
metricAgg = { buckets_path: subBucket };
|
||||
metricAgg = {buckets_path: "1"};
|
||||
} else {
|
||||
metricAgg = {field: metric.field};
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ function (_) {
|
||||
{text: "Min", value: 'min', requiresField: true},
|
||||
{text: "Extended Stats", value: 'extended_stats', requiresField: true},
|
||||
{text: "Percentiles", value: 'percentiles', requiresField: true},
|
||||
{text: "Moving Avg", value: 'moving_avg', requiresField: false, requiresBucketsPath: true},
|
||||
{text: "Moving Avg", value: 'moving_avg', requiresField: false },
|
||||
{text: "Unique Count", value: "cardinality", requiresField: true},
|
||||
{text: "Raw Document", value: "raw_document", requiresField: false}
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user