mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CloudWatch Logs: "limit" query command now respected (#25486)
Closes #25182
This commit is contained in:
parent
bd44d973cd
commit
b1dee9392b
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user