If you want to view and analyze Apache log data, you can use Filebeat to collect the data. Then, use Alibaba Cloud Logstash to filter the data and transfer the processed data to an Alibaba Cloud Elasticsearch cluster for analytics.
Prerequisites
- An Elasticsearch cluster and a Logstash cluster are created in the same Virtual Private
Cloud (VPC). The versions of the clusters are the same.
For more information, see Create an Alibaba Cloud Elasticsearch cluster and Created an Alibaba Cloud Logstash cluster.
- The Auto Indexing feature is enabled for the Elasticsearch cluster.
For security purposes, Alibaba Cloud Elasticsearch disables the Auto Indexing feature by default. However, Beats depends on this feature. If you select Elasticsearch for Output when you create a shipper, you must enable the Auto Indexing feature. For more information, see Access and configure an Elasticsearch cluster.
- An Alibaba Cloud Elastic Compute Service (ECS) instance is created in the same VPC
as the Elasticsearch cluster and Logstash cluster.
For more information, see Create an instance by using the wizard.
Notice Beats supports only Aliyun Linux, Red Hat Linux, and CentOS. - HTTP Daemon (HTTPd) is installed on the ECS instance.
To facilitate the analytics and display of Apache log data by using a visualization tool, we recommend that you define JSON as the format of the log data in the httpd.conf file. For more information, see Step 1. Install and configure Apache HTTP Server. The following configurations are used in this topic:
LogFormat "{\"@timestamp\":\"%{%Y-%m-%dT%H:%M:%S%z}t\",\"client_ip\":\"%{X-Forwa rded-For}i\",\"direct_ip\": \"%a\",\"request_time\":%T,\"status\":%>s,\"url\":\"%U%q\",\"method\":\"%m\",\"http_host\":\"%{Host}i\",\"server_ip\":\"%A\",\"http_referer\":\"%{Referer}i\",\"http_user_agent\":\"%{User-agent}i\",\"body_bytes_sent\":\"%B\",\"total_bytes_sent\":\"%O\"}" access_log_json # Change the original CustomLog configuration to CustomLog "logs/access_log" access_log_json.
- Cloud Assistant and Docker are installed on the ECS instance.
For more information, see Install the Cloud Assistant client and Deploy and use Docker on Alibaba Cloud Linux 2 instances.