From 1ec5963cd18cd70b6aabe5fe70ab3734dd9f3307 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Wed, 11 Jul 2018 00:38:16 +1000 Subject: Templated logback configuration prototype Change-Id: I980e50f49643e24a87793ebfe31570cc513ebe45 Signed-off-by: Luke Parker Issue-ID: LOG-560 --- reference/provider/helm/log4j/placeholder.txt | 0 reference/provider/helm/log4jv1/placeholder.txt | 0 reference/provider/helm/logback/README.MD | 51 ++++ reference/provider/helm/logback/chart/Chart.yaml | 4 + .../helm/logback/chart/resources/logback.xml | 282 +++++++++++++++++++++ .../helm/logback/chart/templates/configmap.yaml | 7 + reference/provider/helm/logback/chart/values.yaml | 35 +++ .../provider/helm/logback/test/placeholder.txt | 0 8 files changed, 379 insertions(+) create mode 100644 reference/provider/helm/log4j/placeholder.txt create mode 100644 reference/provider/helm/log4jv1/placeholder.txt create mode 100644 reference/provider/helm/logback/README.MD create mode 100644 reference/provider/helm/logback/chart/Chart.yaml create mode 100644 reference/provider/helm/logback/chart/resources/logback.xml create mode 100644 reference/provider/helm/logback/chart/templates/configmap.yaml create mode 100644 reference/provider/helm/logback/chart/values.yaml create mode 100644 reference/provider/helm/logback/test/placeholder.txt (limited to 'reference') diff --git a/reference/provider/helm/log4j/placeholder.txt b/reference/provider/helm/log4j/placeholder.txt new file mode 100644 index 0000000..e69de29 diff --git a/reference/provider/helm/log4jv1/placeholder.txt b/reference/provider/helm/log4jv1/placeholder.txt new file mode 100644 index 0000000..e69de29 diff --git a/reference/provider/helm/logback/README.MD b/reference/provider/helm/logback/README.MD new file mode 100644 index 0000000..4da2d43 --- /dev/null +++ b/reference/provider/helm/logback/README.MD @@ -0,0 +1,51 @@ +# Overview + +This is an example of logback configuration templated for use with Helm. + +It provides: + +1. Boilerplate for configuring several appenders: + 1. Beats - machine-readable, tab-separated, fully escaped file. + 2. Console - somewhat human-readable (no tab or newline replacement in messages or stacktraces). + 3. EELF - legacy format, output sorted into several files. + 4. Syslog - Logstash-compatible network transport. +2. Values-based activation/deactivation of each appender. +3. Values-based configuration of root loglevels. +4. Values-based configuration of individual loggers and their loglevels. +5. Values-based configuration of queue lengths, rollover, reconfiguration intervals, etc. + +# Installation + +From ```./charts```, run: + +``` +helm install . +``` + +# Configuration + +Via ```values.yaml```. + +* ```componentName``` and ```subcomponentName``` always customized. These determine the output directory for files appenders. (And must therefore be unique per container, and also per deployment). +* Everything else customized only as necessary. + +# Status + +Before this can be made available generally available: + +1. Discussion: + 1. Is this the right idea? + 2. Is this the right way to parameterize logging configuration? + 3. What can be done better? + 1. What should be parametrized by isn't? + 2. What is parameterized needlessly (i.e. providing a degree of configurability we don't want to support)? +2. Log4j (v1.X and v2.X) equivalents. +3. Test scenarios in this directory: + 1. Write some logs within the container. + 2. Parse the logs to verify that they're as expected. + 3. Run the same tests for each logging provider. + +It doesn't: + +1. Provide appender-specific logger-to-level mappings. Each logger gets the same level for each appender. +2. Define globals, or nececssarily fit into the nascent scheme for OOM helm chart parameterization. diff --git a/reference/provider/helm/logback/chart/Chart.yaml b/reference/provider/helm/logback/chart/Chart.yaml new file mode 100644 index 0000000..0795196 --- /dev/null +++ b/reference/provider/helm/logback/chart/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +name: logdemo +version: 1.0.0 +description: whatever diff --git a/reference/provider/helm/logback/chart/resources/logback.xml b/reference/provider/helm/logback/chart/resources/logback.xml new file mode 100644 index 0000000..eecd13d --- /dev/null +++ b/reference/provider/helm/logback/chart/resources/logback.xml @@ -0,0 +1,282 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${consolePattern} + + + + + ${queueSize} + + + + + + + ${beatsLogDirectory}/${beatsLogFilename}.log + + ${beatsLogDirectory}/${beatsLogFilename}.%i.log.%d + ${maxFileSize} + ${maxHistory} + ${totalSizeCap} + + + ${beatsPattern} + + + + + ${queueSize} + + + + + + + {{default "localhost" .Values.log.syslog.host}} + {{default "514" .Values.log.syslog.port}} + {{default "USER" .Values.log.syslog.facility}} + + + + ${queueSize} + + + + + + + + + ${eelfLogDirectory}/${eelfAuditLogName}.log + + ${eelfLogDirectory}/${eelfAuditLogName}.%i.log.%d + ${maxFileSize} + ${maxHistory} + ${totalSizeCap} + + + ${eelfAuditPattern} + + + + + ${queueSize} + + + + + + + ${eelfLogDirectory}/${eelfMetricsLogName}.log + + ${eelfLogDirectory}/${eelfMetricsLogName}.%i.log.%d + ${maxFileSize} + ${maxHistory} + ${totalSizeCap} + + + ${eelfMetricsPattern} + + + + + ${queueSize} + + + + + + + ${eelfLogDirectory}/${eelfDebugLogName}.log + + ${eelfLogDirectory}/${eelfDebugLogName}.%i.log.%d + ${maxFileSize} + ${maxHistory} + ${totalSizeCap} + + + ${eelfDebugPattern} + + + + + ${queueSize} + + + + + + + ${eelfLogDirectory}/${eelfErrorLogName}.log + + ${eelfLogDirectory}/${eelfErrorLogName}.%i.log.%d + ${maxFileSize} + ${maxHistory} + ${totalSizeCap} + + + ${eelfErrorPattern} + + + + + ${queueSize} + + + + + + + ${eelfLogDirectory}/${eelfApplicationLogName}.log + + ${eelfLogDirectory}/${eelfApplicationLogName}.%i.log.%d + ${maxFileSize} + ${maxHistory} + ${totalSizeCap} + + + ${eelfApplicationPattern} + + + + + ${queueSize} + + + + + + + + + + + {{if .Values.log.root.eelf}} + + + + + + + + + + + + + + + + {{ end }} + + + + + {{ if .Values.log.root.beats }} + + {{ end }} + {{ if .Values.log.root.console }} + + {{ end }} + {{ if .Values.log.root.eelf }} + + {{ end }} + + + + + {{- range .Values.log.loggers }} + + {{ if .beats }} + + {{ end }} + {{ if .console }} + + {{ end }} + {{ if .syslog }} + + {{ end }} + {{ if .eelf }} + + {{ end }} + + {{- end}} + + diff --git a/reference/provider/helm/logback/chart/templates/configmap.yaml b/reference/provider/helm/logback/chart/templates/configmap.yaml new file mode 100644 index 0000000..0122bd4 --- /dev/null +++ b/reference/provider/helm/logback/chart/templates/configmap.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: logback-configmap + namespace: {{ .Values.nsPrefix }} +data: +{{ tpl (.Files.Glob "resources/*").AsConfig . | indent 2 }} diff --git a/reference/provider/helm/logback/chart/values.yaml b/reference/provider/helm/logback/chart/values.yaml new file mode 100644 index 0000000..2db0e99 --- /dev/null +++ b/reference/provider/helm/logback/chart/values.yaml @@ -0,0 +1,35 @@ +log: + + componentName: c1 + subcomponentName: s1 + + debug: true + + scan: + enabled: true + seconds: 60 + + serverName: ${HOSTNAME} + logDir: /var/log/onap + maxFileSize: 50MB + maxHistory: 50 + totalSizeCap: 20GB + queueSize: 256 + + syslog: + host: localhost + port: 514 + facility: USER + + root: + level: INFO + beats: true + console: true + syslog: false + eelf: false + + # loggers: + # - name: org.onap.logging.helm.test + # level: DEBUG + # beats: true + # console: true diff --git a/reference/provider/helm/logback/test/placeholder.txt b/reference/provider/helm/logback/test/placeholder.txt new file mode 100644 index 0000000..e69de29 -- cgit 1.2.3-korg