diff --git a/public/app/plugins/datasource/stackdriver/components/VariableQueryEditor.tsx b/public/app/plugins/datasource/stackdriver/components/VariableQueryEditor.tsx index 3cd985e1360..949fa96e0a7 100644 --- a/public/app/plugins/datasource/stackdriver/components/VariableQueryEditor.tsx +++ b/public/app/plugins/datasource/stackdriver/components/VariableQueryEditor.tsx @@ -144,7 +144,12 @@ export class StackdriverVariableQueryEditor extends PureComponent, prevState: Readonly) { - if (!getConfig().featureToggles.newVariables || prevState.selectedQueryType !== this.state.selectedQueryType) { + const selectSLOServiceChanged = this.state.selectedSLOService !== prevState.selectedSLOService; + if ( + !getConfig().featureToggles.newVariables || + prevState.selectedQueryType !== this.state.selectedQueryType || + selectSLOServiceChanged + ) { const { metricDescriptors, labels, metricTypes, services, ...queryModel } = this.state; const query = this.queryTypes.find(q => q.value === this.state.selectedQueryType); this.props.onChange(queryModel, `Stackdriver - ${query.name}`); diff --git a/public/app/plugins/datasource/stackdriver/datasource.ts b/public/app/plugins/datasource/stackdriver/datasource.ts index 4268e03f5a2..9ba7ad5028b 100644 --- a/public/app/plugins/datasource/stackdriver/datasource.ts +++ b/public/app/plugins/datasource/stackdriver/datasource.ts @@ -249,6 +249,9 @@ export default class StackdriverDatasource extends DataSourceApi>> { + if (!serviceId) { + return Promise.resolve([]); + } let { projectName: p, serviceId: s } = this.interpolateProps({ projectName, serviceId }); return this.api.get(`${p}/services/${s}/serviceLevelObjectives`, { responseMap: ({ name, displayName, goal }: { name: string; displayName: string; goal: number }) => ({