Skip to content
Snippets Groups Projects
Verified Commit 4d8c9701 authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

Make checker deposit output their log as json records by default

Refs. swh/infra/sysadm-environment#4886
parent aa1516b9
No related branches found
No related tags found
No related merge requests found
{{ if .Values.checker_deposit.enabled -}}
{{- $deployment_config := .Values.checker_deposit -}}
{{- $use_json_logger := get $deployment_config "useJsonLogger" | default true }}
{{ $log_level := get $deployment_config "logLevel" | default "INFO" | quote }}
---
apiVersion: v1
kind: ConfigMap
......@@ -35,4 +38,41 @@ data:
> $CONFIG_FILE
exit 0
{{ if $use_json_logger }}
logging-configuration.yml: |
version: 1
handlers:
console:
class: logging.StreamHandler
formatter: json
stream: ext://sys.stdout
formatters:
json:
class: pythonjsonlogger.jsonlogger.JsonFormatter
# python-json-logger parses the format argument to get the variables it actually expands into the json
format: "%(asctime)s:%(threadName)s:%(pathname)s:%(lineno)s:%(funcName)s:%(task_name)s:%(task_id)s:%(name)s:%(levelname)s:%(message)s"
loggers:
celery:
level: {{ $log_level }}
amqp:
level: WARNING
urllib3:
level: WARNING
azure.core.pipeline.policies.http_logging_policy:
level: WARNING
swh:
level: {{ $log_level }}
celery.task:
level: {{ $log_level }}
root:
level: {{ $log_level }}
handlers:
- console
{{ end }}
{{ end }}
{{- $deployment_config := .Values.checker_deposit -}}
{{ if $deployment_config.enabled -}}
{{- $configurationChecksum := include (print $.Template.BasePath "/checker-deposit/configmap.yaml") . -}}
{{- $use_json_logger := get $deployment_config "useJsonLogger" | default true }}
---
apiVersion: apps/v1
kind: Deployment
......@@ -105,6 +106,10 @@ spec:
value: {{ get $deployment_config "logLevel" | default "INFO" | quote }}
- name: SWH_CONFIG_FILENAME
value: /etc/swh/config.yml
{{ if $use_json_logger }}
- name: SWH_LOG_CONFIG
value: /etc/swh/logging-configuration.yml
{{ end }}
- name: SWH_SENTRY_ENVIRONMENT
value: {{ $.Values.sentry.environment }}
- name: SWH_MAIN_PACKAGE
......@@ -122,6 +127,12 @@ spec:
subPath: "pre-stop.sh"
- name: configuration
mountPath: /etc/swh
{{ if $use_json_logger }}
- name: configuration-template
mountPath: /etc/swh/logging-configuration.yml
subPath: "logging-configuration.yml"
readOnly: true
{{ end }}
volumes:
- name: configuration
emptyDir: {}
......@@ -134,6 +145,10 @@ spec:
path: "config.yml.template"
- key: "init-container-entrypoint.sh"
path: "init-container-entrypoint.sh"
{{ if $use_json_logger }}
- key: "logging-configuration.yml"
path: "logging-configuration.yml"
{{ end }}
- name: checker-deposit-utils
configMap:
name: checker-deposit-utils
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment