diff --git a/public/app/plugins/datasource/graphite/datasource.ts b/public/app/plugins/datasource/graphite/datasource.ts index 319f2e498a7..d658ba8286e 100644 --- a/public/app/plugins/datasource/graphite/datasource.ts +++ b/public/app/plugins/datasource/graphite/datasource.ts @@ -247,7 +247,7 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv this.getTagValues = function(tag, optionalOptions) { let options = optionalOptions || {}; - let httpOptions: any = { + let httpOptions: any = { method: 'GET', url: '/tags/' + tag, // for cancellations @@ -273,6 +273,57 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv }); }; + this.getTagsAutoComplete = (expression, tagPrefix) => { + let httpOptions: any = { + method: 'GET', + url: '/tags/autoComplete/tags', + params: { + expr: expression + } + }; + + if (tagPrefix) { + httpOptions.params.tagPrefix = tagPrefix; + } + + return this.doGraphiteRequest(httpOptions).then(results => { + if (results.data) { + return _.map(results.data, (tag) => { + return { text: tag }; + }); + } else { + return []; + } + }); + }; + + this.getTagValuesAutoComplete = (expression, tag, valuePrefix) => { + let httpOptions: any = { + method: 'GET', + url: '/tags/autoComplete/values', + params: { + expr: expression + } + }; + + if (tag) { + httpOptions.params.tag = tag; + } + if (valuePrefix) { + httpOptions.params.valuePrefix = valuePrefix; + } + + return this.doGraphiteRequest(httpOptions).then(results => { + if (results.data) { + return _.map(results.data, (value) => { + return { text: value }; + }); + } else { + return []; + } + }); + }; + this.getVersion = function() { let httpOptions = { method: 'GET', diff --git a/public/app/plugins/datasource/graphite/graphite_query.ts b/public/app/plugins/datasource/graphite/graphite_query.ts index 201972b9126..12301befff8 100644 --- a/public/app/plugins/datasource/graphite/graphite_query.ts +++ b/public/app/plugins/datasource/graphite/graphite_query.ts @@ -263,6 +263,15 @@ export default class GraphiteQuery { this.getSeriesByTagFunc().params[tagIndex] = newTagParam; this.tags[tagIndex] = tag; } + + renderTagExpressions(excludeIndex = -1) { + return _.compact(_.map(this.tags, (tagExpr, index) => { + // Don't render tag that we want to lookup + if (index !== excludeIndex) { + return tagExpr.key + tagExpr.operator + tagExpr.value; + } + })); + } } function wrapFunction(target, func) { diff --git a/public/app/plugins/datasource/graphite/partials/query.editor.html b/public/app/plugins/datasource/graphite/partials/query.editor.html index 858f2a470e4..7db918768d0 100755 --- a/public/app/plugins/datasource/graphite/partials/query.editor.html +++ b/public/app/plugins/datasource/graphite/partials/query.editor.html @@ -12,7 +12,7 @@