Skip to content

Commit 650a7a0

Browse files
committed
fix: add log4j configmap for radar-fitbit-connector to be used by strimzi
1 parent e9756d6 commit 650a7a0

File tree

4 files changed

+63
-2
lines changed

4 files changed

+63
-2
lines changed

charts/radar-fitbit-connector-strimzi/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,7 @@ A Helm chart for RADAR-base fitbit Kafka connector using the Strimzi Operator. T
8989
| fitbit_user_poll_interval | int | `5000` | Polling interval per Fitbit user per request route in seconds. Only use to speed up processing times during e2e testing. |
9090
| application_loop_interval_ms | int | `300000` | How often to perform the main application loop (only controls how often to poll for new user registrations). Only use to speed up processing times during e2e testing. |
9191
| user_cache_refresh_interval_ms | int | `3600000` | How often to invalidate the cache and poll for new user registrations. Only use to speed up processing times during e2e testing. |
92+
| log4j | object | `{"rootLogLevel":"INFO"}` | Log4j configuration |
93+
| log4j.rootLogLevel | string | `"INFO"` | Root log level for the Kafka Connect instance |
94+
| sentry.dsn | string | `nil` | DSN (Data Source Name) of the sentry server |
95+
| sentry.level | string | `"ERROR"` | Log level for sentry (TRACE, DEBUG, INFO, WARN, or ERROR) |
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This approach allows to specify dynamic logging configuration for Kafka Connect through an external logging section of KafkaConnect resource specification.
2+
# See: https://strimzi.io/docs/operators/0.45.1/configuring#property-kafka-connect-logging-reference
3+
apiVersion: v1
4+
kind: ConfigMap
5+
metadata:
6+
name: {{ template "common.names.fullname" . }}-log4j
7+
namespace: {{ include "common.names.namespace" . | quote }}
8+
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
9+
{{- if .Values.commonAnnotations }}
10+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
11+
{{- end }}
12+
data:
13+
log4j.properties: |-
14+
# Root logger configuration
15+
# The sentryAppender is added to the rootLogger if SENTRY_DSN is set
16+
log4j.rootLogger=${env:CONNECT_LOG4J_ROOT_LOGLEVEL:-INFO}, stdout${env:SENTRY_DSN:+, sentryAppender}
17+
18+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
19+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
20+
log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c)%n
21+
22+
# Appender for Sentry monitoring, only active if SENTRY_DSN is set
23+
log4j.appender.sentryAppender=io.sentry.log4j.SentryAppender
24+
log4j.appender.sentryAppender.threshold=${env:SENTRY_LOG_LEVEL:-ERROR}
25+
26+
# Default log levels
27+
log4j.logger.org.reflections=ERROR
28+
log4j.logger.org.I0Itec.zkclient=ERROR

charts/radar-fitbit-connector-strimzi/templates/kafka-connect.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ spec:
4747
pod:
4848
metadata:
4949
annotations:
50+
checksum/configmap-log4j: {{ include (print $.Template.BasePath "/configmap-log4j.yaml") . | sha256sum }}
5051
backup.velero.io/backup-volumes: logs
5152
labels:
5253
app.kubernetes.io/name: {{ include "radar-fitbit-connector-strimzi.name" . }}
@@ -85,18 +86,34 @@ spec:
8586
tolerations:
8687
{{- toYaml . | nindent 8 }}
8788
{{- end }}
89+
volumes:
90+
- name: config-log4j
91+
configMap:
92+
name: {{ include "radar-fitbit-connector-strimzi.fullname" . }}-log4j
8893
containers:
8994
securityContext:
9095
{{- toYaml .Values.securityContext | nindent 12 }}
9196
connectContainer:
9297
env:
9398
- name: CONNECT_REST_ADVERTISED_HOST_NAME # Possibly replaced by ADVERTISED_HOSTNAME in kafka_connect_run.sh
9499
value: {{ include "radar-fitbit-connector-strimzi.fullname" . }}
95-
- name: CONNECT_LOG4J_LOGGERS # Property used in log4j.properties.template file
96-
value: "org.reflections=ERROR"
100+
- name: CONNECT_LOG4J_ROOT_LOGLEVEL
101+
value: {{ .Values.log4j.rootLogLevel | quote }}
102+
- name: KAFKA_LOG4J_OPTS
103+
value: "-Dlog4j.configuration=file:/opt/kafka/config/log4j.properties"
104+
{{- if .Values.sentry.dsn }}
105+
- name: SENTRY_DSN
106+
value: {{ .Values.sentry.dsn | quote }}
107+
- name: SENTRY_LOG_LEVEL
108+
value: {{ .Values.sentry.level | quote }}
109+
{{- end }}
97110
{{- with .Values.extraEnvVars }}
98111
{{- toYaml . | nindent 8 }}
99112
{{- end }}
113+
volumeMounts:
114+
- name: config-log4j
115+
mountPath: /opt/kafka/config/log4j.properties
116+
subPath: log4j.properties
100117
{{- if .Values.customLivenessProbe }}
101118
livenessProbe: {{- .Values.customLivenessProbe | toYaml | nindent 12 }}
102119
{{- else if .Values.livenessProbe.enabled }}

charts/radar-fitbit-connector-strimzi/values.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,15 @@ application_loop_interval_ms: 300000
214214
# -- How often to invalidate the cache and poll for new user registrations.
215215
# Only use to speed up processing times during e2e testing.
216216
user_cache_refresh_interval_ms: 3600000
217+
218+
# -- Log4j configuration
219+
log4j:
220+
# -- Root log level for the Kafka Connect instance
221+
rootLogLevel: INFO
222+
223+
# Sentry monitoring configuration
224+
sentry:
225+
# -- DSN (Data Source Name) of the sentry server
226+
dsn:
227+
# -- Log level for sentry (TRACE, DEBUG, INFO, WARN, or ERROR)
228+
level: ERROR

0 commit comments

Comments
 (0)