Commit 4aff2d74 by Alex Ashley Committed by GitHub

Stackdriver: Use default project name if project name isn't set on the query (#25413)

* Get default project if not defined on query

* Log when using default project name

* Set query result error
parent cd75dc93
...@@ -322,7 +322,18 @@ func calculateAlignmentPeriod(alignmentPeriod string, intervalMs int64, duration ...@@ -322,7 +322,18 @@ func calculateAlignmentPeriod(alignmentPeriod string, intervalMs int64, duration
func (e *StackdriverExecutor) executeQuery(ctx context.Context, query *stackdriverQuery, tsdbQuery *tsdb.TsdbQuery) (*tsdb.QueryResult, stackdriverResponse, error) { func (e *StackdriverExecutor) executeQuery(ctx context.Context, query *stackdriverQuery, tsdbQuery *tsdb.TsdbQuery) (*tsdb.QueryResult, stackdriverResponse, error) {
queryResult := &tsdb.QueryResult{Meta: simplejson.New(), RefId: query.RefID} queryResult := &tsdb.QueryResult{Meta: simplejson.New(), RefId: query.RefID}
req, err := e.createRequest(ctx, e.dsInfo, query, fmt.Sprintf("stackdriver%s", "v3/projects/"+query.ProjectName+"/timeSeries")) projectName := query.ProjectName
if projectName == "" {
defaultProject, err := e.getDefaultProject(ctx)
if err != nil {
queryResult.Error = err
return queryResult, stackdriverResponse{}, nil
}
projectName = defaultProject
slog.Info("No project name set on query, using project name from datasource", "projectName", projectName)
}
req, err := e.createRequest(ctx, e.dsInfo, query, fmt.Sprintf("stackdriver%s", "v3/projects/"+projectName+"/timeSeries"))
if err != nil { if err != nil {
queryResult.Error = err queryResult.Error = err
return queryResult, stackdriverResponse{}, nil return queryResult, stackdriverResponse{}, nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment