Most monitoring setups fail in one of two ways. Either nothing alerts until a customer calls, or everything alerts all the time and the team learns to ignore it. I've spent a lot of my working time on network and server monitoring, and the setup I keep coming back to splits the job between two tools that are each very good at half of it:
- Zabbix for metrics, availability and alerting: is the server up, is the disk filling, is the service answering?
- The Elastic Stack for logs: what exactly happened, on which host, and how often?
This guide sets up both for a fleet of Linux servers, with the configuration that has kept alerts useful and storage under control at high log volumes.
Why two tools?
You can push metrics into Elasticsearch, and Zabbix can collect some log lines. Both work, but each is stretched:
- Zabbix stores numbers very compactly, keeps long trends cheaply, and has mature alerting: dependencies, escalations, maintenance windows and acknowledgements. Searching free text across millions of log lines isn't its job.
- Elasticsearch is built for exactly that kind of search. Its alerting is capable, but host availability, SNMP devices and per-item trends are where Zabbix is far more convenient.
So the rule of thumb is simple: if it's a number, Zabbix; if it's a sentence, Elastic. The two meet in the alert itself: a Zabbix alert tells you that something is wrong, and a link to the matching Kibana search tells you why.
Part 1: Zabbix for metrics and alerts
Install the agent
Zabbix agent 2 is the current agent. It's written in Go, supports plugins (for example for PostgreSQL, MySQL, Docker and MongoDB) and runs checks concurrently. Add the Zabbix repository for your server's version from zabbix.com/download; keep agents on the same version as the server or older.
wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.0+ubuntu24.04_all.deb
sudo dpkg -i zabbix-release_latest_7.0+ubuntu24.04_all.deb
sudo apt update
sudo apt install -y zabbix-agent2Install the repository through the zabbix-release package rather than writing the apt source line by hand. It also installs the signing key, and hand-written sources are a common cause of "repository has no Release file" errors.
# Who may query this agent (passive checks)
Server=10.0.0.10
# Where to send active checks
ServerActive=10.0.0.10
# Must match the host name in the Zabbix frontend exactly
Hostname=web-01sudo systemctl enable --now zabbix-agent2
sudo ufw allow from 10.0.0.10 to any port 10050 proto tcp # passive checks onlyActive or passive?
- Passive: the server connects to the agent on port 10050 and asks for each value.
- Active: the agent fetches its list of checks from the server and pushes results to port 10051.
Prefer active checks for servers behind NAT or in a cloud where you'd rather not open inbound ports, and for large fleets, because the agents do the scheduling work. Zabbix ships a template for each mode: Linux by Zabbix agent (passive) and Linux by Zabbix agent active. Link one, not both, to each host.
Use auto-registration instead of clicking
Adding fifty hosts by hand doesn't scale. With active agents, set HostMetadata=linux web in the agent config, then create an auto-registration action in the frontend that matches the metadata, adds the host to the right groups and links the template. New servers appear in monitoring a minute after the agent starts.
Make triggers worth waking up for
The default templates are a good start, but their thresholds are generic. Three techniques removed most of our alert noise:
1. Tune with macros, not by editing templates. Templates expose thresholds as user macros, such as {$CPU.UTIL.CRIT} or {$VFS.FS.PUSED.MAX.CRIT}. Override them on a host or host group, and template updates won't wipe your changes.
2. Add hysteresis. A trigger that fires at 90% and recovers at 89.9% will flap all day. Give it a separate recovery condition:
Problem: avg(/web-01/system.cpu.util,5m)>90
Recovery: avg(/web-01/system.cpu.util,10m)<753. Use dependencies and maintenance. If a switch goes down, you want one alert for the switch, not forty for the servers behind it. Make the server triggers depend on the switch's availability trigger. And put hosts into a maintenance period before planned work, so a reboot doesn't page anyone.
Finally, alert on symptoms users feel, such as a web check failing or response time doubling, and treat most resource metrics as warnings to look at during working hours.
Custom checks
When you need a metric no template has, a user parameter turns any command into an item:
# Number of jobs waiting in the app's queue
UserParameter=app.queue.size,/usr/local/bin/queue-sizeRestart the agent, then test it from the server with zabbix_get -s web-01 -k app.queue.size before creating the item. Keep these scripts fast: a check that takes ten seconds blocks others.
Part 2: Elastic for logs
Ship logs with Elastic Agent
Elastic Agent, managed centrally with Fleet, is the recommended way to collect logs today. You install it once per host and configure everything else from Kibana. The System integration collects syslog, auth logs and systemd journal entries out of the box; add integrations for Nginx, PostgreSQL and so on as needed.
Filebeat still works and is fine for a few hosts or very custom setups, but Fleet saves a lot of time as the fleet grows: you change a policy once and every agent picks it up.
Integrations write into data streams named type-dataset-namespace, for example logs-nginx.access-production. Use the namespace to separate environments, so a noisy staging server never shares an index with production.
Parse your own app's logs with an ingest pipeline
For your application's logs, parse them as they arrive, so you can filter by level or user instead of searching raw text. Collect the file with the Custom Logs integration and set its dataset to app, so the lines land in logs-app-default. Suppose a line looks like this:
2026-11-25T10:14:03.120Z ERROR [billing] user=4821 Payment provider timed out after 30000 msAn ingest pipeline splits it into fields:
{
"description": "Parse application log lines",
"processors": [
{
"dissect": {
"field": "message",
"pattern": "%{@timestamp} %{log.level} [%{app.module}] user=%{user.id} %{app.message}"
}
},
{ "date": { "field": "@timestamp", "formats": ["ISO8601"] } },
{ "lowercase": { "field": "log.level" } },
{
"drop": {
"if": "ctx.log?.level == 'debug'",
"description": "Debug lines are useful locally, not worth storing in production"
}
}
],
"on_failure": [
{ "set": { "field": "error.message", "value": "{{ _ingest.on_failure_message }}" } }
]
}A few choices worth explaining:
dissectinstead ofgrok. When the format is fixed,dissectis much faster because it doesn't use regular expressions. Usegrokonly for lines that genuinely vary.- The
@customname. Integration pipelines call a pipeline named<type>-<dataset>@customif it exists. Naming yours that way hooks it in without touching the managed pipelines, so integration upgrades don't overwrite it. on_failure. A line that doesn't match is kept, with the error recorded, instead of being rejected. You can then search forerror.messageto find formats you missed.- Drop early. Every line you drop at ingest is disk, memory and money saved. Debug logs are the first candidate.
Test a pipeline before using it with POST _ingest/pipeline/logs-app@custom/_simulate and a few sample documents.
Control retention with ILM
Logs grow forever unless you decide otherwise. Index lifecycle management (ILM) rolls data through phases and deletes it when it's no longer useful:
{
"policy": {
"phases": {
"hot": {
"actions": {
"rollover": { "max_primary_shard_size": "50gb", "max_age": "1d" }
}
},
"warm": {
"min_age": "7d",
"actions": {
"forcemerge": { "max_num_segments": 1 },
"set_priority": { "priority": 50 }
}
},
"delete": {
"min_age": "30d",
"actions": { "delete": {} }
}
}
}
}- Hot: new data is written here. Rolling over at about 50 GB per primary shard, or daily, keeps shards at a size Elasticsearch handles well.
- Warm: after a week, data is read rarely. Force-merging it into one segment makes it smaller and faster to search. On a multi-node cluster you can also move it to cheaper nodes.
- Delete: after 30 days, it's gone. Pick this number with whoever handles compliance, not by default.
To apply it to a data stream, set index.lifecycle.name to logs-30d in the matching @custom component template (for example logs-app@custom). It applies from the next rollover.
Kibana alerts for logs
Keep log alerts few and specific. Good ones I've used:
- A spike in errors: more than N lines with
log.level: errorfrom one service in five minutes. - Something that should never happen: a specific message such as
Payment provider timed out, or a login asroot. - Silence: no logs at all from a host for 15 minutes. That usually means the agent or the host is down, and it's easy to miss otherwise.
Use an Elasticsearch query rule in Kibana for these, and send them to the same channel as Zabbix alerts, so on-call people look in one place.
Sizing tips from running it at volume
- Give Elasticsearch half the RAM, at most about 31 GB of heap. The rest goes to the file system cache, which Elasticsearch relies on heavily.
- Fewer, bigger shards. Thousands of tiny shards waste memory. Aim for shards in the tens of gigabytes.
- Map fields explicitly for your own logs. Dynamic mapping turns every new JSON key into a field, and a "mapping explosion" can slow down a cluster.
- Keep Zabbix history short and trends long. Raw values for a week or two, hourly trends for a year, is plenty for most items and keeps the Zabbix database small.
- Monitor the monitoring. Point Zabbix at the Elasticsearch cluster's health and disk usage. A full disk on the log cluster is a classic silent failure.
FAQ
Should I use Zabbix or the Elastic Stack for monitoring?
Use both if you can: Zabbix for metrics, availability and alerting, and Elastic for collecting and searching logs. If you have to pick one, choose by what you need most: Zabbix for infrastructure health, Elastic for log analysis.
What's the difference between Zabbix agent and agent 2?
Agent 2 is the newer agent, written in Go. It supports plugins for databases and services, runs checks concurrently, and is the recommended agent for new installs. Both work with the same server and templates.
How do I reduce false alerts in Zabbix?
Tune thresholds with macros on hosts or groups, add recovery expressions so triggers don't flap, use trigger dependencies so one outage produces one alert, and schedule maintenance periods for planned work.
How long should I keep logs in Elasticsearch?
As long as you actually use them, and as long as any compliance rules require. 7 to 30 days in fast storage covers most troubleshooting. Use an ILM delete phase so old data is removed automatically.
Elastic Agent or Filebeat?
Elastic Agent with Fleet is the recommended choice for new setups: one agent per host, configured centrally from Kibana. Filebeat is still supported and works well for a few hosts or very custom pipelines.