From 471c63b044552c57d5ea089ae92d8849ecf786b4 Mon Sep 17 00:00:00 2001 From: andriikushch Date: Tue, 29 Oct 2024 09:05:03 +0100 Subject: [PATCH] Update clients/pkg/promtail/targets/azureeventhubs/parser.go Co-authored-by: Trevor Whitney --- .../promtail/targets/azureeventhubs/parser.go | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/clients/pkg/promtail/targets/azureeventhubs/parser.go b/clients/pkg/promtail/targets/azureeventhubs/parser.go index b93a28ffd281d..9f65b0fc83509 100644 --- a/clients/pkg/promtail/targets/azureeventhubs/parser.go +++ b/clients/pkg/promtail/targets/azureeventhubs/parser.go @@ -60,27 +60,24 @@ func (l azureMonitorResourceLog) isTimeOrTimeStampFieldSet() bool { // getTime returns time from `time` or `timeStamp` field. If both fields are set, `time` is used. If both fields are empty, error is returned. func (l azureMonitorResourceLog) getTime() (time.Time, error) { - var t time.Time - var err error - if len(l.Time) == 0 && len(l.TimeStamp) == 0 { return t, errors.New("time and timeStamp fields are empty") } - - if len(l.TimeStamp) != 0 { - t, err = time.Parse(time.RFC3339, l.TimeStamp) - if err != nil { - return t, err - } - } - + if len(l.Time) != 0 { - t, err = time.Parse(time.RFC3339, l.Time) + t, err := time.Parse(time.RFC3339, l.Time) if err != nil { return t, err } + + return t.UTC(), nil } + t, err := time.Parse(time.RFC3339, l.TimeStamp) + if err != nil { + return t, err + } + return t.UTC(), nil }