Zabbix API/Stream
Collect Zabbix monitoring data by calling Zabbix API/Stream
Installation and Configuration¶
Zabbix supports two methods for data reporting
- Zabbix API: Version requirement
≥ 5.0 - Zabbix Stream: Version requirement
≥ 6.4
Guance supports two methods for collecting Zabbix monitoring data
- DataKit
- DataFlux Function
DataKit Method¶
Configure pythond configuration file¶
Navigate to the DataKit configuration directory conf.d, enter the samples directory, copy pythond.conf.sample to pythond.conf, and modify the following configuration
[[inputs.pythond]]
# Python input name
name = 'zabbix_collect' # required
# System environments to run Python
#envs = ['LD_LIBRARY_PATH=/path/to/lib:$LD_LIBRARY_PATH',]
evns = ['ZABBIX_HOST=http://127.0.0.1/zabbix', 'ZABBIX_USER=Admin', 'ZABBIX_PASSWD=zabbix', 'ZABBIX_VERSION=7.0', 'COLLECT_TYPE=api']
# Python path(recomment abstract Python path)
cmd = "python3" # required. python3 is recommended.
# Python scripts relative path
dirs = ["zabbix"]
- Where
ZABBIX_HOST,ZABBIX_USER,ZABBIX_PASSWD,ZABBIX_VERSIONshould be filled with the actual Zabbix address, username, password, version, and type. - If
COLLECT_TYPEis set toapi, the Zabbix API will be called to retrieve data later; otherwise, set it tostreamto call Zabbix Stream for data retrieval. - Version requirement: Zabbix versions
6.4and above can use thestreammethod.
Copy the script¶
Navigate to the DataKit directory, enter the pythond directory, create a zabbix directory, and download the script to the zabbix directory using the link below
Directory structure is as follows:
Restart DataKit after making the adjustments.
DataFlux Function Method¶
Install Func¶
It is recommended to activate the Guance Integration - Extensions - DataFlux Func (Automata): All prerequisites are automatically installed. Please proceed with the script installation.
For self-deploying Func, refer to Self-deploying Func
Retrieve Metrics via Zabbix API Method¶
-
Log in to the Func console, click [Script Market], enter the Guance Script Market, and search for:
integration_zabbix -
Click [Install], then enter the corresponding parameters:
- zabbix host
- zabbix user
- zabbix password
-
zabbix version
-
Click [Deploy Startup Script], the system will automatically create the
Startupscript set and configure the corresponding startup scripts. -
After enabling, you can see the corresponding automatic trigger configuration in [Management / Automatic Trigger Configuration]. Click [Execute] to run it immediately without waiting for the scheduled time. Wait a moment, then you can check the execution task records and corresponding logs.
Retrieve Metrics via Zabbix Stream Method¶
Retrieving metrics via the Zabbix Stream method requires configuring an executable stream URL for the Zabbix server. Currently, use Function to create an API to generate this URL.
-
Log in to the Func console, click [Script Market], enter the Guance Script Market, search for:
integration_zabbix_stream, and click install; -
Create an API. Log in to func, click
Management -> Synchronous API (Asynchronous API is recommended) -> Create, in the execution field select theZabbix Receivermethod from the newly imported script, and configure the collection task-related configurations in the parameter specification. The following parameter information needs to be specified: - zabbix_host
- zabbix_user
- zabbix_passwd
- zabbix_version with actual values
- base64 is the Zabbix input parameter, fill in
INPUT_BY_CALLERhere -
Create Zabbix Connector
Log in to Zabbix, click
Management -> General -> Connectors, click create connector, enter the URL created in the previous step in the URL field, select Numbers and Floats for the information type, and click add; -
Modify
zabbix_server.conf, changeStartConnectorsto10, save and restart thezabbix-serverservice.
toml
StartConnectors=10