docker.recipes

Collectd

intermediate

System statistics collection daemon with extensive plugin support.

Overview

Collectd is a lightweight system statistics collection daemon originally developed by Florian Forster in 2005, designed to gather performance metrics from systems and applications with minimal overhead. The daemon operates on a plugin-based architecture, supporting over 100 plugins for monitoring everything from basic system resources (CPU, memory, disk I/O) to complex application metrics, network statistics, and hardware sensors. Its modular design allows administrators to enable only the metrics they need, keeping resource consumption low while providing comprehensive monitoring capabilities. This monitoring stack combines collectd's efficient data collection with Graphite's powerful time-series database and visualization engine. Collectd continuously gathers metrics from the host system and applications, then forwards them to Graphite's Carbon daemon via the network write plugin. Graphite stores these metrics in its Whisper database format and provides a web-based dashboard for creating graphs, setting up alerts, and analyzing historical trends. The integration eliminates the complexity of manual metric forwarding and provides immediate visualization of collected data. System administrators managing multiple servers, DevOps teams implementing observability practices, and infrastructure engineers building monitoring solutions will find this stack particularly valuable. The combination offers enterprise-grade monitoring capabilities without the complexity and resource overhead of larger solutions like Prometheus or commercial monitoring platforms. Home lab enthusiasts and small businesses can deploy comprehensive system monitoring with minimal configuration, while larger organizations can use this as a foundation for custom monitoring workflows or as a lightweight alternative to heavier monitoring stacks.

Key Features

  • Over 100 collectd plugins including CPU, memory, disk, network, Apache, MySQL, PostgreSQL, and custom application metrics
  • Carbon line protocol ingestion on port 2003 for high-throughput metric collection from multiple collectd instances
  • StatsD UDP endpoint on port 8125 for application-level custom metrics and counters
  • Whisper time-series database with configurable retention policies and data aggregation
  • Web-based Graphite composer for creating custom dashboards and metric correlation graphs
  • Collectd's write plugins support for batching and buffering metrics to prevent data loss during network issues
  • Graphite's functions API for mathematical operations, moving averages, and derivative calculations on metrics
  • Plugin-based architecture allowing selective metric collection to minimize resource overhead

Common Use Cases

  • 1Infrastructure monitoring for Linux/Unix servers with detailed system performance metrics
  • 2Application performance monitoring using collectd's application-specific plugins (Apache, Nginx, databases)
  • 3Home lab monitoring setup for enthusiasts tracking multiple self-hosted services and hardware
  • 4Development environment monitoring to track resource usage during testing and optimization
  • 5Small to medium business server monitoring without enterprise monitoring tool licensing costs
  • 6Custom metric collection from IoT devices or embedded systems using collectd's network protocols
  • 7Historical performance analysis and capacity planning using Graphite's long-term data retention

Prerequisites

  • Docker host with at least 1GB RAM (Graphite can be memory-intensive with large datasets)
  • Port 80 available for Graphite web interface access
  • Ports 2003 (Carbon) and 8125 (StatsD) available for metric ingestion
  • Understanding of collectd plugin configuration and metric naming conventions
  • Basic knowledge of Graphite's dot-notation metric paths and retention policies
  • Sufficient disk space for time-series data storage (plan for metric volume × retention period)

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 collectd:
3 image: collectd/collectd:latest
4 container_name: collectd
5 restart: unless-stopped
6 volumes:
7 - ./collectd/collectd.conf:/etc/collectd/collectd.conf:ro
8 networks:
9 - collectd-network
10
11 graphite:
12 image: graphiteapp/graphite-statsd:latest
13 container_name: graphite
14 restart: unless-stopped
15 volumes:
16 - graphite_data:/opt/graphite/storage
17 ports:
18 - "80:80"
19 - "2003:2003"
20 - "8125:8125/udp"
21 networks:
22 - collectd-network
23
24volumes:
25 graphite_data:
26
27networks:
28 collectd-network:
29 driver: bridge

.env Template

.env
1# Collectd configuration file required

Usage Notes

  1. 1Docs: https://collectd.org/documentation.shtml
  2. 2Graphite dashboard at http://localhost:80
  3. 3Carbon line protocol on port 2003 for metrics ingestion
  4. 4StatsD on UDP 8125 for application metrics
  5. 5Create ./collectd/collectd.conf with LoadPlugin directives
  6. 6100+ plugins: CPU, memory, disk, network, sensors, and more

Individual Services(2 services)

Copy individual services to mix and match with your existing compose files.

collectd
collectd:
  image: collectd/collectd:latest
  container_name: collectd
  restart: unless-stopped
  volumes:
    - ./collectd/collectd.conf:/etc/collectd/collectd.conf:ro
  networks:
    - collectd-network
graphite
graphite:
  image: graphiteapp/graphite-statsd:latest
  container_name: graphite
  restart: unless-stopped
  volumes:
    - graphite_data:/opt/graphite/storage
  ports:
    - "80:80"
    - "2003:2003"
    - 8125:8125/udp
  networks:
    - collectd-network

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 collectd:
5 image: collectd/collectd:latest
6 container_name: collectd
7 restart: unless-stopped
8 volumes:
9 - ./collectd/collectd.conf:/etc/collectd/collectd.conf:ro
10 networks:
11 - collectd-network
12
13 graphite:
14 image: graphiteapp/graphite-statsd:latest
15 container_name: graphite
16 restart: unless-stopped
17 volumes:
18 - graphite_data:/opt/graphite/storage
19 ports:
20 - "80:80"
21 - "2003:2003"
22 - "8125:8125/udp"
23 networks:
24 - collectd-network
25
26volumes:
27 graphite_data:
28
29networks:
30 collectd-network:
31 driver: bridge
32EOF
33
34# 2. Create the .env file
35cat > .env << 'EOF'
36# Collectd configuration file required
37EOF
38
39# 3. Start the services
40docker compose up -d
41
42# 4. View logs
43docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/collectd/run | bash

Troubleshooting

  • Collectd plugins not loading: Verify plugin dependencies are available in container and LoadPlugin directives are correct in collectd.conf
  • Metrics not appearing in Graphite: Check Carbon logs for connection issues and verify collectd write_graphite plugin target matches Carbon listener port 2003
  • High memory usage in Graphite: Adjust storage-schemas.conf retention policies to reduce data points stored and enable carbon cache limiting
  • Collectd daemon exits with plugin errors: Review collectd logs for missing plugin dependencies or configuration syntax errors in collectd.conf
  • Dashboard graphs showing gaps: Verify collectd interval settings match Graphite's storage schema intervals to prevent data aggregation issues
  • Permission denied errors: Ensure collectd container has proper read access to system metrics if mounting host filesystem paths

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Components

collectdgraphite

Tags

#collectd#metrics#system#daemon#plugins

Category

Monitoring & Observability
Ad Space