Skip to content

Commit 85bc080

Browse files
authored
Updates the timezone to utc for tcplog receiver (#957)
* chore: updates the timezone to utc for tcplog receiver * chore: lint
1 parent f467f1c commit 85bc080

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/collector/otel_collector_plugin.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ const (
3333
// 2024-11-06T17:19:24+00:00 ---> Nov 6 17:19:24
3434
// 2024-11-16T17:19:24+00:00 ---> Nov 16 17:19:24
3535
timestampConversionExpression = `'EXPR(let timestamp = split(split(body, ">")[1], " ")[0]; ` +
36-
`let newTimestamp = timestamp matches "(\\d{4})-(\\d{2})-(0\\d{1})T(\\d{2}):(\\d{2}):(\\d{2}).*" ` +
37-
`? date(timestamp).Format("Jan 2 15:04:05") : date(timestamp).Format("Jan 02 15:04:05"); ` +
36+
`let newTimestamp = ` +
37+
`timestamp matches "(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})([+-]\\d{2}:\\d{2}|Z)" ` +
38+
`? (let utcTime = ` +
39+
`date(timestamp).UTC(); utcTime.Format("Jan 2 15:04:05")) : date(timestamp).Format("Jan 02 15:04:05"); ` +
3840
`split(body, ">")[0] + ">" + newTimestamp + " " + split(body, " ", 2)[1])'`
3941
)
4042

0 commit comments

Comments
 (0)