Skip to content

Use structured logging everywhere #113

Open
@astefanutti

Description

@astefanutti

The operator pod logs contain unstructured statements like:

I0530 13:59:55.649049 1 request.go:690] Waited for 1.040481717s due to client-side throttling, not priority and fairness, request: GET:https://172.30.0.1:443/apis/cloud.network.openshift.io/v1?timeout=32s

Or:

I0530 13:59:57.605555 1 leaderelection.go:248] attempting to acquire leader lease openshift-operators/5a3ca514.codeflare.dev...
E0530 14:00:57.607293 1 leaderelection.go:330] error retrieving resource lock openshift-operators/5a3ca514.codeflare.dev: the server was unable to return a response in the time allotted, but may still be processing the request (get leases.coordination.k8s.io 5a3ca514.codeflare.dev)
E0530 14:02:01.484918 1 leaderelection.go:330] error retrieving resource lock openshift-operators/5a3ca514.codeflare.dev: the server was unable to return a response in the time allotted, but may still be processing the request (get leases.coordination.k8s.io 5a3ca514.codeflare.dev)
E0530 14:04:16.991007 1 leaderelection.go:330] error retrieving resource lock openshift-operators/5a3ca514.codeflare.dev: Get "https://172.30.0.1:443/apis/coordination.k8s.io/v1/namespaces/openshift-operators/leases/5a3ca514.codeflare.dev": dial tcp 172.30.0.1:443: connect: connection refused - error from a previous attempt: unexpected EOF
E0530 14:04:19.050293 1 leaderelection.go:330] error retrieving resource lock openshift-operators/5a3ca514.codeflare.dev: Get "https://172.30.0.1:443/apis/coordination.k8s.io/v1/namespaces/openshift-operators/leases/5a3ca514.codeflare.dev": dial tcp 172.30.0.1:443: connect: connection refused
I0530 14:04:49.264891 1 leaderelection.go:258] successfully acquired lease openshift-operators/5a3ca514.codeflare.dev

These come from components that rely on klog, which isn't configured to use the correct logging backend.

Also, klog CLI option flags should be bound, so it's possible, for example, to turn on JSON output for easier parsing by downstream log management tools.

Some information about Kubernetes structured logging can be found at https://kubernetes.io/blog/2020/09/04/kubernetes-1-19-introducing-structured-logs/.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions