Skip to content

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_VERSION should be filled with the actual Zabbix address, username, password, version, and type.
  • If COLLECT_TYPE is set to api, the Zabbix API will be called to retrieve data later; otherwise, set it to stream to call Zabbix Stream for data retrieval.
  • Version requirement: Zabbix versions 6.4 and above can use the stream method.

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

wget https://static.guance.com/integrations/zabbix/zabbix-collector.py

Directory structure is as follows:

conf.d/
├── pythond.conf
pythond/
└── zabbix/
  └── zabbix-collector.py

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

  1. Log in to the Func console, click [Script Market], enter the Guance Script Market, and search for: integration_zabbix

  2. Click [Install], then enter the corresponding parameters:

  3. zabbix host
  4. zabbix user
  5. zabbix password
  6. zabbix version

  7. Click [Deploy Startup Script], the system will automatically create the Startup script set and configure the corresponding startup scripts.

  8. 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.

  1. Log in to the Func console, click [Script Market], enter the Guance Script Market, search for: integration_zabbix_stream, and click install;

  2. Create an API. Log in to func, click Management -> Synchronous API (Asynchronous API is recommended) -> Create, in the execution field select the Zabbix Receiver method from the newly imported script, and configure the collection task-related configurations in the parameter specification. The following parameter information needs to be specified:

  3. zabbix_host
  4. zabbix_user
  5. zabbix_passwd
  6. zabbix_version with actual values
  7. base64 is the Zabbix input parameter, fill in INPUT_BY_CALLER here
    {
      "configs": {
        "zabbix_host": "<your-zabbix-host>",
        "zabbix_user": "<your-zabbix-user>",
        "zabbix_passwd": "<your-zabbix-password>",
        "zabbix_version": "7.0",
        "base64": "INPUT_BY_CALLER"
      }
    }
    
  8. 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;

  9. Modify zabbix_server.conf, change StartConnectors to 10, save and restart the zabbix-server service.

toml StartConnectors=10

Feedback

Is this page helpful? ×