Merge "Add logging configuration to docker image"

This commit is contained in:
Zuul 2019-04-18 10:12:29 +00:00 committed by Gerrit Code Review
commit de37e81ce0
5 changed files with 57 additions and 6 deletions

View File

@ -16,6 +16,10 @@ FROM monasca/base:$BASE_TAG
ENV \
DEBUG=false \
VERBOSE=true \
LOG_LEVEL=WARNING \
LOG_LEVEL_KAFKA=WARNING \
LOG_LEVEL_INFLUXDB=WARNING \
LOG_LEVEL_CASSANDRA=WARNING \
ZOOKEEPER_URI=zookeeper:2181 \
KAFKA_URI=kafka:9092 \
KAFKA_ALARM_HISTORY_BATCH_SIZE=1000 \
@ -40,7 +44,7 @@ ENV \
STAY_ALIVE_ON_FAILURE="false"
# Copy all necessary files to proper locations.
COPY monasca_persister.conf.j2 /etc/monasca/
COPY monasca-persister.conf.j2 persister-logging.conf.j2 /etc/monasca/
# Run here all additional steps your service need post installation.
# Stay with only one `RUN` and use `&& \` for next steps to don't create

View File

@ -71,6 +71,10 @@ CASSANDRA_PASSWORD password Cassandra passwo
CASSANDRA_KEY_SPACE monasca Keyspace name where metrics are stored
CASSANDRA_CONNECTION_TIMEOUT 5 Cassandra timeout in seconds
CASSANDRA_RETENTION_POLICY 45 Data retention period in days
LOG_LEVEL WARNING Log level for monasca persister
LOG_LEVEL_KAFKA WARNING Log level for communication with Kafka
LOG_LEVEL_INFLUXDB WARNING Log level for communication with InfluxDB
LOG_LEVEL_CASSANDRA WARNING Log level for communication with Cassandra
STAY_ALIVE_ON_FAILURE false If true, container runs 2 hours even start fails
=============================== =============================== ================================================

View File

@ -1,8 +1,7 @@
[DEFAULT]
#log_file = monasca_persister.log
#log_dir = /var/log/monasca_persister
# Provide logging configuration
log_config_append = /etc/monasca/persister-logging.conf
# Default log level is WARNING
# Show debugging output in logs (sets DEBUG log level output)
debug = {{ DEBUG }}
# Show more verbose log output (sets INFO log level output) if debug is False

View File

@ -0,0 +1,43 @@
[loggers]
keys = root, kafka, influxdb, cassandra
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = {{ LOG_LEVEL }}
formatter = default
handlers = console
[logger_kafka]
qualname = kafka
level = {{ LOG_LEVEL_KAFKA }}
formatter = default
handlers = console
propagate = 0
[logger_influxdb]
qualname = influxdb
level = {{ LOG_LEVEL_INFLUXDB }}
formatter = default
handlers = console
propagate = 0
[logger_cassandra]
qualname = cassandra
level = {{ LOG_LEVEL_CASSANDRA }}
formatter = default
handlers = console
propagate = 0
[handler_console]
class = logging.StreamHandler
args = (sys.stderr,)
level = DEBUG
formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)s [%(name)s][%(threadName)s] %(message)s

View File

@ -25,12 +25,13 @@ python3 /kafka_wait_for_topics.py
# Template all config files before start, it will use env variables.
# Read usage examples: https://pypi.org/project/Templer/
echo "Start script: creating config files from templates"
templer -v -f /etc/monasca/monasca_persister.conf.j2 /etc/monasca/monasca_persister.conf
templer -v -f /etc/monasca/monasca-persister.conf.j2 /etc/monasca/monasca-persister.conf
templer -v -f /etc/monasca/persister-logging.conf.j2 /etc/monasca/persister-logging.conf
# Start our service.
# gunicorn --args
echo "Start script: starting container"
monasca-persister --config-file /etc/monasca/monasca_persister.conf
monasca-persister --config-file /etc/monasca/monasca-persister.conf
# Allow server to stay alive in case of failure for 2 hours for debugging.
RESULT=$?