diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 30032ef3e2..6837b3adf8 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -806,6 +806,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 5a9986456b..cdad806d6e 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 d90edf7197..aa33cfa851 100644 --- a/ansible/roles/common/tasks/config.yml +++ b/ansible/roles/common/tasks/config.yml @@ -165,6 +165,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 82302aa0c1..838a2043b8 100644 --- a/ansible/roles/common/templates/fluentd.json.j2 +++ b/ansible/roles/common/templates/fluentd.json.j2 @@ -24,6 +24,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 0ccb5f7545..4988f4ca57 100644 --- a/doc/source/reference/logging-and-monitoring/central-logging-guide.rst +++ b/doc/source/reference/logging-and-monitoring/central-logging-guide.rst @@ -276,3 +276,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 3429c2c0e4..53bdd16a20 100644 --- a/etc/kolla/globals.yml +++ b/etc/kolla/globals.yml @@ -351,6 +351,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 + `__