Monitoring - agent-based vs agentless
Introduction
Monitoring systems offer different approaches to collecting metrics. I'll focus on two - agent-based and agentless. In this article, I'll analyze both approaches, their advantages and disadvantages.
Agent-based: how it works
Agent-based monitoring relies on a simple concept: we install a dedicated application (agent) on each monitored device, which collects data and sends it to a central server.
Tip
The server receiving the data can consist of multiple servers that balance the load between them
graph LR
A[Agent on server 1] --> C[Central monitoring server]
B[Agent on server 2] --> C
D[Agent on server 3] --> C
C --> E[Dashboard/Alerts]
Advantages of agent-based approach
Key benefits
- Rich set of metrics - access to detailed system data
- Accuracy - data collected directly at the source
- Lower network load - data can be pre-processed and aggregated
- Security - usually offers encrypted communication
- Offline operation - some agents can buffer data when connection to server is interrupted
Disadvantages of agent-based approach
Challenges
- Agent infrastructure management - installation, updates, and configuration on each device
- Monitored system load - each agent consumes system resources
- Compatibility - agents aren't always available for all operating systems
- Scalability - managing agents in very large environments can be challenging
Agentless: how it works
Agentless monitoring, as the name suggests, doesn't require installing dedicated software on monitored devices. Instead, it uses existing protocols and interfaces available in monitored systems.
graph LR
C[Central monitoring server] -- SNMP --> A[Server 1]
C -- SSH --> B[Server 2]
C -- API/HTTP --> D[Server 3]
C --> E[Dashboard/Alerts]
Advantages
Key benefits
- Easy deployment - no need to install additional software
- Lower performance impact - doesn't consume as many resources
- Central management - configuration from monitoring server level
- Universality - easier to monitor heterogeneous environments
- Instant deployment - ability to quickly add new systems to monitoring
Disadvantages
Challenges
- Limited metric access - only those available through standard interfaces
- Higher network load - more frequent network polling
- Requires mature infrastructure - thoughtful port management or access accounts
- Network dependency - no data buffering during network issues
Exposing statistics via HTTP/JSON
In microservice architectures, we often see an approach where applications expose their metrics in a standardized format via HTTP, usually in JSON format.
Example JSON metrics format
Advantages of HTTP/JSON approach
- Standardization - universal format understood by most tools
- Easy integration - practically every programming language can generate JSON
- Flexibility - ability to define custom application-specific metrics
- Security - ability to secure endpoints with standard mechanisms (TLS, authorization)
- Scalability - works well for both small and large infrastructures
Popular monitoring systems
Zabbix
Zabbix is a comprehensive open-source monitoring solution that offers both agent-based and agentless monitoring.
Agent mode:
- Dedicated Zabbix agent installed on monitored systems
- Rich set of system metrics
- Ability to execute custom scripts
- Low resource usage
Agentless Mode:
- Support for SNMP, IPMI, JMX
- Monitoring via SSH
- Network service polling (HTTP, FTP, SMTP, etc.)
Zabbix in practice
Zabbix works excellently in heterogeneous environments where some systems can have agents installed while others must be monitored agentlessly.
Prometheus
Prometheus is a monitoring system that has gained huge popularity in container and Kubernetes environments. It operates mainly in agentless mode but uses the concept of "exporters".
Key features:
- Pull model (server queries metric sources)
- Exporters instead of traditional agents
- Text-based metric exposure format
- Good PromQL query language
- Native Grafana integration (dashboards)
- Alert and notification support
Example Prometheus metrics endpoint:
# HELP http_requests_total Total number of HTTP requests
# TYPE http_requests_total counter
http_requests_total{method="post",code="200"} 1027
http_requests_total{method="post",code="400"} 3
http_requests_total{method="get",code="200"} 9836
http_requests_total{method="get",code="404"} 12
# HELP http_request_duration_seconds HTTP request latency in seconds
# TYPE http_request_duration_seconds histogram
http_request_duration_seconds_bucket{le="0.05"} 24054
http_request_duration_seconds_bucket{le="0.1"} 33444
http_request_duration_seconds_bucket{le="0.2"} 100392
http_request_duration_seconds_bucket{le="+Inf"} 144320
http_request_duration_seconds_sum 53423
http_request_duration_seconds_count 144320
Choosing the right approach
The decision to choose agent-based or agentless monitoring should be dictated by the specifics of your environment.
Agent-based monitoring works better when:
- You need detailed system metrics
- You're monitoring critical systems requiring precise measurements
- You have resources to manage agent infrastructure
Agentless monitoring will be a better choice when:
- Quick deployment and ease of maintenance are priorities
- You're monitoring a dynamic environment with frequent changes
- You can't install additional software on monitored systems
Hybrid approach
In practice, the most effective monitoring solutions use a hybrid approach, combining the advantages of both methods:
- Using agents for key systems requiring precise monitoring
- Using agentless monitoring for quick detection of new resources
- Using HTTP/JSON API for microservices and modern applications
- Combining data from different sources into one coherent visualization system
Summary
The choice between agent-based and agentless monitoring isn't binary (true/false) - monitoring systems offer flexibility in data collection methods. The key to success is knowing your IT environment's specifics and selecting appropriate tools that meet your needs.
Regardless of the chosen approach, a well-designed monitoring system should provide:
- Comprehensive insight into infrastructure and applications
- Problem detection before they affect users
- Historical data for trend analysis and capacity planning
- Scalability with infrastructure growth
When choosing a monitoring solution, it's worth considering both current needs and future IT infrastructure development directions.