Logging using ELK Stack | |
Tiki has comprehensive built in logging capabilities as part of Action Log and to a lesser extent System Log. Nevertheless, high volume sites might find these logging capabilities insufficient, or more importantly not performant enough, since these internal logging mechanisms save their data in the MySQL database that is used by Tiki as a whole. One popular logging solution used by many large sites on the Internet uses the ELK stack, which not only provides a highly performant way to handle log processing, it provides a very flexible way to query and analyze data from the logs themselves. It is log from Tiki to the ELK stack, which would be useful for advanced system administrators managing large sites. There are already numerous articles explaining how and why to setup logging using the ELK stack available on the Internet, including on Elastic's own website, so the purpose of this documentation is to focus on how to use such a setup with Tiki, rather than repeating the information that is out there. Available from Tiki 16 {maketoc title="" levels="2,3"} |
Overall architecture | |
The flow of the logging information is as follows: And then the logs can be queried or analyzed using Kibana and related tools that work with Elasticsearch. |
Step 1: make sure you have ELK installed. | |
You are going to need Elasticsearch, Logstash and Kibana installed. You can install all of these on the same machine or separate machines, or even use a cloud service to get instances. The configurations that are explained here have been tested with:
|
Step 2: setup your Tiki server to log information to the Apache logs | |
This example is based on Apache 2.x as the web server but you could use similar directives to achieve the same thing in other web servers like NGINX. In you Apache VirtualHost configuration, switch the log format to the tikicombined log format. Reload Apache to refresh the configuration. Note that the index name of the Elasticsearch index you want the logs to be indexed into is specified as "log_yourindexname" in the following example. Copy to clipboard
In the .htaccess file in the Tiki webroot that you want to send logs to the web server log, uncomment the following lines as follows. Specify a TIKI_HEADER_REPORT_ID (must be alphanumeric with underscore, no spaces) to identify that Tiki instance in the logs. .htaccess Copy to clipboard
|
Step 3: setup Filebeat to send logs to Logstash | |
Although it is possible to load Apache log files directly into Logstash, this example will use Filebeat (which is part of the ELK stack) to send files over to your Logstash server. The main advantage of using Filebeat is to be able to separate out the CPU intensive part of log processing (Logstash) on another centralized log processing server, and keep merely the "sending the files" part, i.e. Filebeat on the web server itself. First make sure Filebeat is installed and running on your server. And then make sure it is using a configuration file containing the minimum something like the following: filebeat.yml Copy to clipboard
You should also setup the logging section of the configuration if you want filebeat errors to be logged on the server. |
Step 4: setup Logstash configuration file | |
On the logstash server, you are going to need a configuration file that processes Tiki log files, and also pick up the log files sent by FileBeat. tiki.conf Copy to clipboard
For more information on logstash, check https://www.elastic.co/guide/en/logstash/index.html. |
Step 5: Setup the events you wish to log. | |
All the read events (that would normally be in the Apache log) should already be logged from all the Tiki that are setup as above with a TIKI_HEADER_REPORT_ID set. if you look closely, you will note that the tiki.conf configuration file drops those with no such parameter set. In order to log Tiki events in addition to the username, object type, object ID, URL, query string etc which are more standard parameters, you have to configure events to be Logged, similar to how they are configured to be Recorded in an PluginActivityStream. To setup events to be logged:
|
Tips | |
|