diff --git a/public/app/features/templating/query_variable.ts b/public/app/features/templating/query_variable.ts index 5e6bdc264ed..0aec1d8f412 100644 --- a/public/app/features/templating/query_variable.ts +++ b/public/app/features/templating/query_variable.ts @@ -23,6 +23,7 @@ export class QueryVariable implements Variable { tagValuesQuery: string; tags: any[]; skipUrlSync: boolean; + definition: string; defaults = { type: 'query', diff --git a/public/app/plugins/datasource/stackdriver/StackdriverMetricFindQuery.ts b/public/app/plugins/datasource/stackdriver/StackdriverMetricFindQuery.ts index 8920fed989e..f8fc2e796ce 100644 --- a/public/app/plugins/datasource/stackdriver/StackdriverMetricFindQuery.ts +++ b/public/app/plugins/datasource/stackdriver/StackdriverMetricFindQuery.ts @@ -5,6 +5,7 @@ import { getMetricTypesByService, getAlignmentOptionsByMetric, getAggregationOptionsByMetric, + extractServicesFromMetricDescriptors, getLabelKeys, } from './functions'; @@ -14,6 +15,8 @@ export default class StackdriverMetricFindQuery { async execute(query: any) { try { switch (query.selectedQueryType) { + case MetricFindQueryTypes.Services: + return this.handleServiceQuery(); case MetricFindQueryTypes.MetricTypes: return this.handleMetricTypesQuery(query); case MetricFindQueryTypes.LabelKeys: @@ -37,6 +40,16 @@ export default class StackdriverMetricFindQuery { } } + async handleServiceQuery() { + const metricDescriptors = await this.datasource.getMetricTypes(this.datasource.projectName); + const services = extractServicesFromMetricDescriptors(metricDescriptors); + return services.map(s => ({ + text: s.serviceShortName, + value: s.service, + expandable: true, + })); + } + async handleMetricTypesQuery({ selectedService }) { if (!selectedService) { return []; diff --git a/public/app/plugins/datasource/stackdriver/components/SimpleSelect.tsx b/public/app/plugins/datasource/stackdriver/components/SimpleSelect.tsx index 976fc52b34d..1834bd9da5c 100644 --- a/public/app/plugins/datasource/stackdriver/components/SimpleSelect.tsx +++ b/public/app/plugins/datasource/stackdriver/components/SimpleSelect.tsx @@ -12,7 +12,7 @@ const SimpleSelect: SFC = props => { return (
{label} -
+