mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 21:19:28 -06:00
Merge branch 'master' of https://github.com/mk-dhia/grafana into mk-dhia-master
This commit is contained in:
commit
3c41d0477a
@ -67,7 +67,6 @@ function (angular, _, queryDef) {
|
|||||||
} else if (!$scope.agg.field) {
|
} else if (!$scope.agg.field) {
|
||||||
$scope.agg.field = 'select field';
|
$scope.agg.field = 'select field';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($scope.agg.type) {
|
switch($scope.agg.type) {
|
||||||
case 'cardinality': {
|
case 'cardinality': {
|
||||||
var precision_threshold = $scope.agg.settings.precision_threshold || '';
|
var precision_threshold = $scope.agg.settings.precision_threshold || '';
|
||||||
@ -103,12 +102,14 @@ function (angular, _, queryDef) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'raw_document': {
|
case 'raw_document': {
|
||||||
$scope.target.metrics = [$scope.agg];
|
$scope.agg.settings.size = $scope.agg.settings.size || 500;
|
||||||
|
$scope.settingsLinkText = 'Size: ' + $scope.agg.settings.size ;
|
||||||
|
$scope.target.metrics.splice(0,$scope.target.metrics.length, $scope.agg);
|
||||||
|
|
||||||
$scope.target.bucketAggs = [];
|
$scope.target.bucketAggs = [];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($scope.aggDef.supportsInlineScript) {
|
if ($scope.aggDef.supportsInlineScript) {
|
||||||
// I know this stores the inline script twice
|
// I know this stores the inline script twice
|
||||||
// but having it like this simplifes the query_builder
|
// but having it like this simplifes the query_builder
|
||||||
|
@ -72,6 +72,11 @@
|
|||||||
<label class="gf-form-label width-10">Percentiles</label>
|
<label class="gf-form-label width-10">Percentiles</label>
|
||||||
<input type="text" class="gf-form-input max-width-12" ng-model="agg.settings.percents" array-join ng-blur="onChange()"></input>
|
<input type="text" class="gf-form-input max-width-12" ng-model="agg.settings.percents" array-join ng-blur="onChange()"></input>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="gf-form offset-width-7" ng-if="agg.type === 'raw_document'">
|
||||||
|
<label class="gf-form-label width-10">Size</label>
|
||||||
|
<input type="number" class="gf-form-input max-width-12" ng-model="agg.settings.size" ng-blur="onChange()"></input>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="gf-form offset-width-7" ng-if="agg.type === 'cardinality'">
|
<div class="gf-form offset-width-7" ng-if="agg.type === 'cardinality'">
|
||||||
<label class="gf-form-label width-10">Precision threshold</label>
|
<label class="gf-form-label width-10">Precision threshold</label>
|
||||||
|
@ -109,8 +109,8 @@ function (queryDef) {
|
|||||||
return filterObj;
|
return filterObj;
|
||||||
};
|
};
|
||||||
|
|
||||||
ElasticQueryBuilder.prototype.documentQuery = function(query) {
|
ElasticQueryBuilder.prototype.documentQuery = function(query, size) {
|
||||||
query.size = 500;
|
query.size = size === undefined ? 500 : size;
|
||||||
query.sort = {};
|
query.sort = {};
|
||||||
query.sort[this.timeField] = {order: 'desc', unmapped_type: 'boolean'};
|
query.sort[this.timeField] = {order: 'desc', unmapped_type: 'boolean'};
|
||||||
|
|
||||||
@ -194,9 +194,12 @@ function (queryDef) {
|
|||||||
if (target.bucketAggs.length === 0) {
|
if (target.bucketAggs.length === 0) {
|
||||||
metric = target.metrics[0];
|
metric = target.metrics[0];
|
||||||
if (metric && metric.type !== 'raw_document') {
|
if (metric && metric.type !== 'raw_document') {
|
||||||
throw {message: 'Invalid query'};
|
target.bucketAggs = [{type: 'date_histogram', id: '2', settings: {interval: 'auto'}}];
|
||||||
|
} else {
|
||||||
|
var size = metric && metric.hasOwnProperty("settings") && metric.settings.hasOwnProperty("size")
|
||||||
|
&& metric.settings["size"] !== null ? metric.settings["size"] : 500 ;
|
||||||
|
return this.documentQuery(query,size);
|
||||||
}
|
}
|
||||||
return this.documentQuery(query, target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nestedAggs = query;
|
nestedAggs = query;
|
||||||
|
@ -156,13 +156,22 @@ describe('ElasticQueryBuilder', function() {
|
|||||||
|
|
||||||
it('with raw_document metric', function() {
|
it('with raw_document metric', function() {
|
||||||
var query = builder.build({
|
var query = builder.build({
|
||||||
metrics: [{type: 'raw_document', id: '1'}],
|
metrics: [{type: 'raw_document', id: '1',settings: {}}],
|
||||||
timeField: '@timestamp',
|
timeField: '@timestamp',
|
||||||
bucketAggs: [],
|
bucketAggs: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(query.size).to.be(500);
|
expect(query.size).to.be(500);
|
||||||
});
|
});
|
||||||
|
it('with raw_document metric size set', function() {
|
||||||
|
var query = builder.build({
|
||||||
|
metrics: [{type: 'raw_document', id: '1',settings: {size: 1337}}],
|
||||||
|
timeField: '@timestamp',
|
||||||
|
bucketAggs: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(query.size).to.be(1337);
|
||||||
|
});
|
||||||
|
|
||||||
it('with moving average', function() {
|
it('with moving average', function() {
|
||||||
var query = builder.build({
|
var query = builder.build({
|
||||||
|
Loading…
Reference in New Issue
Block a user