Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse_klog always parse the timestamp as UTC timezone #471

Open
Leo1003 opened this issue Sep 23, 2023 · 3 comments
Open

parse_klog always parse the timestamp as UTC timezone #471

Leo1003 opened this issue Sep 23, 2023 · 3 comments

Comments

@Leo1003
Copy link
Contributor

Leo1003 commented Sep 23, 2023

The logs outputs from kubelet are emitted with local timezone timestamp, however, the parse_klog() (and maybe also parse_glog()) function always parses them as UTC timestamp. This leads to hours of time shifting in the parsed log.

@jszwedko
Copy link
Member

Hi @Leo1003 !

Could you give an example log message including the timestamp?

@Leo1003
Copy link
Contributor Author

Leo1003 commented Oct 11, 2023

The following logs is generated from kubelet. The timestamp is based on the machine's timezone (Asia/Taipei UTC+8)

E1011 10:11:03.249539    5813 summary_sys_containers.go:83] "Failed to get system container stats" err="failed to get cgroup stats for \"/system.slice/kubelet.service\": failed to get container info for \"/system.slice/kubelet.service\": unknown container \"/system.slice/kubelet.service\"" containerName="/system.slice/kubelet.service"

According to the docs the timezone settings should default to the local timezone.

However, the parsed result is:

{ "file": "summary_sys_containers.go", "id": 5813, "level": "error", "line": 83, "message": "\"Failed to get system container stats\" err=\"failed to get cgroup stats for \\\"/system.slice/kubelet.service\\\": failed to get container info for \\\"/system.slice/kubelet.service\\\": unknown container \\\"/system.slice/kubelet.service\\\"\" containerName=\"/system.slice/kubelet.service\"", "timestamp": t'2023-10-11T10:11:03.249539Z' }

The parsed timestamp is 2023-10-11T10:11:03.249539Z, which is shifted 8 hours.


Note: klog uses time.Now()source and time.Clock()source.

@jszwedko
Copy link
Member

Perfect, thanks for sharing that! As a workaround you could try using the timezone parameter on the remap transform where you are calling this VRL function. I'm not sure if that will definitely work, but something to try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants