diff --git a/public/app/plugins/datasource/graphite/datasource.ts b/public/app/plugins/datasource/graphite/datasource.ts index f3209b89709..d2927cc5567 100644 --- a/public/app/plugins/datasource/graphite/datasource.ts +++ b/public/app/plugins/datasource/graphite/datasource.ts @@ -350,32 +350,17 @@ export class GraphiteDatasource extends DataSourceApi[,]*), this is used for template variables - let matches = interpolatedQuery.match(/^tag_values\(([^,]+)((, *[^,]+)*)\)$/); - if (matches) { - const expressions = []; - const exprRegex = /, *([^,]+)/g; - let match = exprRegex.exec(matches[2]); - while (match !== null) { - expressions.push(match[1]); - match = exprRegex.exec(matches[2]); - } + let allParams = interpolatedQuery.match(/^tag_values\((.*)\)$/); + let expressions = allParams ? allParams[1].split(',').filter((p) => !!p) : undefined; + if (expressions) { options.limit = 10000; - return this.getTagValuesAutoComplete(expressions, matches[1], undefined, options); + return this.getTagValuesAutoComplete(expressions.slice(1), expressions[0], undefined, options); } // special handling for tags([,]*), this is used for template variables - matches = interpolatedQuery.match(/^tags\(([^,]*)((, *[^,]+)*)\)$/); - if (matches) { - const expressions = []; - if (matches[1]) { - expressions.push(matches[1]); - const exprRegex = /, *([^,]+)/g; - let match = exprRegex.exec(matches[2]); - while (match !== null) { - expressions.push(match[1]); - match = exprRegex.exec(matches[2]); - } - } + allParams = interpolatedQuery.match(/^tags\((.*)\)$/); + expressions = allParams ? allParams[1].split(',').filter((p) => !!p) : undefined; + if (expressions) { options.limit = 10000; return this.getTagsAutoComplete(expressions, undefined, options); }