From fc44ee6ff3553754c618349df3be7544b17e9c5f Mon Sep 17 00:00:00 2001
From: Pradeep Kilambi <pkilambi@redhat.com>
Date: Wed, 6 Sep 2017 12:14:12 -0400
Subject: [PATCH] Enable Ceilometer agent logging for containers

Change-Id: Ibeb28d7c497b02253d00a74257989cefba2b0cc4
---
 docker/services/ceilometer-agent-central.yaml      | 7 ++++++-
 docker/services/ceilometer-agent-compute.yaml      | 8 +++++++-
 docker/services/ceilometer-agent-notification.yaml | 8 +++++++-
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/docker/services/ceilometer-agent-central.yaml b/docker/services/ceilometer-agent-central.yaml
index 424c316f77..d772462d5c 100644
--- a/docker/services/ceilometer-agent-central.yaml
+++ b/docker/services/ceilometer-agent-central.yaml
@@ -69,7 +69,7 @@ outputs:
         config_image: {get_param: DockerCeilometerConfigImage}
       kolla_config:
         /var/lib/kolla/config_files/ceilometer_agent_central.json:
-          command: /usr/bin/ceilometer-polling --polling-namespaces central
+          command: /usr/bin/ceilometer-polling --polling-namespaces central --logfile /var/log/ceilometer/central.log
           config_files:
             - source: "/var/lib/kolla/config_files/src/*"
               dest: "/"
@@ -116,6 +116,11 @@ outputs:
               - '/usr/bin/bootstrap_host_exec'
               - 'ceilometer_agent_central'
               - "su ceilometer -s /bin/bash -c 'for n in {1..10}; do /usr/bin/ceilometer-upgrade --skip-metering-database && exit 0 || sleep 5; done; exit 1'"
+      host_prep_tasks:
+        - name: create persistent logs directory
+          file:
+            path: /var/log/containers/ceilometer
+            state: directory
       upgrade_tasks:
         - name: Stop and disable ceilometer agent central service
           tags: step2
diff --git a/docker/services/ceilometer-agent-compute.yaml b/docker/services/ceilometer-agent-compute.yaml
index 535b1693fc..c800b44f1a 100644
--- a/docker/services/ceilometer-agent-compute.yaml
+++ b/docker/services/ceilometer-agent-compute.yaml
@@ -69,7 +69,7 @@ outputs:
         config_image: {get_param: DockerCeilometerConfigImage}
       kolla_config:
         /var/lib/kolla/config_files/ceilometer_agent_compute.json:
-          command: /usr/bin/ceilometer-polling --polling-namespaces compute
+          command: /usr/bin/ceilometer-polling --polling-namespaces compute --logfile /var/log/ceilometer/compute.log
           config_files:
             - source: "/var/lib/kolla/config_files/src/*"
               dest: "/"
@@ -89,8 +89,14 @@ outputs:
                   - /var/lib/kolla/config_files/ceilometer_agent_compute.json:/var/lib/kolla/config_files/config.json:ro
                   - /var/lib/config-data/puppet-generated/ceilometer/:/var/lib/kolla/config_files/src:ro
                   - /var/run/libvirt:/var/run/libvirt:ro
+                  - /var/log/containers/ceilometer:/var/log/ceilometer
             environment:
               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
+      host_prep_tasks:
+        - name: create persistent logs directory
+          file:
+            path: /var/log/containers/ceilometer
+            state: directory
       upgrade_tasks:
         - name: Check if openstack-ceilometer-compute is deployed
           command: systemctl is-enabled openstack-ceilometer-compute
diff --git a/docker/services/ceilometer-agent-notification.yaml b/docker/services/ceilometer-agent-notification.yaml
index 7f1d442a8b..d8afe695be 100644
--- a/docker/services/ceilometer-agent-notification.yaml
+++ b/docker/services/ceilometer-agent-notification.yaml
@@ -69,7 +69,7 @@ outputs:
         config_image: {get_param: DockerCeilometerConfigImage}
       kolla_config:
         /var/lib/kolla/config_files/ceilometer_agent_notification.json:
-          command: /usr/bin/ceilometer-agent-notification
+          command: /usr/bin/ceilometer-agent-notification --logfile /var/log/ceilometer/agent-notification.log
           config_files:
             - source: "/var/lib/kolla/config_files/src/*"
               dest: "/"
@@ -96,8 +96,14 @@ outputs:
                 -
                   - /var/lib/kolla/config_files/ceilometer_agent_notification.json:/var/lib/kolla/config_files/config.json:ro
                   - /var/lib/config-data/puppet-generated/ceilometer/:/var/lib/kolla/config_files/src:ro
+                  - /var/log/containers/ceilometer:/var/log/ceilometer
             environment:
               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
+      host_prep_tasks:
+        - name: create persistent logs directory
+          file:
+            path: /var/log/containers/ceilometer
+            state: directory
       upgrade_tasks:
         - name: Stop and disable ceilometer agent notification service
           tags: step2