diff --git a/pkg/tsdb/cloudwatch/log_actions.go b/pkg/tsdb/cloudwatch/log_actions.go index da848ce3f0b..e2cac5bed5f 100644 --- a/pkg/tsdb/cloudwatch/log_actions.go +++ b/pkg/tsdb/cloudwatch/log_actions.go @@ -200,13 +200,19 @@ func (e *CloudWatchExecutor) executeStartQuery(ctx context.Context, logsClient c // so that a row's context can be retrieved later if necessary. // The usage of ltrim around the @log/@logStream fields is a necessary workaround, as without it, // CloudWatch wouldn't consider a query using a non-alised @log/@logStream valid. + modifiedQueryString := "fields @timestamp,ltrim(@log) as " + logIdentifierInternal + ",ltrim(@logStream) as " + logStreamIdentifierInternal + "|" + parameters.Get("queryString").MustString("") + startQueryInput := &cloudwatchlogs.StartQueryInput{ StartTime: aws.Int64(startTime.Unix()), EndTime: aws.Int64(endTime.Unix()), - Limit: aws.Int64(parameters.Get("limit").MustInt64(1000)), LogGroupNames: aws.StringSlice(parameters.Get("logGroupNames").MustStringArray()), - QueryString: aws.String("fields @timestamp,ltrim(@log) as " + logIdentifierInternal + ",ltrim(@logStream) as " + logStreamIdentifierInternal + "|" + parameters.Get("queryString").MustString("")), + QueryString: aws.String(modifiedQueryString), } + + if resultsLimit, err := parameters.Get("limit").Int64(); err == nil { + startQueryInput.Limit = aws.Int64(resultsLimit) + } + return logsClient.StartQueryWithContext(ctx, startQueryInput) }