Skip to content

Commit 110331d

Browse files
author
Serhii Zakharov
authored
include full timestamps in the logs (#442)
1 parent fcf1c9c commit 110331d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pkg/gatherers/clusterconfig/gather_logs.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type logMessagesFilter struct {
3737
// - containerNameRegexFilter to filter containers in the pod (keep empty to not filter)
3838
// - logMessagesFilter allows you to specify
3939
// - messagesToSearch to filter the logs by substrings (case-insensitive)
40-
// or regex (add `(?i)` in the beginning to make search case-insensitive)
40+
// or regex (add `(?i)` in the beginning to make search case-insensitive). Leave nil to not filter.
4141
// - regexSearch which makes messagesToSearch regex patterns, so you can accomplish more complicated search
4242
// - sinceSeconds which sets the moment to fetch the logs from (current time - sinceSeconds)
4343
// - limitBytes which sets the maximum amount of logs that can be fetched
@@ -85,6 +85,7 @@ func gatherLogsFromContainers(
8585
Container: container,
8686
SinceSeconds: &messagesFilter.sinceSeconds,
8787
LimitBytes: &messagesFilter.limitBytes,
88+
Timestamps: true,
8889
})
8990

9091
logs, err := filterLogs(ctx, request, messagesFilter.messagesToSearch, messagesFilter.isRegexSearch)
@@ -129,6 +130,10 @@ func filterLogs(
129130

130131
for scanner.Scan() {
131132
line := scanner.Text()
133+
if messagesToSearch == nil {
134+
result += line + "\n"
135+
}
136+
132137
for _, messageToSearch := range messagesToSearch {
133138
if regexSearch {
134139
matches, err := regexp.MatchString(messageToSearch, line)

pkg/gatherers/clusterconfig/operators_pods_and_events.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ func fetchPodContainerLog(ctx context.Context,
345345
Container: containerName,
346346
TailLines: tailLines,
347347
LimitBytes: limitBytes,
348+
Timestamps: true,
348349
})
349350
readCloser, err := req.Stream(ctx)
350351
if err != nil {

0 commit comments

Comments
 (0)