Browse Source

Support customising Fluentd formatting

In some scenarios it may be useful to perform custom formatting of logs
before forwarding them. For example, the JSON formatter plugin can be
used to convert an event to JSON.

Change-Id: I3dd9240c5910a9477456283b392edc9566882dcd
Doug Szumski 2 months ago
parent
commit
c8a22f1090

+ 1
- 0
ansible/roles/common/handlers/main.yml View File

@@ -23,6 +23,7 @@
23 23
       or fluentd_output.changed | bool
24 24
       or fluentd_output_custom.changed | bool
25 25
       or fluentd_format.changed | bool
26
+      or fluentd_format_custom.changed | bool
26 27
       or fluentd_filter.changed | bool
27 28
       or fluentd_filter_custom.changed | bool
28 29
       or fluentd_td_agent.changed | bool

+ 21
- 0
ansible/roles/common/tasks/config.yml View File

@@ -158,6 +158,27 @@
158 158
   notify:
159 159
     - Restart fluentd container
160 160
 
161
+- name: Find custom fluentd format config files
162
+  local_action:
163
+    module: find
164
+    path: "{{ node_custom_config }}/fluentd/format"
165
+    pattern: "*.conf"
166
+  run_once: True
167
+  register: find_custom_fluentd_format
168
+  when:
169
+    - enable_fluentd | bool
170
+
171
+- name: Copying over custom fluentd format config files
172
+  template:
173
+    src: "{{ item.path }}"
174
+    dest: "{{ node_config_directory }}/fluentd/format/{{ item.path | basename }}"
175
+  register: fluentd_format_custom
176
+  when:
177
+    - enable_fluentd | bool
178
+  with_items: "{{ find_custom_fluentd_format.files }}"
179
+  notify:
180
+    - Restart fluentd container
181
+
161 182
 - name: Copying over fluentd filter config files
162 183
   template:
163 184
     src: "conf/filter/{{ item.src }}.conf.j2"

+ 4
- 8
ansible/roles/common/templates/fluentd.json.j2 View File

@@ -27,15 +27,11 @@
27 27
             "owner": "{{ fluentd_user }}",
28 28
             "perm": "0600"
29 29
         },
30
+        {# Copy all configuration files in format/ directory to include #}
31
+        {# custom format configs. #}
30 32
         {
31
-            "source": "{{ container_config_directory }}/format/apache_access.conf",
32
-            "dest": "{{ fluentd_dir }}/format/apache_access.conf",
33
-            "owner": "{{ fluentd_user }}",
34
-            "perm": "0600"
35
-        },
36
-        {
37
-            "source": "{{ container_config_directory }}/format/wsgi_access.conf",
38
-            "dest": "{{ fluentd_dir }}/format/wsgi_access.conf",
33
+            "source": "{{ container_config_directory }}/format/*.conf",
34
+            "dest": "{{ fluentd_dir }}/format/",
39 35
             "owner": "{{ fluentd_user }}",
40 36
             "perm": "0600"
41 37
         },

+ 11
- 0
doc/source/reference/logging-and-monitoring/central-logging-guide.rst View File

@@ -182,6 +182,17 @@ Configuration of custom fluentd filters is possible by placing filter
182 182
 configuration files in ``/etc/kolla/config/fluentd/filter/*.conf`` on the
183 183
 control host.
184 184
 
185
+Custom log formatting
186
+---------------------
187
+
188
+In some scenarios it may be useful to perform custom formatting of logs before
189
+forwarding them. For example, the JSON formatter plugin can be used to convert
190
+an event to JSON.
191
+
192
+Configuration of custom fluentd formatting is possible by placing filter
193
+configuration files in ``/etc/kolla/config/fluentd/format/*.conf`` on the
194
+control host.
195
+
185 196
 Custom log forwarding
186 197
 ---------------------
187 198
 

+ 10
- 0
releasenotes/notes/fluentd-custom-format-config-b6fc3a4883efc213.yaml View File

@@ -0,0 +1,10 @@
1
+---
2
+features:
3
+  - |
4
+    Adds ability to configure custom fluentd formatting.
5
+
6
+    In some scenarios it may be useful to configure custom fluentd formatting
7
+    to, for example, convert events to JSON.
8
+
9
+    Configuration of custom fluentd formatting is possible by placing
10
+    output configuration files in /etc/kolla/config/fluentd/format/\*.conf.

Loading…
Cancel
Save