fluent-operator icon indicating copy to clipboard operation
fluent-operator copied to clipboard

[Question] Change operator log level

Open sergiomcalzada opened this issue 2 years ago • 9 comments

Describe the issue

Is there any option to configure the operator log level?

For example, to reduce this kind of logs

1.6768157667830777e+09 INFO controllers.FluentBitConfig Fluent Bit main configuration has updated {"logging-control-plane": "fluent", "fluentbitconfig": "fluentbit-config", "secret": "fluentbit-config"}

How did you install fluent operator?

Helm chart

Additional context

No response

sergiomcalzada avatar Feb 20 '23 13:02 sergiomcalzada

1.6768157667830777e+09 INFO controllers.FluentBitConfig Fluent Bit main configuration has updated {"logging-control-plane": "fluent", "fluentbitconfig": "fluentbit-config", "secret": "fluentbit-config"}

Configuration changes are important information that doesn't occur a lot, so setting it to info level is ok https://github.com/fluent/fluent-operator/blob/master/controllers/fluentdconfig_controller.go#L218

benjaminhuo avatar Feb 23 '23 06:02 benjaminhuo

Hi,

I don't mean change the notification from INFO to other logging level, I mean to don't print "INFO" logs to console. That is changing the global log-level that is output to console

Kind regards, Sergio

sergiomcalzada avatar Feb 23 '23 09:02 sergiomcalzada

Hi,

I don't mean change the notification from INFO to other logging level, I mean to don't print "INFO" logs to console. That is changing the global log-level that is output to console

Kind regards, Sergio

Sorry, I don't get it. K8s applications always output logs to stdout and logging agent usually collect k8s app logs from stdout.

@wanjunlei

benjaminhuo avatar Feb 23 '23 09:02 benjaminhuo

Hi,

I don't mean to don't print to console. Let me try to recap how log usually works.

  • You have a "logging" service that writes to console (or other outputs)
  • You write lines of logs with certain level
    • log.info / log.Error / log.Warn (and so on)
  • There is global log level setting
    • if the global log level is greater that the log-level of the message the the message is print if no, it isn't

For example

r.Log.Info("Fluentd main configuration has updated", "logging-control-plane", fd.Namespace, "fd", fd.Name, "secret", secName)

If the global log level is "INFO / DEBUG" the message is printed to console if the global log level is "WARM / ERROR" the message isn't printed to console

sergiomcalzada avatar Feb 23 '23 09:02 sergiomcalzada

Hi,

I don't mean to don't print to console. Let me try to recap how log usually works.

  • You have a "logging" service that writes to console (or other outputs)

  • You write lines of logs with certain level

    • log.info / log.Error / log.Warn (and so on)
  • There is global log level setting

    • if the global log level is greater that the log-level of the message the the message is print if no, it isn't

For example

r.Log.Info("Fluentd main configuration has updated", "logging-control-plane", fd.Namespace, "fd", fd.Name, "secret", secName)

If the global log level is "INFO / DEBUG" the message is printed to console if the global log level is "WARM / ERROR" the message isn't printed to console

Use --zap-log-level to set the log level.

wanjunlei avatar Feb 23 '23 09:02 wanjunlei

If the global log level is "INFO / DEBUG" the message is printed to console if the global log level is "WARM / ERROR" the message isn't printed to console

Got you, I think @wanjunlei answered your question

benjaminhuo avatar Feb 23 '23 09:02 benjaminhuo

Hi, Yes and no. I know that a setting exists, but would like how to set the setting in the chart

thanks in advance

sergiomcalzada avatar Feb 23 '23 09:02 sergiomcalzada

It is currently impossible to set it in the helm chart.

wanjunlei avatar Feb 23 '23 09:02 wanjunlei

Tested manually with the following code and it works

      containers:
        - name: fluent-operator
          image: kubesphere/fluent-operator:v2.0.0
          args:
          - "--zap-log-level=error"

Would be good to have a feature to set custom args (also custom environment variables) to the operator.

Thank you very much for your work

sergiomcalzada avatar Feb 23 '23 09:02 sergiomcalzada