Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra exercise to include host OS logging #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,33 @@ but they are not here).
Once you're in, Kibana needs some further setup which is not automated.
Set the log index to ``flog-*`` and you should be ready to go.

Extra: Adding Host OS Logs
^^^^^^^^^^^^^^^^^^^^^^^^^^

We can extend the catchment of centralised logging to include logs
generated by the host OS and processed using ``rsyslog``. It is
relatively straightforward to connect ``rsyslog`` to ``fluentd``:
Kolla-Ansible will configure ``fluentd`` to bind to a UDP port and
listen on each host's primary network interface. It is easy to
configure ``rsyslog`` to forward log messages to this UDP port.

The best approach is to use a `Kayobe custom playbook
<https://docs.openstack.org/kayobe/latest/custom-ansible-playbooks.html>`_
to make this change. Custom playbooks have access to the Kayobe inventory
and group variables. We can use the ``overcloud`` group to reconfigure
``rsyslog`` on all hosts.

To run the custom playbook:

.. code-block:: console

cd config/src/kayobe-confg/etc/kayobe/ansible
kayobe playbook run host-logging.yml

Once the playbook completes, you should soon find extra log messages
in Kibana from host OS services such as ``kernel``, ``systemd`` and
``sshd``.

Adding the Barbican service
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
27 changes: 27 additions & 0 deletions etc/kayobe/ansible/host-logging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
# Direct host OS logs to Fluentd for forwarding to ElasticSearch
- name: Configure rsyslog to forward messages
hosts: overcloud
become: yes

tasks:
- name: Check rsyslog is started and enabled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a task to install the package?

systemd:
state: started
enabled: yes
name: rsyslog

- name: Update rsyslog file
lineinfile:
path: /etc/rsyslog.conf
insertafter: '^#*.* @@remote-host:514'
line: '*.* @{{ ansible_default_ipv4.address }}:5140'
register: rsyslog_config

- name: Restart rsyslog
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be better done as a handler that the previous task would notify.

systemd:
state: restarted
name: rsyslog
when: rsyslog_config.changed

...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally don't use end markers in Kayobe code.