diff --git a/public/app/plugins/datasource/opentsdb/datasource.js b/public/app/plugins/datasource/opentsdb/datasource.js index 83e7168399f..14605151752 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.js +++ b/public/app/plugins/datasource/opentsdb/datasource.js @@ -224,7 +224,7 @@ function (angular, _, dateMath) { this.getAggregators = function() { if (aggregatorsPromise) { return aggregatorsPromise; } - aggregatorsPromise = this._get('/api/aggregators').then(function(result) { + aggregatorsPromise = this._get('/api/aggregators').then(function(result) { if (result.data && _.isArray(result.data)) { return result.data.sort(); } @@ -233,6 +233,19 @@ function (angular, _, dateMath) { return aggregatorsPromise; }; + var filterTypesPromise = null; + this.getFilterTypes = function() { + if (filterTypesPromise) { return filterTypesPromise; } + + filterTypesPromise = this._get('/api/config/filters').then(function(result) { + if (result.data) { + return Object.keys(result.data).sort(); + } + return []; + }); + return filterTypesPromise; + }; + function transformMetricData(md, groupByTags, target, options) { var metricLabel = createMetricLabel(md, target, groupByTags, options); var dps = []; diff --git a/public/app/plugins/datasource/opentsdb/query_ctrl.ts b/public/app/plugins/datasource/opentsdb/query_ctrl.ts index 57afd75ab30..60466a00ff5 100644 --- a/public/app/plugins/datasource/opentsdb/query_ctrl.ts +++ b/public/app/plugins/datasource/opentsdb/query_ctrl.ts @@ -45,7 +45,15 @@ export class OpenTsQueryCtrl extends QueryCtrl { } this.datasource.getAggregators().then((aggs) => { - this.aggregators = aggs; + if (aggs.length !== 0) { + this.aggregators = aggs; + } + }); + + this.datasource.getFilterTypes().then((filterTypes) => { + if (filterTypes.length !== 0) { + this.filterTypes = filterTypes; + } }); // needs to be defined here as it is called from typeahead @@ -135,7 +143,7 @@ export class OpenTsQueryCtrl extends QueryCtrl { } if (!this.target.currentFilterType) { - this.target.currentFilterType = 'literal_or'; + this.target.currentFilterType = 'iliteral_or'; } if (!this.target.currentFilterGroupBy) { diff --git a/public/app/plugins/datasource/opentsdb/specs/query-ctrl-specs.ts b/public/app/plugins/datasource/opentsdb/specs/query-ctrl-specs.ts index d59bf0c64c7..5924fac7a38 100644 --- a/public/app/plugins/datasource/opentsdb/specs/query-ctrl-specs.ts +++ b/public/app/plugins/datasource/opentsdb/specs/query-ctrl-specs.ts @@ -17,6 +17,7 @@ describe('OpenTsQueryCtrl', function() { ctx.panelCtrl = {panel: {}}; ctx.panelCtrl.refresh = sinon.spy(); ctx.datasource.getAggregators = sinon.stub().returns(ctx.$q.when([])); + ctx.datasource.getFilterTypes = sinon.stub().returns(ctx.$q.when([])); ctx.ctrl = $controller(OpenTsQueryCtrl, {$scope: ctx.scope}, { panelCtrl: ctx.panelCtrl,