Zabbix与Prometheus集成问询:现有Zabbix系统如何对接Prometheus
Hey there! Combining your existing Zabbix network device monitoring with Prometheus's real-time metrics and robust alerting is a great call—you get the best of both worlds. Here are the most reliable ways to integrate them:
Option 1: Pull Zabbix Metrics into Prometheus with Zabbix Exporter
This is the most common approach: use the official Zabbix Exporter to scrape metrics from your Zabbix server and feed them into Prometheus.
Step 1: Deploy the Zabbix Exporter
You can use Docker for a quick setup:docker run -d -p 9249:9249 \ --name zabbix-exporter \ -e ZABBIX_SERVER=<your-zabbix-server-ip> \ -e ZABBIX_USER=<zabbix-admin-username> \ -e ZABBIX_PASSWORD=<zabbix-admin-password> \ prom/zabbix-exporterOr download the binary from the official repo and run it directly if you prefer not to use containers.
Step 2: Configure Prometheus to Scrape the Exporter
Edit your Prometheus config file (prometheus.yml) and add a new scrape job:scrape_configs: # Existing jobs... - job_name: 'zabbix' static_configs: - targets: ['<zabbix-exporter-ip>:9249'] scrape_interval: 30s # Adjust based on your needsRestart Prometheus to apply the changes.
Step 3: Verify the Integration
Head to the Prometheus UI (usually athttp://<prometheus-ip>:9090), go to the Targets page, and confirm thezabbixjob shows asUP. You can then query metrics likezabbix_host_statusorzabbix_item_valueto see data flowing in.
Option 2: Push Prometheus Metrics to Zabbix
If you want Zabbix to remain the central hub for monitoring visualization and some workflows, you can push Prometheus-collected metrics to Zabbix instead.
Step 1: Use a Tool like
prom2zabbix
This utility converts Prometheus metrics into Zabbix-compatible data and sends them via Zabbix Sender or the Zabbix API. Install it via your package manager or build from source.Step 2: Set Up Zabbix Items/Templates
Create a custom Zabbix template (e.g., "Prometheus Metrics") with items of type Zabbix trapper—these are designed to receive data pushed from external sources. Map each Prometheus metric to a corresponding Zabbix item key.Step 3: Automate the Push
Use a cron job to runprom2zabbixat regular intervals, or set up a webhook from Prometheus Alertmanager to push metrics only when specific conditions are met. For example:prom2zabbix --zabbix-server <zabbix-ip> --zabbix-host <target-host> --prometheus-url <prometheus-ip>:9090 --query 'node_cpu_seconds_total'
Option 3: Bi-Directional Integration (Best of Both)
For full flexibility, combine both approaches:
- Use Zabbix Exporter to pull Zabbix metrics into Prometheus, leveraging Prometheus's powerful PromQL for alerting rules and integration with tools like Grafana for visualization.
- Push Prometheus alerts to Zabbix using Alertmanager's webhook, so you can manage alert history and ticketing workflows in Zabbix.
- Configure Alertmanager for Zabbix Webhook
Edit your Alertmanager config (alertmanager.yml):
Make sure your Zabbix API user has permissions to create events.receivers: - name: 'zabbix-alerts' webhook_configs: - url: 'http://<zabbix-ip>/zabbix/api/v2/events' send_resolved: true http_config: basic_auth: username: '<zabbix-api-user>' password: '<zabbix-api-pass>'
Key Notes to Keep in Mind
- Time Sync: Ensure Zabbix, Prometheus, and all network devices are using NTP to avoid timestamp mismatches in metrics.
- Performance: For large Zabbix deployments, adjust the exporter's scrape interval and limit the number of items/hosts it scrapes to avoid overwhelming your Zabbix server.
- Maintenance: Stick to officially supported tools (like the prom/zabbix-exporter) whenever possible to reduce long-term maintenance overhead.
内容的提问来源于stack exchange,提问作者UMJ




