diff --git a/public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx b/public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx index cbac49867cb..6f6045b03e3 100644 --- a/public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx +++ b/public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx @@ -43,9 +43,14 @@ export class StackdriverTemplateQueryComponent extends PureComponent s.value === this.state.selectedService) - ? this.state.selectedService - : services[0].value; + + let selectedService = ''; + if (services.some(s => s.value === this.state.selectedService)) { + selectedService = this.state.selectedService; + } else if (services && services.length > 0) { + selectedService = services[0].value; + } + const { metricTypes, selectedMetricType } = getMetricTypes( metricDescriptors, this.state.selectedMetricType,