Skip to content

Commit

Permalink
Update clients/pkg/promtail/targets/azureeventhubs/parser.go
Browse files Browse the repository at this point in the history
Co-authored-by: Trevor Whitney <[email protected]>
  • Loading branch information
andriikushch and trevorwhitney committed Oct 29, 2024
1 parent cc1601e commit 471c63b
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions clients/pkg/promtail/targets/azureeventhubs/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 471c63b

Please sign in to comment.