diff --git a/pkg/tsdb/stackdriver/stackdriver.go b/pkg/tsdb/stackdriver/stackdriver.go
index b90420e9f03..495e62de22c 100644
--- a/pkg/tsdb/stackdriver/stackdriver.go
+++ b/pkg/tsdb/stackdriver/stackdriver.go
@@ -102,10 +102,8 @@ func (e *StackdriverExecutor) getGCEDefaultProject(ctx context.Context, tsdbQuer
gceDefaultProject, err := e.getDefaultProject(ctx)
if err != nil {
- slog.Debug("Stackdriver", "Auth", "Failed to use GCE auth: ", err)
return nil, fmt.Errorf("Failed to retrieve default project from GCE metadata server. error: %v", err)
}
- slog.Debug("Stackdriver", "Auth", "Successfully use GCE auth: ", gceDefaultProject)
queryResult.Meta.Set("defaultProject", gceDefaultProject)
result.Results[refId] = queryResult
diff --git a/public/app/plugins/datasource/stackdriver/components/Metrics.tsx b/public/app/plugins/datasource/stackdriver/components/Metrics.tsx
index 2ae137ca1a5..686e528d2d6 100644
--- a/public/app/plugins/datasource/stackdriver/components/Metrics.tsx
+++ b/public/app/plugins/datasource/stackdriver/components/Metrics.tsx
@@ -111,7 +111,6 @@ export function Metrics(props: Props) {
return services.length > 0 ? _.uniqBy(services, s => s.value) : [];
};
- console.log('rerender', { service, metricType });
return (
<>
diff --git a/public/app/plugins/datasource/stackdriver/components/QueryEditor.test.tsx b/public/app/plugins/datasource/stackdriver/components/QueryEditor.test.tsx
index c7a75dadbac..6350f9675b7 100644
--- a/public/app/plugins/datasource/stackdriver/components/QueryEditor.test.tsx
+++ b/public/app/plugins/datasource/stackdriver/components/QueryEditor.test.tsx
@@ -11,6 +11,7 @@ const props: Props = {
datasource: {
getProjects: () => Promise.resolve([]),
getDefaultProject: () => Promise.resolve('projectName'),
+ ensureGCEDefaultProject: () => {},
getMetricTypes: () => Promise.resolve([]),
getLabels: () => Promise.resolve([]),
variables: [],
diff --git a/public/app/plugins/datasource/stackdriver/components/QueryEditor.tsx b/public/app/plugins/datasource/stackdriver/components/QueryEditor.tsx
index 0ce4ad77fd2..b751284acb1 100644
--- a/public/app/plugins/datasource/stackdriver/components/QueryEditor.tsx
+++ b/public/app/plugins/datasource/stackdriver/components/QueryEditor.tsx
@@ -56,6 +56,7 @@ export class QueryEditor extends React.Component
{
async componentDidMount() {
const { events, target, templateSrv, datasource } = this.props;
+ await datasource.ensureGCEDefaultProject();
if (!target.projectName) {
target.projectName = datasource.getDefaultProject();
}
diff --git a/public/app/plugins/datasource/stackdriver/components/__snapshots__/QueryEditor.test.tsx.snap b/public/app/plugins/datasource/stackdriver/components/__snapshots__/QueryEditor.test.tsx.snap
index e6eeee7acf2..81fc2058be9 100644
--- a/public/app/plugins/datasource/stackdriver/components/__snapshots__/QueryEditor.test.tsx.snap
+++ b/public/app/plugins/datasource/stackdriver/components/__snapshots__/QueryEditor.test.tsx.snap
@@ -15,7 +15,7 @@ Array [
onClick={[Function]}
>
Select Project
diff --git a/public/app/plugins/datasource/stackdriver/datasource.ts b/public/app/plugins/datasource/stackdriver/datasource.ts
index 9251a21ec1d..670d31bd05c 100644
--- a/public/app/plugins/datasource/stackdriver/datasource.ts
+++ b/public/app/plugins/datasource/stackdriver/datasource.ts
@@ -41,6 +41,7 @@ export default class StackdriverDatasource extends DataSourceApi) {
+ await this.ensureGCEDefaultProject();
const queries = options.targets
.filter((target: StackdriverQuery) => {
return !target.hide && target.metricType;
@@ -173,6 +174,7 @@ export default class StackdriverDatasource extends DataSourceApi {
try {
if (!projectName) {