From 2cf50ffa28228d5cf736e2385ee39a3ccb6af0df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Tom=C5=A1i=C4=8D?= Date: Mon, 12 Jun 2023 15:07:34 +0200 Subject: [PATCH] matrix-synapse: Add support for structured logging --- charts/matrix-synapse/templates/configuration.yaml | 14 +++++++++++--- charts/matrix-synapse/values.yaml | 11 +++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/charts/matrix-synapse/templates/configuration.yaml b/charts/matrix-synapse/templates/configuration.yaml index 7f04dee..2afb12d 100644 --- a/charts/matrix-synapse/templates/configuration.yaml +++ b/charts/matrix-synapse/templates/configuration.yaml @@ -9,8 +9,13 @@ data: log.yaml: | version: 1 formatters: + {{- if .Values.config.useStructuredLogging }} + structured: + class: synapse.logging.TerseJsonFormatter + {{- else }} precise: - format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s- %(message)s' + format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s- %(message)s' + {{- end }} filters: context: (): synapse.util.logcontext.LoggingContextFilter @@ -18,12 +23,15 @@ data: handlers: console: class: logging.StreamHandler - formatter: precise + formatter: {{ if .Values.config.useStructuredLogging }}structured{{ else }}precise{{ end }} filters: [context] level: {{ .Values.config.logLevel | default "INFO" }} loggers: synapse: - level: {{ .Values.config.logLevel | default "INFO" }} + level: {{ .Values.config.logLevel | default "INFO" }} + {{- with .Values.extraLoggers -}} + {{ . | toYaml | nindent 8 }} + {{- end }} root: level: {{ .Values.config.logLevel | default "INFO" }} handlers: [console] diff --git a/charts/matrix-synapse/values.yaml b/charts/matrix-synapse/values.yaml index 392244e..c2467f4 100644 --- a/charts/matrix-synapse/values.yaml +++ b/charts/matrix-synapse/values.yaml @@ -140,6 +140,11 @@ config: extraMainListenerTypes: [] # - consent + ## Logging + # use TerseJsonFormatter structured logging + # Ref: https://matrix-org.github.io/synapse/latest/structured_logging.html + useStructuredLogging: false + ## Specify arbitrary Synapse configuration here; ## Ref: https://github.com/matrix-org/synapse/blob/develop/docs/sample_config.yaml ## @@ -154,6 +159,12 @@ extraConfig: {} # - syd.example.com # dynamic_thumbnails: true +## Specify additional loggers configutation here; +## Ref: https://matrix-org.github.io/synapse/latest/structured_logging.html +extraLoggers: {} +# synapse.storage.SQL: +# level: WARNING + ## Specify arbitrary - secret - Synapse configuration here; ## These values will be stored in secrets instead of configmaps ## Ref: https://github.com/matrix-org/synapse/blob/develop/docs/sample_config.yaml