Skip to content

Commit

Permalink
review: prefixed all logging related environment variables with `DITT…
Browse files Browse the repository at this point in the history
…O_LOGGING_`

Signed-off-by: Thomas Jaeckle <thomas.jaeckle@bosch.io>
  • Loading branch information
thjaeckle committed May 20, 2021
1 parent abef687 commit 4bddd98
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 63 deletions.
16 changes: 8 additions & 8 deletions concierge/service/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
</filter>
</appender>

<if condition='isDefined("LOGSTASH_SERVER")'>
<if condition='isDefined("DITTO_LOGGING_LOGSTASH_SERVER")'>
<then>
<appender name="stash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>${LOGSTASH_SERVER}</destination>
<destination>${DITTO_LOGGING_LOGSTASH_SERVER}</destination>

<!-- Encoder is required -->
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
Expand All @@ -43,7 +43,7 @@
</then>
</if>

<if condition='isDefined("FILE_APPENDER")'>
<if condition='isDefined("DITTO_LOGGING_FILE_APPENDER")'>
<then>
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
Expand All @@ -53,8 +53,8 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>concierge.log.%d{yyyy-MM-dd}.gz</fileNamePattern>
<!-- Keep 30 days' worth of history capped at 1GB total size -->
<maxHistory>${MAX_LOG_FILE_HISTORY_IN_DAYS:-10}</maxHistory>
<totalSizeCap>${TOTAL_LOG_FILE_SIZE:-1GB}</totalSizeCap>
<maxHistory>${DITTO_LOGGING_MAX_LOG_FILE_HISTORY_IN_DAYS:-10}</maxHistory>
<totalSizeCap>${DITTO_LOGGING_TOTAL_LOG_FILE_SIZE:-1GB}</totalSizeCap>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<customFields>{"appname":"concierge","instance_index":"${INSTANCE_INDEX}"}</customFields>
Expand All @@ -72,7 +72,7 @@

<root level="${LOG_LEVEL:-INFO}">
<!-- Logging INFO messages can be disabled by setting environment variable -->
<if condition='isNull("DISABLE_SYSOUT_LOG")'>
<if condition='isNull("DITTO_LOGGING_DISABLE_SYSOUT_LOG")'>
<then>
<appender-ref ref="STDOUT"/>
</then>
Expand All @@ -81,13 +81,13 @@
<!-- Always log ERRORs to syserr -->
<appender-ref ref="STDERR"/>

<if condition='isDefined("LOGSTASH_SERVER")'>
<if condition='isDefined("DITTO_LOGGING_LOGSTASH_SERVER")'>
<then>
<appender-ref ref="stash"/>
</then>
</if>

<if condition='isDefined("FILE_APPENDER")'>
<if condition='isDefined("DITTO_LOGGING_FILE_APPENDER")'>
<then>
<appender-ref ref="file"/>
</then>
Expand Down
16 changes: 8 additions & 8 deletions connectivity/service/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
</filter>
</appender>

<if condition='isDefined("LOGSTASH_SERVER")'>
<if condition='isDefined("DITTO_LOGGING_LOGSTASH_SERVER")'>
<then>
<appender name="stash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>${LOGSTASH_SERVER}</destination>
<destination>${DITTO_LOGGING_LOGSTASH_SERVER}</destination>

<!-- Encoder is required -->
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
Expand All @@ -43,7 +43,7 @@
</then>
</if>

<if condition='isDefined("FILE_APPENDER")'>
<if condition='isDefined("DITTO_LOGGING_FILE_APPENDER")'>
<then>
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
Expand All @@ -52,8 +52,8 @@
<file>connectivity.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>connectivity.log.%d{yyyy-MM-dd}.gz</fileNamePattern>
<maxHistory>${MAX_LOG_FILE_HISTORY_IN_DAYS:-10}</maxHistory>
<totalSizeCap>${TOTAL_LOG_FILE_SIZE:-1GB}</totalSizeCap>
<maxHistory>${DITTO_LOGGING_MAX_LOG_FILE_HISTORY_IN_DAYS:-10}</maxHistory>
<totalSizeCap>${DITTO_LOGGING_TOTAL_LOG_FILE_SIZE:-1GB}</totalSizeCap>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<customFields>{"appname":"connectivity","instance_index":"${INSTANCE_INDEX}"}</customFields>
Expand All @@ -75,7 +75,7 @@

