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

[Bug]: logFormat=json creates events without contextual information #7574

Open
hafe opened this issue Mar 28, 2025 · 5 comments
Open

[Bug]: logFormat=json creates events without contextual information #7574

hafe opened this issue Mar 28, 2025 · 5 comments
Labels
bug An issue reporting a potential bug needs more info Issues that require more information needs triage An issue that needs to be triaged

Comments

@hafe
Copy link
Contributor

hafe commented Mar 28, 2025

Version

edge

What Kubernetes platforms are you running on?

Kind

Steps to reproduce

No file and line present in NIC logs when logFormat is "json". File and line are present when "glog" is configured.

Structured logging in JSON is nice but without file and line it is not very practial to use.

@hafe hafe added bug An issue reporting a potential bug needs triage An issue that needs to be triaged labels Mar 28, 2025
Copy link

Hi @hafe thanks for reporting!

Be sure to check out the docs and the Contributing Guidelines while you wait for a human to take a look at this 🙂

Cheers!

@vepatel
Copy link
Contributor

vepatel commented Mar 28, 2025

@hafe Can you please provide exact repro steps for this please with the event you're observing in logs?

@vepatel vepatel added the needs more info Issues that require more information label Mar 28, 2025
@hafe
Copy link
Contributor Author

hafe commented Mar 28, 2025

just switched logFormat from glog to json and file/line is no longer present in log messages

@hafe
Copy link
Contributor Author

hafe commented Mar 30, 2025

Example with glog:

I0330 07:06:24.132037 1 leaderelection.go:257] attempting to acquire leader lease default/nic-nginx-ingress-leader-election...
I20250330 07:06:24.140270 1 service.go:26] Adding service: kubernetes
I20250330 07:06:24.140661 1 service.go:26] Adding service: nic-nginx-ingress-controller
I20250330 07:06:24.140742 1 service.go:26] Adding service: kube-dns
I20250330 07:06:24.232862 1 service.go:142] Syncing service default/nic-nginx-ingress-controller
I20250330 07:06:24.472901 1 main.go:102] Event(v1.ObjectReference{Kind:"ConfigMap", Namespace:"default", Name:"nic-nginx-ingress", UID:"e7afc234-0c83-4e1a-b570-386c1cb67235", APIVersion:"v1", ResourceVersion:"561", FieldPath:""}): type: 'Normal' reason: 'Updated' ConfigMap default/nic-nginx-ingress updated without error
I0330 07:06:59.678082 1 leaderelection.go:271] successfully acquired lease default/nic-nginx-ingress-leader-election

Example with json:

I0330 07:03:07.868148 1 leaderelection.go:257] attempting to acquire leader lease default/nic-nginx-ingress-leader-election...
{"time":"2025-03-30T07:03:07.875732211Z","level":"INFO","msg":"Adding service: kubernetes"}
{"time":"2025-03-30T07:03:07.87576521Z","level":"INFO","msg":"Adding service: nic-nginx-ingress-controller"}
{"time":"2025-03-30T07:03:07.875813377Z","level":"INFO","msg":"Adding service: kube-dns"}
{"time":"2025-03-30T07:03:07.96753629Z","level":"INFO","msg":"Syncing service default/nic-nginx-ingress-controller"}
{"time":"2025-03-30T07:03:08.186180215Z","level":"INFO","msg":"Event(v1.ObjectReference{Kind:"ConfigMap", Namespace:"default", Name:"nic-nginx-ingress", UID:"e7afc234-0c83-4e1a-b570-386c1cb67235", APIVersion:"v1", ResourceVersion:"561", FieldPath:""}): type: 'Normal' reason: 'Updated' ConfigMap default/nic-nginx-ingress updated without error"}
I0330 07:03:45.948189 1 leaderelection.go:271] successfully acquired lease default/nic-nginx-ingress-leader-election

No file and line and leader election still uses glog it seems

@AlexFenlon
Copy link
Contributor

Hi @hafe ,

Thank you for the update on this, we will investigate this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue reporting a potential bug needs more info Issues that require more information needs triage An issue that needs to be triaged
Projects
None yet
Development

No branches or pull requests

3 participants