Zabbix is a popular open-source monitoring system that provides a wide range of alert rules. You can collect Zabbix monitoring data into Simple Log Service for centralized querying and analysis.
Prerequisites
-
Zabbix is installed. For more information, see Download and Install Zabbix.
This example uses an Alibaba Cloud ECS instance with Zabbix installed.
-
A Project and a Logstore are created. For more information, see Manage a Project and Create a Basic Logstore.
Step 1: Configure the data storage path
Zabbix stores monitoring data on the machine where it is installed. Configure the data storage path as follows.
-
Log on to the server where Zabbix is installed.
-
Open the zabbix_server.conf file.
vim /etc/zabbix/zabbix_server.conf -
In the zabbix_server.conf file, set the data storage path.
Use the Real-time export feature of Zabbix to export monitoring data, such as events, history, and trends, in JSON format. This feature requires Zabbix 4.0 or later. For more information, see Real-time export.
Avoid using
ExportDir=/tmp/. The/tmpdirectory is often a tmpfs (memory file system). Although it provides fast write speeds, it consumes memory. Exporting a large amount of data, such as high-frequency metrics, may exhaust memory and cause an OOM (Out of Memory) error.ExportDir=/data/zabbix_export -
Restart the Zabbix service for the configuration to take effect.
systemctl restart zabbix-serverAfter the configuration takes effect, Zabbix generates files with the .ndjson extension in the /data/zabbix_export directory.
Step 2: Create a LoongCollector configuration
Log on to the Simple Log Service console.
In the Import Data section, select JSON - Text Log.
-
Select the destination project and Logstore, and then click Next.
-
Create a machine group.
-
Navigate to and click Create Machine Group. In the Create Machine Group panel, select the ECS instances that are in the same region as your Project, and then click Create Machine Group.
If your ECS instance is in a different region from Simple Log Service, or if Zabbix is on a self-managed cluster or a third-party cloud server, you must install LoongCollector manually. For more information, see Install LoongCollector.
In the Select Machine Group step, move the created machine group (such as group-1) from the Source Machine Groups list on the left to the Applied Machine Groups list on the right, and then click Next.
-
Wait for the installation to complete, enter a name, and then click OK.
-
Click Next. If the heartbeat status is FAIL, click Automatic Retry and wait for about two minutes until the status is OK. Then, click Next to automatically install LoongCollector and configure an IP-based machine group. To use a machine group with user-defined identifiers, see Associate a Machine Group with a Collection Configuration.
-
-
Create a collection configuration and click Next.
Zabbix monitoring data is in JSON format, so use JSON mode for data collection. Set Log Path to the data storage path configured in Step 1: Configure the data storage path. For more information about other parameters, see Collect logs in JSON mode.
Configure collection parameters: set the log path to
/tmp, set the file name pattern to*.ndjson, select JSON Mode for Mode, enable the Use System Time switch, and set Maximum Monitor Directory Depth to10. -
Simple Log Service enables full-text indexing by default. You can also create field indexes manually based on the collected logs. Alternatively, click Automatic Index Generation to let Simple Log Service automatically create field indexes. For more information, see Create an Index.
-
Query and analyze logs.
Click Query Log to navigate to the query and analysis page of the Logstore.
Wait about one minute for the index to take effect. You can then view the collected logs on the Raw Logs tab. For detailed instructions, see Quick Start for Log Query and Analysis.
NoteTo query all fields in your logs, use full-text indexing. To query specific fields and reduce index traffic, use field indexes. To analyze fields by using
SELECTstatements, you must create field indexes.