Skip to content

Commit

Permalink
Merge pull request #770 from ksdpmx/loglevel
Browse files Browse the repository at this point in the history
feat: add global log_level support for fluentd
  • Loading branch information
benjaminhuo committed Jun 2, 2023
2 parents 16c04ae + 6058ba3 commit 6080b20
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 2 deletions.
5 changes: 5 additions & 0 deletions apis/fluentd/v1alpha1/fluentd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ type FluentdSpec struct {
Replicas *int32 `json:"replicas,omitempty"`
// Numbers of the workers in Fluentd instance
Workers *int32 `json:"workers,omitempty"`
// Global logging verbosity
// +kubebuilder:validation:Optional
// +kubebuilder:validation:Enum:=fatal;error;warn;info;debug;trace
// +kubebuilder:default:=info
LogLevel string `json:"logLevel,omitempty"`
// Fluentd image.
Image string `json:"image,omitempty"`
// Fluentd Watcher command line arguments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,17 @@ spec:
type: object
x-kubernetes-map-type: atomic
type: array
logLevel:
default: info
description: Global logging verbosity
enum:
- fatal
- error
- warn
- info
- debug
- trace
type: string
nodeSelector:
additionalProperties:
type: string
Expand Down
3 changes: 3 additions & 0 deletions charts/fluent-operator/templates/fluentd-fluentd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ spec:
fluentdCfgSelector:
matchLabels:
config.fluentd.fluent.io/enabled: "true"
{{- if .Values.fluentd.logLevel }}
logLevel: {{ .Values.fluentd.logLevel }}
{{- end }}
{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions charts/fluent-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ fluentd:
requests:
cpu: 100m
memory: 128Mi
logLevel: ""
# Configure the output plugin parameter in Fluentd.
# Fluentd is disabled by default, if you enable it make sure to also set up an output to use.
output:
Expand Down
11 changes: 11 additions & 0 deletions config/crd/bases/fluentd.fluent.io_fluentds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,17 @@ spec:
type: object
x-kubernetes-map-type: atomic
type: array
logLevel:
default: info
description: Global logging verbosity
enum:
- fatal
- error
- warn
- info
- debug
- trace
type: string
nodeSelector:
additionalProperties:
type: string
Expand Down
4 changes: 2 additions & 2 deletions controllers/fluentdconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const (
SYSTEM = `# Enable RPC endpoint
<system>
rpc_endpoint 127.0.0.1:24444
log_level info
log_level %s
workers %d
</system>
`
Expand Down Expand Up @@ -186,7 +186,7 @@ func (r *FluentdConfigReconciler) Reconcile(ctx context.Context, req ctrl.Reques
return ctrl.Result{}, err
}

systemCfg = fmt.Sprintf(SYSTEM, workers)
systemCfg = fmt.Sprintf(SYSTEM, fd.Spec.LogLevel, workers)
}

secName := fmt.Sprintf("%s-config", fd.Name)
Expand Down
1 change: 1 addition & 0 deletions docs/fluentd.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ FluentdSpec defines the desired state of Fluentd
| disableService | By default will build the related service according to the globalinputs definition. | bool |
| replicas | Numbers of the Fluentd instance | *int32 |
| workers | Numbers of the workers in Fluentd instance | *int32 |
| logLevel | Global logging verbosity | string |
| image | Fluentd image. | string |
| args | Fluentd Watcher command line arguments. | []string |
| envVars | EnvVars represent environment variables that can be passed to fluentd pods. | []corev1.EnvVar |
Expand Down
11 changes: 11 additions & 0 deletions manifests/setup/fluent-operator-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19801,6 +19801,17 @@ spec:
type: object
x-kubernetes-map-type: atomic
type: array
logLevel:
default: info
description: Global logging verbosity
enum:
- fatal
- error
- warn
- info
- debug
- trace
type: string
nodeSelector:
additionalProperties:
type: string
Expand Down
11 changes: 11 additions & 0 deletions manifests/setup/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19801,6 +19801,17 @@ spec:
type: object
x-kubernetes-map-type: atomic
type: array
logLevel:
default: info
description: Global logging verbosity
enum:
- fatal
- error
- warn
- info
- debug
- trace
type: string
nodeSelector:
additionalProperties:
type: string
Expand Down

0 comments on commit 6080b20

Please sign in to comment.