diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 5ec9f5da89..5eb752ff02 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -803,6 +803,7 @@ enable_cyborg: "no" enable_designate: "no" enable_etcd: "no" enable_fluentd: "yes" +enable_fluentd_systemd: "{{ (enable_fluentd | bool) and (enable_central_logging | bool) }}" enable_freezer: "no" enable_gnocchi: "no" enable_gnocchi_statsd: "no" diff --git a/ansible/roles/common/defaults/main.yml b/ansible/roles/common/defaults/main.yml index cd2449ece4..68fe8261d7 100644 --- a/ansible/roles/common/defaults/main.yml +++ b/ansible/roles/common/defaults/main.yml @@ -120,6 +120,7 @@ fluentd_default_volumes: - "{{ '/etc/timezone:/etc/timezone:ro' if ansible_facts.os_family == 'Debian' else '' }}" - "kolla_logs:/var/log/kolla/" - "fluentd_data:/var/lib/fluentd/data/" + - "/var/log/journal:/var/log/journal:ro" kolla_toolbox_extra_volumes: "{{ default_extra_volumes }}" cron_extra_volumes: "{{ default_extra_volumes }}" fluentd_extra_volumes: "{{ default_extra_volumes }}" diff --git a/ansible/roles/common/tasks/config.yml b/ansible/roles/common/tasks/config.yml index a2c03ad0cb..e957433570 100644 --- a/ansible/roles/common/tasks/config.yml +++ b/ansible/roles/common/tasks/config.yml @@ -114,6 +114,8 @@ enabled: true - name: "conf/input/11-letsencrypt.conf.j2" enabled: "{{ enable_letsencrypt | bool }}" + - name: "conf/input/12-systemd.conf.j2" + enabled: "{{ enable_fluentd_systemd | bool }}" customised_input_files: "{{ find_custom_fluentd_inputs.files | map(attribute='path') | list }}" # Filters fluentd_filter_files: "{{ default_filter_files | customise_fluentd(customised_filter_files) }}" diff --git a/ansible/roles/common/templates/conf/input/12-systemd.conf.j2 b/ansible/roles/common/templates/conf/input/12-systemd.conf.j2 new file mode 100644 index 0000000000..001cb6a9c9 --- /dev/null +++ b/ansible/roles/common/templates/conf/input/12-systemd.conf.j2 @@ -0,0 +1,9 @@ + + @type systemd + tag journal + path /var/log/journal + + fields_strip_underscores true + fields_lowercase true + + diff --git a/ansible/roles/common/templates/fluentd.json.j2 b/ansible/roles/common/templates/fluentd.json.j2 index 712182c14a..931e5daec2 100644 --- a/ansible/roles/common/templates/fluentd.json.j2 +++ b/ansible/roles/common/templates/fluentd.json.j2 @@ -26,6 +26,13 @@ "recurse": true }, {% endfor %} +{% if enable_fluentd_systemd | bool %} + { + "path": "/var/log/journal", + "owner": "{{ fluentd_user }}:{{ fluentd_user }}", + "recurse": true + }, +{% endif %} { "path": "/var/lib/fluentd/data", "owner": "{{ fluentd_user }}:{{ fluentd_user }}", diff --git a/doc/source/reference/logging-and-monitoring/central-logging-guide.rst b/doc/source/reference/logging-and-monitoring/central-logging-guide.rst index 34b265a40d..59d1819384 100644 --- a/doc/source/reference/logging-and-monitoring/central-logging-guide.rst +++ b/doc/source/reference/logging-and-monitoring/central-logging-guide.rst @@ -232,3 +232,13 @@ network equipment. This can be done by configuring custom fluentd inputs. Configuration of custom fluentd inputs is possible by placing input configuration files in ``/etc/kolla/config/fluentd/input/*.conf`` on the control host. + +Systemd Logs +------------ + +By default, when enabling central logging, we also enable reading ``systemd`` +logs from the ``/var/log/journal`` file. + +To disable this behavior when central logging is enabled, set the value of +the variable ``enable_fluentd_systemd`` to ``false`` in the configuration +file ``/etc/kolla/globals.yml``. diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml index 223ec3bfa6..ac9d58c612 100644 --- a/etc/kolla/globals.yml +++ b/etc/kolla/globals.yml @@ -345,6 +345,7 @@ workaround_ansible_issue_8743: yes #enable_destroy_images: "no" #enable_etcd: "no" #enable_fluentd: "yes" +#enable_fluentd_systemd: "{{ (enable_fluentd | bool) and (enable_central_logging | bool) }}" #enable_freezer: "no" #enable_gnocchi: "no" #enable_gnocchi_statsd: "no" diff --git a/releasenotes/notes/feature_enable-fluent-plugin-systemd-9326efac3a64fbfd.yaml b/releasenotes/notes/feature_enable-fluent-plugin-systemd-9326efac3a64fbfd.yaml new file mode 100644 index 0000000000..80c95a44f6 --- /dev/null +++ b/releasenotes/notes/feature_enable-fluent-plugin-systemd-9326efac3a64fbfd.yaml @@ -0,0 +1,23 @@ +--- +features: + - | + Implements [Enable Fluentd Plugin Systemd]. + Adds the needed changes and configurations in order to use the + fluentd plugin, systemd, to read logs from /var/log/journal by + default. This allows us to read and manipulate this logs for + monitoring purposes. + + These logs will be sent to OpenSearch by default, to disable this + behavior, set the value of the variable ``enable_fluentd_systemd`` + to ``false`` in the configuration file ``/etc/kolla/globals.yml``. + + By default, when enabling central logging, we also enable the + ``systemd`` plugin. To disable this behavior when central logging + is enabled, set the value of the variable ``enable_fluentd_systemd`` + to ``false`` in the configuration file ``/etc/kolla/globals.yml``. + + fluent-plugin-systemd source: + https://github.com/fluent-plugin-systemd/fluent-plugin-systemd + + `Blueprint enable-fluent-plugin-systemd + `__