From 58eec5ca12aa3e2c0bbfc7cfb00beee82ff199d2 Mon Sep 17 00:00:00 2001 From: Doug Szumski Date: Thu, 20 Sep 2018 14:02:30 +0000 Subject: [PATCH] Forward system logs to Monasca Log API When Monasca is enabled disable direct logging to ElasticSearch and send all logs harvested by Fluentd to the Monasca Log API. This change also cleans up output files which may be left behind when the various log forwarding options are enabled / disabled. Partially-Implements: blueprint monasca-roles Change-Id: I7197966c5117176407d60c86c08d3bcea5e8131a --- ansible/roles/common/tasks/config.yml | 27 +++++++++++++++-- .../templates/conf/output/00-local.conf.j2 | 30 ++++++++++++++++--- .../templates/conf/output/02-monasca.conf.j2 | 13 ++++++++ 3 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 ansible/roles/common/templates/conf/output/02-monasca.conf.j2 diff --git a/ansible/roles/common/tasks/config.yml b/ansible/roles/common/tasks/config.yml index 2eb838f753..040c09c289 100644 --- a/ansible/roles/common/tasks/config.yml +++ b/ansible/roles/common/tasks/config.yml @@ -79,6 +79,12 @@ notify: - Restart fluentd container +- name: Determine whether logs should be forwarded directly to Elasticsearch + set_fact: + log_direct_to_elasticsearch: "{{ ( enable_elasticsearch | bool or + ( elasticsearch_address != kolla_internal_vip_address )) and + not enable_monasca | bool }}" + - name: Copying over fluentd output config files template: src: "conf/output/{{ item.name }}.conf.j2" @@ -93,8 +99,25 @@ - name: "00-local" enabled: true - name: "01-es" - enabled: "{{ enable_elasticsearch | bool or - ( elasticsearch_address != kolla_internal_vip_address ) }}" + enabled: "{{ log_direct_to_elasticsearch }}" + - name: "02-monasca" + enabled: "{{ enable_monasca | bool }}" + notify: + - Restart fluentd container + +- name: Removing stale output config files + file: + path: "{{ node_config_directory }}/fluentd/output/{{ item.name }}.conf" + state: "absent" + become: true + when: + - enable_fluentd | bool + - item.disable | bool + with_items: + - name: "02-monasca" + disable: "{{ not enable_monasca | bool }}" + - name: "01-es" + disable: "{{ not log_direct_to_elasticsearch }}" notify: - Restart fluentd container diff --git a/ansible/roles/common/templates/conf/output/00-local.conf.j2 b/ansible/roles/common/templates/conf/output/00-local.conf.j2 index 22d2ba76bb..1837b0c5ce 100644 --- a/ansible/roles/common/templates/conf/output/00-local.conf.j2 +++ b/ansible/roles/common/templates/conf/output/00-local.conf.j2 @@ -7,8 +7,7 @@ append true compress gzip -{% if enable_elasticsearch | bool or - elasticsearch_address != kolla_internal_vip_address %} +{% if log_direct_to_elasticsearch %} type elasticsearch host {{ elasticsearch_address }} @@ -17,6 +16,18 @@ logstash_prefix {{ kibana_log_prefix }} flush_interval 15s +{% elif enable_monasca | bool %} + type copy + + @type monasca + keystone_url {{ keystone_internal_url }} + monasca_log_api {{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ monasca_log_api_port }} + monasca_log_api_version v3.0 + username {{ monasca_agent_user }} + password {{ monasca_agent_password }} + domain_id default + project_name {{ monasca_control_plane_project }} + {% endif %} @@ -31,8 +42,7 @@ append true compress gzip -{% if enable_elasticsearch | bool or - elasticsearch_address != kolla_internal_vip_address %} +{% if log_direct_to_elasticsearch %} type elasticsearch host {{ elasticsearch_address }} @@ -41,5 +51,17 @@ logstash_prefix {{ kibana_log_prefix }} flush_interval 15s +{% elif enable_monasca | bool %} + type copy + + @type monasca + keystone_url {{ keystone_internal_url }} + monasca_log_api {{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ monasca_log_api_port }} + monasca_log_api_version v3.0 + username {{ monasca_agent_user }} + password {{ monasca_agent_password }} + domain_id default + project_name {{ monasca_control_plane_project }} + {% endif %} diff --git a/ansible/roles/common/templates/conf/output/02-monasca.conf.j2 b/ansible/roles/common/templates/conf/output/02-monasca.conf.j2 new file mode 100644 index 0000000000..f495249ec0 --- /dev/null +++ b/ansible/roles/common/templates/conf/output/02-monasca.conf.j2 @@ -0,0 +1,13 @@ + + type copy + + @type monasca + keystone_url {{ keystone_internal_url }} + monasca_log_api {{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ monasca_log_api_port }} + monasca_log_api_version v3.0 + username {{ monasca_agent_user }} + password {{ monasca_agent_password }} + domain_id default + project_name {{ monasca_control_plane_project }} + +