<root level="${LOG_LEVEL:-INFO}">
<!-- Logging INFO messages can be disabled by setting environment variable -->
<if condition='isNull("DISABLE_SYSOUT_LOG")'>
<if condition='isNull("DITTO_LOGGING_DISABLE_SYSOUT_LOG")'>
<then>
<appender-ref ref="STDOUT"/>
</then>
Expand All @@ -84,13 +84,13 @@
<!-- Always log ERRORs to syserr -->
<appender-ref ref="STDERR"/>

<if condition='isDefined("LOGSTASH_SERVER")'>
<if condition='isDefined("DITTO_LOGGING_LOGSTASH_SERVER")'>
<then>
<appender-ref ref="stash"/>
</then>
</if>

<if condition='isDefined("FILE_APPENDER")'>
<if condition='isDefined("DITTO_LOGGING_FILE_APPENDER")'>
<then>
<appender-ref ref="file"/>
</then>
Expand Down
12 changes: 6 additions & 6 deletions deployment/kubernetes/deploymentFiles/ditto/ditto-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ spec:
### -
# in order to write logs into a file you can enable this by setting the following env variable
# the log file(s) can be found in /opt/ditto directory on the host machine
#- name: FILE_APPENDER
#- name: DITTO_LOGGING_FILE_APPENDER
#- value: true
volumes:
- name: ditto-log-files
Expand Down Expand Up @@ -187,7 +187,7 @@ spec:
### -
# in order to write logs into a file you can enable this by setting the following env variable
# the log file(s) can be found in /opt/ditto directory on the host machine
#- name: FILE_APPENDER
#- name: DITTO_LOGGING_FILE_APPENDER
#- value: true
volumes:
- name: ditto-log-files
Expand Down Expand Up @@ -286,7 +286,7 @@ spec:
### -
# in order to write logs into a file you can enable this by setting the following env variable
# the log file(s) can be found in /opt/ditto directory on the host machine
#- name: FILE_APPENDER
#- name: DITTO_LOGGING_FILE_APPENDER
#- value: true
volumes:
- name: ditto-log-files
Expand Down Expand Up @@ -384,7 +384,7 @@ spec:
### -
# in order to write logs into a file you can enable this by setting the following env variable
# the log file(s) can be found in /opt/ditto directory on the host machine
#- name: FILE_APPENDER
#- name: DITTO_LOGGING_FILE_APPENDER
#- value: true
volumes:
- name: ditto-log-files
Expand Down Expand Up @@ -481,7 +481,7 @@ spec:
# key: mongodb-uri
# in order to write logs into a file you can enable this by setting the following env variable
# the log file(s) can be found in /opt/ditto directory on the host machine
#- name: FILE_APPENDER
#- name: DITTO_LOGGING_FILE_APPENDER
#- value: true
volumes:
- name: ditto-log-files
Expand Down Expand Up @@ -572,7 +572,7 @@ spec:
value: "-Xgcpolicy:gencon -Xgc:concurrentScavenge -XX:+IdleTuningGcOnIdle -XX:+ExitOnOutOfMemoryError -Xtune:virtualized -Xss512k -XX:MaxRAMPercentage=80 -Dakka.coordinated-shutdown.exit-jvm=on -Dakka.cluster.shutdown-after-unsuccessful-join-seed-nodes=120s"
# in order to write logs into a file you can enable this by setting the following env variable
# the log file(s) can be found in /opt/ditto directory on the host machine
#- name: FILE_APPENDER
#- name: DITTO_LOGGING_FILE_APPENDER
#- value: true
volumes:
- name: ditto-log-files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,24 +163,28 @@ ssl-config {

Gathering logs for a running Ditto installation can be achieved by:

* grepping log output from STDOUT/STDERR via Docker's [logging drivers](https://docs.docker.com/engine/admin/logging/overview/)
* sending logs to STDOUT/STDERR: this is the default
* can be disabled by setting the environment variable `DITTO_LOGGING_DISABLE_SYSOUT_LOG`
* Benefits: simple, works with all Docker logging drivers (e.g. "awslogs", "splunk", etc.)

* pushing logs into ELK stack. This can be done via the environment variable `LOGSTASH_SERVER`.
* configure your logstash endpoint where Ditto can push the logs.
* pushing logs into ELK stack: this can be done by setting the environment variable `DITTO_LOGGING_LOGSTASH_SERVER`
* configure `DITTO_LOGGING_LOGSTASH_SERVER` to contain the endpoint of a logstash server

* writing logs to log files. This can be done via the environment variable `FILE_APPENDER`.
* configure the amonut of log files, and the total amount of space used for logs files via
these two environment variables `MAX_LOG_FILE_HISTORY_IN_DAYS` and `TOTAL_LOG_FILE_SIZE`

* writing logs to log files: this can be done by setting the environment variable `DITTO_LOGGING_FILE_APPENDER` to `true`
* configure the amount of log files, and the total amount of space used for logs files via these two environment
variables:
* `DITTO_LOGGING_MAX_LOG_FILE_HISTORY_IN_DAYS` (default: 10)
* `DITTO_LOGGING_TOTAL_LOG_FILE_SIZE` (default: 1GB)
* the format in which logging is done is "LogstashEncoder" format - that way the logfiles may easily be imported into
an ELK stack

## Monitoring

In addition to logging, the Ditto images include monitoring features. Specific metrics are
automatically gathered and published on a HTTP port. There it can be scraped by a [Prometheus](https://prometheus.io)
automatically gathered and published on an HTTP port. There it can be scraped by a [Prometheus](https://prometheus.io)
backend, from where the metrics can be accessed to display in dashboards (e.g. with [Grafana](https://grafana.com)).

### Configuring
### Monitoring configuration

In the default configuration, each Ditto service opens a HTTP endpoint, where it provides the Prometheus metrics
on port `9095`. This can be changed via the environment variable `PROMETHEUS_PORT`.
Expand Down
16 changes: 8 additions & 8 deletions gateway/service/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
</filter>
</appender>

<if condition='isDefined("LOGSTASH_SERVER")'>
<if condition='isDefined("DITTO_LOGGING_LOGSTASH_SERVER")'>
<then>
<appender name="stash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>${LOGSTASH_SERVER}</destination>
<destination>${DITTO_LOGGING_LOGSTASH_SERVER}</destination>

<!-- Encoder is required -->
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
Expand All @@ -43,7 +43,7 @@
</then>
</if>

<if condition='isDefined("FILE_APPENDER")'>
<if condition='isDefined("DITTO_LOGGING_FILE_APPENDER")'>
<then>
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
Expand All @@ -53,8 +53,8 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>connectivity.log.%d{yyyy-MM-dd}.gz</fileNamePattern>
<!-- Keep 30 days' worth of history capped at 1GB total size -->
<maxHistory>${MAX_LOG_FILE_HISTORY_IN_DAYS:-10}</maxHistory>
<totalSizeCap>${TOTAL_LOG_FILE_SIZE:-1GB}</totalSizeCap>1GB</totalSizeCap>
<maxHistory>${DITTO_LOGGING_MAX_LOG_FILE_HISTORY_IN_DAYS:-10}</maxHistory>
<totalSizeCap>${DITTO_LOGGING_TOTAL_LOG_FILE_SIZE:-1GB}</totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<customFields>{"appname":"connectivity","instance_index":"${INSTANCE_INDEX}"}</customFields>
Expand All @@ -74,7 +74,7 @@

<root level="${LOG_LEVEL:-INFO}">
<!-- Logging INFO messages can be disabled by setting environment variable -->
<if condition='isNull("DISABLE_SYSOUT_LOG")'>
<if condition='isNull("DITTO_LOGGING_DISABLE_SYSOUT_LOG")'>
<then>
<appender-ref ref="STDOUT"/>
</then>
Expand All @@ -83,13 +83,13 @@
<!-- Always log ERRORs to syserr -->
<appender-ref ref="STDERR"/>

<if condition='isDefined("LOGSTASH_SERVER")'>
<if condition='isDefined("DITTO_LOGGING_LOGSTASH_SERVER")'>
<then>
<appender-ref ref="stash"/>
</then>
</if>

<if condition='isDefined("FILE_APPENDER")'>
<if condition='isDefined("DITTO_LOGGING_FILE_APPENDER")'>
<then>
<appender-ref ref="file"/>
</then>
Expand Down
16 changes: 8 additions & 8 deletions policies/service/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
</filter>
</appender>

<if condition='isDefined("LOGSTASH_SERVER")'>
<if condition='isDefined("DITTO_LOGGING_LOGSTASH_SERVER")'>
<then>
<appender name="stash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>${LOGSTASH_SERVER}</destination>
<destination>${DITTO_LOGGING_LOGSTASH_SERVER}</destination>

<!-- Encoder is required -->
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
Expand All @@ -43,7 +43,7 @@
</then>
</if>

<if condition='isDefined("FILE_APPENDER")'>
<if condition='isDefined("DITTO_LOGGING_FILE_APPENDER")'>
<then>
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
Expand All @@ -53,8 +53,8 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>policies.log.%d{yyyy-MM-dd}.gz</fileNamePattern>
<!-- Keep 30 days' worth of history capped at 1GB total size -->
<maxHistory>${MAX_LOG_FILE_HISTORY_IN_DAYS:-10}</maxHistory>
<totalSizeCap>${TOTAL_LOG_FILE_SIZE:-1GB}</totalSizeCap>1GB</totalSizeCap>
<maxHistory>${DITTO_LOGGING_MAX_LOG_FILE_HISTORY_IN_DAYS:-10}</maxHistory>
<totalSizeCap>${DITTO_LOGGING_TOTAL_LOG_FILE_SIZE:-1GB}</totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<customFields>{"appname":"policies","instance_index":"${INSTANCE_INDEX}"}</customFields>
Expand All @@ -74,7 +74,7 @@

<root level="${LOG_LEVEL:-INFO}">
<!-- Logging INFO messages can be disabled by setting environment variable -->
<if condition='isNull("DISABLE_SYSOUT_LOG")'>
<if condition='isNull("DITTO_LOGGING_DISABLE_SYSOUT_LOG")'>
<then>
<appender-ref ref="STDOUT"/>
</then>
Expand All @@ -83,13 +83,13 @@
<!-- Always log ERRORs to syserr -->
<appender-ref ref="STDERR"/>

<if condition='isDefined("LOGSTASH_SERVER")'>
<if condition='isDefined("DITTO_LOGGING_LOGSTASH_SERVER")'>
<then>
<appender-ref ref="stash"/>
</then>
</if>

<if condition='isDefined("FILE_APPENDER")'>
<if condition='isDefined("DITTO_LOGGING_FILE_APPENDER")'>
<then>
<appender-ref ref="file"/>
</then>
Expand Down
16 changes: 8 additions & 8 deletions things/service/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
</filter>
</appender>

<if condition='isDefined("LOGSTASH_SERVER")'>
<if condition='isDefined("DITTO_LOGGING_LOGSTASH_SERVER")'>
<then>
<appender name="stash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>${LOGSTASH_SERVER}</destination>
<destination>${DITTO_LOGGING_LOGSTASH_SERVER}</destination>

<!-- encoder is required -->
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
Expand All @@ -43,7 +43,7 @@
</then>
</if>

<if condition='isDefined("FILE_APPENDER")'>
<if condition='isDefined("DITTO_LOGGING_FILE_APPENDER")'>
<then>
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
Expand All @@ -53,8 +53,8 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>things.log.%d{yyyy-MM-dd}.gz</fileNamePattern>
<!-- Keep 30 days' worth of history capped at 1GB total size -->
<maxHistory>${MAX_LOG_FILE_HISTORY_IN_DAYS:-10}</maxHistory>
<totalSizeCap>${TOTAL_LOG_FILE_SIZE:-1GB}</totalSizeCap>1GB</totalSizeCap>
<maxHistory>${DITTO_LOGGING_MAX_LOG_FILE_HISTORY_IN_DAYS:-10}</maxHistory>
<totalSizeCap>${DITTO_LOGGING_TOTAL_LOG_FILE_SIZE:-1GB}</totalSizeCap>1GB</totalSizeCap>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<customFields>{"appname":"things","instance_index":"${INSTANCE_INDEX}"}</customFields>
Expand All @@ -74,7 +74,7 @@

<root level="${LOG_LEVEL:-INFO}">
<!-- Logging INFO messages can be disabled by setting environment variable -->
<if condition='isNull("DISABLE_SYSOUT_LOG")'>
<if condition='isNull("DITTO_LOGGING_DISABLE_SYSOUT_LOG")'>
<then>
<appender-ref ref="STDOUT"/>
</then>
Expand All @@ -83,13 +83,13 @@
<!-- Always log ERRORs to syserr -->
<appender-ref ref="STDERR"/>

<if condition='isDefined("LOGSTASH_SERVER")'>
<if condition='isDefined("DITTO_LOGGING_LOGSTASH_SERVER")'>
<then>
<appender-ref ref="stash"/>
</then>
</if>

<if condition='isDefined("FILE_APPENDER")'>
<if condition='isDefined("DITTO_LOGGING_FILE_APPENDER")'>
<then>
<appender-ref ref="file"/>
</then>
Expand Down
Loading

0 comments on commit 4bddd98

Please sign in to comment.