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

Add support for JSON output format for logs #1974

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

Karthik-K-N
Copy link
Contributor

@Karthik-K-N Karthik-K-N commented Sep 24, 2024

What this PR does / why we need it:

Most of the core components of cluster-api supports JSON output format for logs and capi is planning to make json output format for logs as default in future releases rather than having text output format like now.
This PR adds support for the same in cluster-api-provider-ibmcloud repository, This will help in easy parsing of logs in obervability tools.

User needs to pass additional flag --logging-format=json to set the output log format to JSON

Default text format log output

I0923 08:58:50.656130       1 reflector.go:302] Stopping reflector *v1beta2.IBMVPCMachineTemplate (10m27.692803049s) from pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:232
I0923 08:58:50.660508       1 reflector.go:302] Stopping reflector *v1beta2.IBMPowerVSMachineTemplate (9m52.646239995s) from pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:232
I0923 08:58:50.666075       1 internal.go:541] "Stopping and waiting for webhooks"
I0923 08:58:50.669962       1 server.go:249] "Shutting down webhook server with timeout of 1 minute" logger="controller-runtime.webhook"
I0923 08:58:50.672521       1 internal.go:544] "Stopping and waiting for HTTP servers"
I0923 08:58:50.673560       1 server.go:254] "Shutting down metrics server with timeout of 1 minute" logger="controller-runtime.metrics"
I0923 08:58:50.673729       1 server.go:68] "shutting down server" name="health probe" addr="[::]:9440"
I0923 08:58:50.673822       1 internal.go:548] "Wait completed, proceeding to shutdown the manager"

Log format when JSON output format is set

{"ts":1727081930843.5164,"logger":"controller-runtime.metrics","caller":"server/server.go:247","msg":"Serving metrics server","v":0,"bindAddress":":8443","secure":true}
{"ts":1727081934322.6074,"caller":"leaderelection/leaderelection.go:367","msg":"lock is held by capi-ibmcloud-controller-manager-7d574bbf58-ptbqk_4eaa0a09-0efc-4bd1-95f2-ae84e4ac9f47 and has not yet expired","v":4}
{"ts":1727081934322.689,"caller":"leaderelection/leaderelection.go:255","msg":"failed to acquire lease capi-ibmcloud-system/effcf9b8.cluster.x-k8s.io","v":4}
{"ts":1727081936795.2607,"caller":"leaderelection/leaderelection.go:367","msg":"lock is held by capi-ibmcloud-controller-manager-7d574bbf58-ptbqk_4eaa0a09-0efc-4bd1-95f2-ae84e4ac9f47 and has not yet expired","v":4}
{"ts":1727081936795.3213,"caller":"leaderelection/leaderelection.go:255","msg":"failed to acquire lease capi-ibmcloud-system/effcf9b8.cluster.x-k8s.io","v":4}
{"ts":1727081941185.4644,"caller":"leaderelection/leaderelection.go:367","msg":"lock is held by capi-ibmcloud-controller-manager-7d574bbf58-ptbqk_4eaa0a09-0efc-4bd1-95f2-ae84e4ac9f47 and has not yet expired","v":4}

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

/area provider/ibmcloud

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:

Add support for JSON output format for logs

@k8s-ci-robot k8s-ci-robot added the area/provider/ibmcloud Issues or PRs related to ibmcloud provider label Sep 24, 2024
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 24, 2024
Copy link

netlify bot commented Sep 24, 2024

Deploy Preview for kubernetes-sigs-cluster-api-ibmcloud ready!

Name Link
🔨 Latest commit f43fbfe
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-ibmcloud/deploys/66f262a7cdc06f0008253d78
😎 Deploy Preview https://deploy-preview-1974--kubernetes-sigs-cluster-api-ibmcloud.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Karthik-K-N Karthik-K-N force-pushed the update-log branch 2 times, most recently from 3831985 to 21aa771 Compare September 24, 2024 05:30
@mkumatag
Copy link
Member

@Karthik-K-N can you please update the description with the details like what additional flags it will add and how users can use them and also sample logs post applying this option?

main.go Outdated Show resolved Hide resolved
Copy link
Contributor

@Amulyam24 Amulyam24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 25, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Karthik-K-N, mkumatag

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 25, 2024
@k8s-ci-robot k8s-ci-robot merged commit 57394ba into kubernetes-sigs:main Sep 25, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/provider/ibmcloud Issues or PRs related to ibmcloud provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants