Chapter 2. Installing the Centralized Logging Suite
2.1. Installing the Centralized Log Relay/Transformer Copy linkLink copied to clipboard!
Locate a bare metal system that meets the following minimum specifications:
- 8 GB of memory
- Single-socket Xeon class CPU
- 500 GB of disk space
- Install Red Hat Enterprise Linux 7.
Allow the system to access the Operational Tools packages:
Register the system and subscribe it:
subscription-manager register subscription-manager list --consumed
# subscription-manager register # subscription-manager list --consumedCopy to Clipboard Copied! Toggle word wrap Toggle overflow If an OpenStack subscription is not attached automatically, see the documentation for manually attaching subscriptions.
Disable initially enabled repositories and enable only the ones appropriate for the Operational Tools:
subscription-manager repos --disable=* subscription-manager repos --enable=rhel-7-server-rpms --enable=rhel-7-server-optional-rpms --enable=rhel-7-server-openstack-8-optools-rpms
# subscription-manager repos --disable=* # subscription-manager repos --enable=rhel-7-server-rpms --enable=rhel-7-server-optional-rpms --enable=rhel-7-server-openstack-8-optools-rpmsCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe base OpenStack repository (rhel-7-server-openstack-8-rpms) must not be enabled on this node. This repository may contain newer versions of certain Operational Tools dependencies which may be incompatible with the Operational Tools packages.
Install the
Elasticsearch,Fluentd, andKibanasoftware by running the following command:yum install elasticsearch fluentd rubygem-fluent-plugin-elasticsearch kibana httpd
# yum install elasticsearch fluentd rubygem-fluent-plugin-elasticsearch kibana httpdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enable Cross-origin resource sharing (CORS) in
Elasticsearch. To do so, edit/etc/elasticsearch/elasticsearch.ymland add the following lines to the end of the file:http.cors.enabled: true http.cors.allow-origin: "/.*/"
http.cors.enabled: true http.cors.allow-origin: "/.*/"Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThis will allow the
ElasticsearchJavaScript applications to be called from any web page on any web server. To allow CORS from yourKibanaserver only, use:http.cors.allow-origin: "http://LOGGING_SERVER"
http.cors.allow-origin: "http://LOGGING_SERVER"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace LOGGING_SERVER with the IP address or the host name of your
Kibanaserver, depending on whether you are going to accessKibanausing the IP address or the host name. However, if theElasticsearchservice is only accessible from trusted hosts, it is safe to use"/.*/".Start the
Elasticsearchinstance and enable it at boot:systemctl start elasticsearch systemctl enable elasticsearch
# systemctl start elasticsearch # systemctl enable elasticsearchCopy to Clipboard Copied! Toggle word wrap Toggle overflow To confirm the
Elasticsearchinstance is working, run the following command:curl http://localhost:9200/
# curl http://localhost:9200/Copy to Clipboard Copied! Toggle word wrap Toggle overflow This should give a response similar to the following:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure
Fluentdto accept log data and write it toElasticsearch. Edit/etc/fluentd/fluent.confand replace its content with the following:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Start
Fluentdand enable it at boot:systemctl start fluentd systemctl enable fluentd
# systemctl start fluentd # systemctl enable fluentdCopy to Clipboard Copied! Toggle word wrap Toggle overflow TipCheck the journal for
Fluentdand ensure it has no errors at start:journalctl -u fluentd -l -f
# journalctl -u fluentd -l -fCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure
Kibanato point to theElasticsearchinstance. Create/etc/httpd/conf.d/kibana3.confand place the following content inside:Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you want to restrict access to
KibanaandElasticsearchto authorized users only, for example, because these services are running on a system in an open network, secure the virtual host using HTTP Basic authentication and moveElasticseachbehind a proxy. To do so, follow these steps:Create (or rewrite) the
/etc/httpd/conf.d/kibana3.conffile with the following content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou can use a different path for the
AuthUserFileoption as well as any other description for theAuthNameoption.Create a pair of user name and password which will be allowed to access
Kibana. To do so, run the following command:htpasswd -c /etc/httpd/conf/htpasswd-kibana user_name
# htpasswd -c /etc/httpd/conf/htpasswd-kibana user_nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf you are using a different path for the
AuthUserFileoption, change the command accordingly.Replace user_name with a user name of your choice. When prompted, enter the password that will be used with this user name. You will be prompted to re-type the password.
Optionally, create more users with their own passwords by running the following command:
htpasswd /etc/httpd/conf/htpasswd-kibana another_user_name
# htpasswd /etc/httpd/conf/htpasswd-kibana another_user_nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure
Elasticsearchto listen on thelocalhostinterface only. To do so, open the/etc/elasticsearch/elasticsearch.ymlfile in an editor and append the following option:network.host: 127.0.0.1
network.host: 127.0.0.1Copy to Clipboard Copied! Toggle word wrap Toggle overflow You must also configure
Elasticsearchto allow using HTTP Basic authentication data with CORS by appending the following option to/etc/elasticsearch/elasticsearch.yml:http.cors.allow-credentials: true
http.cors.allow-credentials: trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow Restart
Elasticsearchfor these changes to take effect:systemctl restart elasticsearch
# systemctl restart elasticsearchCopy to Clipboard Copied! Toggle word wrap Toggle overflow Finally, ensure that the
Elasticsearchfiles are downloaded using the proxy, and that the HTTP Basic authentication data is sent by the browser. To do so, edit the/usr/share/kibana/config.jsfile. Find the following line in this file:elasticsearch: "http://"+window.location.hostname+":9200",
elasticsearch: "http://"+window.location.hostname+":9200",Copy to Clipboard Copied! Toggle word wrap Toggle overflow and change it as follows:
elasticsearch: {server: "http://"+window.location.hostname, withCredentials: true},elasticsearch: {server: "http://"+window.location.hostname, withCredentials: true},Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Enable
Kibana(inside Apache) to connect toElasticsearch, and then start Apache and enable it at boot:setsebool -P httpd_can_network_connect 1 systemctl start httpd systemctl enable httpd
# setsebool -P httpd_can_network_connect 1 # systemctl start httpd # systemctl enable httpdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Open the firewall on the system to allow connections to
Fluentdandhttpd:firewall-cmd --zone=public --add-port=4000/tcp --permanent firewall-cmd --zone=public --add-service=http --permanent firewall-cmd --reload
# firewall-cmd --zone=public --add-port=4000/tcp --permanent # firewall-cmd --zone=public --add-service=http --permanent # firewall-cmd --reloadCopy to Clipboard Copied! Toggle word wrap Toggle overflow Moreover, if you have not configured HTTP authentication and
Elasticsearchproxy, open the firewall to allow direct connections toElasticsearch:firewall-cmd --zone=public --add-port=9200/tcp --permanent firewall-cmd --reload
# firewall-cmd --zone=public --add-port=9200/tcp --permanent # firewall-cmd --reloadCopy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantIf you do not restrict access to
KibanaandElasticseachusing HTTP authentication, the information provided by Kibana and Elasticsearch is available to anyone without any authentication. To secure the data, ensure that the system or the open TCP ports (80, 4000, and 9200) are only accessible from trusted hosts.
2.2. Installing the Log Collection Agent on All Nodes Copy linkLink copied to clipboard!
To collect the logs from all the systems in the OpenStack environment and send them to your centralized logging server, run the following commands on all the OpenStack systems.
Enable the Operational Tools repository:
subscription-manager repos --enable=rhel-7-server-openstack-8-optools-rpms
# subscription-manager repos --enable=rhel-7-server-openstack-8-optools-rpmsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Install
fluentdandrubygem-fluent-plugin-add:yum install fluentd rubygem-fluent-plugin-add
# yum install fluentd rubygem-fluent-plugin-addCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the
Fluentduser so it has permissions to read all the OpenStack log files. Do this by running the following command:for user in {keystone,nova,neutron,cinder,glance}; do usermod -a -G $user fluentd; done# for user in {keystone,nova,neutron,cinder,glance}; do usermod -a -G $user fluentd; doneCopy to Clipboard Copied! Toggle word wrap Toggle overflow Note that you may get an error on some nodes about missing groups. This can be disregarded as not all the nodes run all the services.
Configure
Fluentd. Make sure/etc/fluentd/fluent.conflooks like the following; be sure to replace LOGGING_SERVER with the host name or IP address of your centralized logging server configured above:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Now that
Fluentdhas been configured, start theFluentdservice and enable it at boot:systemctl start fluentd systemctl enable fluentd
# systemctl start fluentd # systemctl enable fluentdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
You should now be able to access Kibana running at http://LOGGING_SERVER/index.html#/dashboard/file/logstash.json and see logs start to populate. If you have enabled HTTP Basic authentication in the Kibana configuration, you must enter a valid user name and password to access this page.
By default, the front page of the logging server, http://LOGGING_SERVER/, is a Kibana welcome screen providing technical requirements and additional configuration information. If you want the logs to be available here, replace the default.json file in the Kibana application directory with logstash.json, but first create a backup copy of default.json in case you need this file again in the future:
mv /usr/share/kibana/app/dashboards/default.json /usr/share/kibana/app/dashboards/default.json.orig cp /usr/share/kibana/app/dashboards/logstash.json /usr/share/kibana/app/dashboards/default.json
# mv /usr/share/kibana/app/dashboards/default.json /usr/share/kibana/app/dashboards/default.json.orig
# cp /usr/share/kibana/app/dashboards/logstash.json /usr/share/kibana/app/dashboards/default.json