From 65b9756127416b1daf2f28189dbeaf9063f84918 Mon Sep 17 00:00:00 2001 From: Doug Szumski Date: Tue, 23 Apr 2019 15:46:00 +0100 Subject: [PATCH] Add support for using custom Logstash patterns A user may want to define and use Logstash patterns. This commit adds support to copy them into the Monasca Log Transformer container. In the future support could be added for other Logstash containers. Change-Id: Id8cde14af6dc7f49714f6b1cb878882d0048d293 --- ansible/roles/monasca/tasks/config.yml | 35 +++++++++++++++++++ .../monasca-log-transformer.json.j2 | 7 ++++ 2 files changed, 42 insertions(+) diff --git a/ansible/roles/monasca/tasks/config.yml b/ansible/roles/monasca/tasks/config.yml index e047089060..f3c617c335 100644 --- a/ansible/roles/monasca/tasks/config.yml +++ b/ansible/roles/monasca/tasks/config.yml @@ -208,6 +208,41 @@ notify: - Restart monasca-log-transformer container +- name: Ensuring logstash patterns folder exists + vars: + service: "{{ monasca_services['monasca-log-transformer'] }}" + file: + path: "{{ node_config_directory }}/monasca-log-transformer/logstash_patterns" + state: "directory" + mode: "0770" + become: true + when: + - inventory_hostname in groups[service['group']] + - service.enabled | bool + +- name: Find custom logstash patterns + local_action: + module: find + path: "{{ node_custom_config }}/monasca/logstash_patterns" + pattern: "*" + run_once: True + register: monasca_custom_logstash_patterns + +- name: Copying over custom logstash patterns + vars: + service: "{{ monasca_services['monasca-log-transformer'] }}" + template: + src: "{{ item.path }}" + dest: "{{ node_config_directory }}/monasca-log-transformer/logstash_patterns/{{ item.path | basename }}" + mode: "0660" + with_items: "{{ monasca_custom_logstash_patterns.files }}" + become: true + when: + - inventory_hostname in groups[service['group']] + - service.enabled | bool + notify: + - Restart monasca-log-transformer container + - name: Copying over monasca-log-persister config vars: service: "{{ monasca_services['monasca-log-persister'] }}" diff --git a/ansible/roles/monasca/templates/monasca-log-transformer/monasca-log-transformer.json.j2 b/ansible/roles/monasca/templates/monasca-log-transformer/monasca-log-transformer.json.j2 index 109326485c..733eeedad9 100644 --- a/ansible/roles/monasca/templates/monasca-log-transformer/monasca-log-transformer.json.j2 +++ b/ansible/roles/monasca/templates/monasca-log-transformer/monasca-log-transformer.json.j2 @@ -6,6 +6,13 @@ "dest": "/etc/logstash/conf.d/log-transformer.conf", "owner": "logstash", "perm": "0600" + }, + { + "source": "{{ container_config_directory }}/logstash_patterns/*", + "dest": "/etc/logstash/conf.d/patterns/", + "owner": "logstash", + "perm": "0600", + "optional": true } ], "permissions": [