Add logging configuration to docker image

Story: 2005462
Task: 30536

Change-Id: I6cd41b442b052ef6df118ada6abaa4cc45795d49
changes/92/652992/4
Dobroslaw Zybort 4 years ago
parent f43d019a67
commit f911fb85a0

@ -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

@ -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
=============================== =============================== ================================================

@ -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

@ -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

@ -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=$?

Loading…
Cancel
Save