From 6c77500822f28adc0740239ce0c2bf891d3de0c8 Mon Sep 17 00:00:00 2001 From: nightfury1204 Date: Tue, 2 Jul 2024 20:18:26 +0100 Subject: [PATCH] Fix apps logs --- pkg/helpers/aws.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/helpers/aws.go b/pkg/helpers/aws.go index cf1cc7c052..a1c68784e6 100644 --- a/pkg/helpers/aws.go +++ b/pkg/helpers/aws.go @@ -364,8 +364,10 @@ func CloudWatchLogsStream(ctx context.Context, cw cloudwatchlogsiface.CloudWatch var start int64 if opts.Since != nil { - start = time.Now().UTC().Add((*opts.Since)*-1).Unix() * int64(time.Microsecond) + start = time.Now().UTC().Add((*opts.Since) * -1).UnixMilli() req.StartTime = aws.Int64(start) + } else { + req.StartTime = aws.Int64(time.Now().UTC().Add(-1 * time.Hour).UnixMilli()) } if stream != "" { @@ -390,13 +392,21 @@ func CloudWatchLogsStream(ctx context.Context, cw cloudwatchlogsiface.CloudWatch if err != nil { switch AwsErrorCode(err) { case "ThrottlingException", "ResourceNotFoundException": - time.Sleep(1 * time.Second) + time.Sleep(3 * time.Second) continue default: return err } } + if res != nil { + if res.NextToken != nil { + time.Sleep(2 * time.Second) + } else if len(res.Events) == 0 { + time.Sleep(5 * time.Second) + } + } + es := []*cloudwatchlogs.FilteredLogEvent{} for _, e := range res.Events {