Collecting Syslog Aggregation Server Logs to LTS
Introduction
System Logging Protocol (Syslog) is a data protocol used by network devices to collect logs to a logging server. It can record log messages of multiple event types and is supported by almost all network devices, such as routers, switches, and printers. Even Unix-like servers can generate syslog messages to record user logins, firewall events, and Apache or Nginx access.
Syslog defines related format specifications based on RFC5424 and RFC3164. RFC3164 was released in 2001, and RFC5424 was an upgraded version released in 2009. The new version is compatible with the old version and solves many problems of the old version. Therefore, RFC 5424 is recommended. For more information, see RFC5424 and RFC3164.
This section describes how to use the syslog protocol to upload logs to LTS. You need to buy an ECS as a syslog aggregation server. Rsyslog comes preinstalled by default on Linux servers. However, Huawei Cloud ECSs do not receive remote syslog writes by default. You need to enable this function.
Solution Overview
- You can buy a Linux ECS and configure it as a syslog aggregation server to receive log data from other devices. If the size of a log received by a syslog server exceeds 1,024 bytes, the log will be truncated.
- The log processing rate of a single syslog server is 10 MB/s. To process a large number of logs or ensure high reliability, you can buy multiple ECSs as syslog servers and configure load balancers for distributing traffic.
- You need to install ICAgent on syslog servers and configure log collection rules to collect logs to LTS.
Planning Resources
Buy two ECSs. One serves as a syslog aggregation server, and the other serves as a service ECS to simulate user systems or devices to send logs.
Buying an ECS
- Log in to the management console and choose Compute > Elastic Cloud Server.
- Buy an ECS as a syslog aggregation server.
You are advised to use CentOS 6.5 64bit or later images. The recommended specifications are 2 vCPUs and 4 GB of memory.
- Log in to the syslog server as user root to install ICAgent.
- Allow TCP ports 30200, 30201, 8149, 8923, and 8102 in the outbound rules of the syslog server, and then allow UDP port 514 in the inbound rules as the default listening port.
- Log in to the LTS console. In the navigation pane, choose Host Management. On the page displayed, click Install ICAgent. Set OS to Linux and Host to Intra-region hosts. Then, select Obtain AK/SK for Installation Mode. Click Copy Command to copy the ICAgent installation command and manually replace the AK/SK.
- Log in to the syslog server as user root and run the ICAgent installation command. If the message ICAgent install success is displayed, ICAgent is successfully installed. You can then view the ICAgent status by choosing Host Management in the navigation pane of the LTS console and then clicking Hosts.
- Enable the rsyslog listening and receiving functions.
By default, rsyslog of Huawei Cloud ECSs does not receive remote syslog writes. You need to manually enable this function.
- Log in to the ECS.
- Modify the rsyslog configuration file.
vi /etc/rsyslog.conf
- Add the following content to the configuration file to enable TCP and UDP remote receiving:
Provides UDP syslog reception $ModLoad imudp $UDPServerRun 514 Provides TCP syslog reception $ModLoad imtcp $InputTCPServerRun 514
- Save the settings. Click More > Restart in the Operation column to restart the ECS.
- Run any of the following commands. If the command output is normal, the service is working.
Run service rsyslog status to check whether the rsyslog running status is running.
Figure 2 Checking the rsyslog status
Run systemctl status rsyslog to check whether the rsyslog running status is running.
Figure 3 Rsyslog status
Run netstat -anp | grep 514 to check whether the listening function is enabled.
Figure 4 Checking whether listening is enabled
- Configure syslog collection.
- Choose Host Management in the LTS navigation pane and click Create Host Group to create a host group. On the displayed page, enter a host group name and select hosts.
- Choose Log Ingestion in the navigation pane. On the displayed page, click ECS (Elastic Cloud Server).
- Select a log stream.
- Select host groups.
- Set the collection path to /var/log/messages.
- Log in to the service ECS for verification.
After your service system or device generates logs, you can view the logs on the LTS console. Log in to the service ECS and run the logger -n x.x.x.x -P 514 testremotelog command to send syslog messages to the aggregation server. x.x.x.x indicates the IP address (public or private) of the syslog server. testremotelog indicates the log content, which can be customized.
After the command is executed, you can view the log in the configured log group and log stream.
Alternatively, log in to the syslog aggregation server and check whether the testremotelog log exists in /var/log/messages.
tail -f /var/log/messages
Figure 5 Checking whether the testremotelog log exists
- Use multiple syslog servers and load balancers to implement load balancing.
The log processing rate of a single syslog server is 10 MB/s. To process a large number of logs, you can use multiple syslog servers and load balancers.
- Create syslog aggregation servers and install ICAgent.
- Create a load balancer. For details, see Using ELB to Distribute Traffic to a Web Application Across ECSs.
- Add listeners for TCP/UDP ports and port 514. For details, see Adding a Listener.
- Add backend servers to the backend server group. For details, see Backend Server Group.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot