From 1ded68d2d35d67bbbcdc364d09633f9b32f10643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 3 Feb 2016 11:58:13 +0100 Subject: [PATCH] Make Heka collect RabbitMQ logs Partially implements: blueprint heka Change-Id: I8fd3324daf15e52712591c2b3cbec613d82b73b3 --- ansible/roles/common/tasks/config.yml | 1 + .../roles/common/templates/heka-rabbitmq.toml.j2 | 16 ++++++++++++++++ ansible/roles/common/templates/heka.json.j2 | 6 ++++++ ansible/roles/rabbitmq/tasks/start.yml | 1 + .../rabbitmq/templates/rabbitmq-env.conf.j2 | 2 ++ docker/rabbitmq/extend_start.sh | 7 +++++++ 6 files changed, 33 insertions(+) create mode 100644 ansible/roles/common/templates/heka-rabbitmq.toml.j2 diff --git a/ansible/roles/common/tasks/config.yml b/ansible/roles/common/tasks/config.yml index 01d340431d..b50a578526 100644 --- a/ansible/roles/common/tasks/config.yml +++ b/ansible/roles/common/tasks/config.yml @@ -30,3 +30,4 @@ with_items: - "global" - "haproxy" + - "rabbitmq" diff --git a/ansible/roles/common/templates/heka-rabbitmq.toml.j2 b/ansible/roles/common/templates/heka-rabbitmq.toml.j2 new file mode 100644 index 0000000000..014c75113e --- /dev/null +++ b/ansible/roles/common/templates/heka-rabbitmq.toml.j2 @@ -0,0 +1,16 @@ +[rabbitmq_log_decoder] +type = "SandboxDecoder" +filename = "lua_decoders/os_rabbitmq_log.lua" + +[rabbitmq_log_splitter] +type = "RegexSplitter" +delimiter = '\n(=[^=]+====)' +delimiter_eol = false + +[rabbitmq_logstreamer_input] +type = "LogstreamerInput" +decoder = "rabbitmq_log_decoder" +splitter = "rabbitmq_log_splitter" +log_directory = "/var/log/kolla" +file_match = 'rabbitmq/rabbit*\.log' +differentiator = ['rabbitmq'] diff --git a/ansible/roles/common/templates/heka.json.j2 b/ansible/roles/common/templates/heka.json.j2 index bda52ca561..c65d0fab2a 100644 --- a/ansible/roles/common/templates/heka.json.j2 +++ b/ansible/roles/common/templates/heka.json.j2 @@ -12,6 +12,12 @@ "dest": "/etc/heka/heka-haproxy.toml", "owner": "heka", "perm": "0600" + }, + { + "source": "{{ container_config_directory }}/heka-rabbitmq.toml", + "dest": "/etc/heka/heka-rabbitmq.toml", + "owner": "heka", + "perm": "0600" } ] } diff --git a/ansible/roles/rabbitmq/tasks/start.yml b/ansible/roles/rabbitmq/tasks/start.yml index 9ed544290a..2f5585fce2 100644 --- a/ansible/roles/rabbitmq/tasks/start.yml +++ b/ansible/roles/rabbitmq/tasks/start.yml @@ -8,3 +8,4 @@ volumes: - "{{ node_config_directory }}/rabbitmq/:{{ container_config_directory }}/:ro" - "rabbitmq:/var/lib/rabbitmq/" + - "kolla_logs:/var/log/kolla/" diff --git a/ansible/roles/rabbitmq/templates/rabbitmq-env.conf.j2 b/ansible/roles/rabbitmq/templates/rabbitmq-env.conf.j2 index 549b7f0c9b..837b9a0ca4 100644 --- a/ansible/roles/rabbitmq/templates/rabbitmq-env.conf.j2 +++ b/ansible/roles/rabbitmq/templates/rabbitmq-env.conf.j2 @@ -1,6 +1,8 @@ RABBITMQ_NODENAME=rabbit RABBITMQ_BOOT_MODULE=rabbit_clusterer +RABBITMQ_LOG_BASE=/var/log/kolla/rabbitmq + {% if not kolla_base_distro in ['ubuntu', 'debian'] %} RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="-pa /usr/lib/rabbitmq/lib/rabbitmq_server-3.5.5/plugins/rabbitmq_clusterer-3.5.x-189b3a81.ez/rabbitmq_clusterer-3.5.x-189b3a81/ebin" # See bug https://bugs.launchpad.net/ubuntu/+source/erlang/+bug/1374109 diff --git a/docker/rabbitmq/extend_start.sh b/docker/rabbitmq/extend_start.sh index 06e71e810e..f0b9fd9c41 100644 --- a/docker/rabbitmq/extend_start.sh +++ b/docker/rabbitmq/extend_start.sh @@ -8,3 +8,10 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then chmod 400 /var/lib/rabbitmq/.erlang.cookie exit 0 fi + +if [[ ! -d "/var/log/kolla/rabbitmq" ]]; then + mkdir -p /var/log/kolla/rabbitmq +fi +if [[ $(stat -c %a /var/log/kolla/rabbitmq) != "755" ]]; then + chmod 755 /var/log/kolla/rabbitmq +fi