kyverno / kyverno

Cloud Native Policy Management
https://kyverno.io
Apache License 2.0
5.38k stars 806 forks source link

[Enhancement] Reduce logs when set to level 1 #9581

Open crhuber opened 5 months ago

crhuber commented 5 months ago

Kyverno Version

1.11.4

Description

I have kyverno admission controller started with the following args

 containers:
  - args:
    - --loggingFormat=json
    - --v=1

Docs say https://kyverno.io/docs/installation/customization/#container-flags "Sets the verbosity level of Kyverno log output. Takes an integer from 1 to 6 with 6 being the most verbose. Level 4 shows variable substitution messages."

Even at verbosity 1 we are getting many info messages like

{"level":"info","ts":1706704201.6543248,"logger":"klog","caller":"events/event_broadcaster.go:338","msg":"Event occurred","object":{"name":"add-cronjobs-preference"},"kind":"ClusterPolicy","apiVersion":"kyverno.io/v1","type":"Normal","reason":"PolicyApplied","action":"Resource Mutated","note":"Job xyz is successfully mutated"}

We dont need this level of logging everytime there is a mutation so how do we only get logs for error?

Slack discussion

No response

Troubleshooting

chipzoller commented 5 months ago

There's no logging for only errors. If level 1 is still too high, you can set to 0 to disable the logging.

Pushkarm029 commented 5 months ago

How many logs should we expect at level 1? let's suppose this log

{"level":"info","ts":1706704201.6543248,"logger":"klog","caller":"events/event_broadcaster.go:338","msg":"Event occurred","object":{"name":"add-cronjobs-preference"},"kind":"ClusterPolicy","apiVersion":"kyverno.io/v1","type":"Normal","reason":"PolicyApplied","action":"Resource Mutated","note":"Job xyz is successfully mutated"}

Manoramsharma commented 3 months ago

HI @chipzoller can I work on this issue. Can I know how many logs exactly we should expect at level 1?

chipzoller commented 3 months ago

Probably not a good issue for a beginner.