How python-diamond/diamond works
Diamond is a Python metrics-collection daemon: it polls host and service sources, turns observations into metrics, then routes them to configured publishing handlers. The README highlights system metrics, extensible custom collectors, and Graphite plus other destinations. The graph shows the server, collector framework, metric/queue boundary, and representative output adapters. The source excerpts are partial, so detailed wiring among unsampled collectors and handlers is not asserted.
Main entry points: Handler.py Handler framework · metric.py Metric model · server.py Diamond server · scheduler.py Collector scheduler
Components 21
Metric collection
- Collector API
src/diamond/collector.py - Host collectors
src/collectors/cpu/cpu.py - Service collectors
src/collectors/elasticsearch/elasticsearch.py - Database collectors
src/collectors/postgres/postgres.py - Custom collectors
src/collectors/userscripts/userscripts.py
Daemon runtime
- Diamond server
src/diamond/server.py - Collector scheduler
src/diamond/utils/scheduler.py - Configuration utilities
src/diamond/utils/config.py - Metric model
src/diamond/metric.py - Metric queue
src/diamond/server.py
Metric publishing
- Handler framework
src/diamond/handler/Handler.py - Graphite handler
src/diamond/handler/graphite.py - InfluxDB handler
src/diamond/handler/influxdbHandler.py - HTTP POST handler
src/diamond/handler/httpHandler.py - Librato handler
src/diamond/handler/libratohandler.py
Other components
- Monitored systems
- Service APIs
- Graphite
- InfluxDB
- HTTP endpoint
- Librato
Connections 27
- Diamond server → Configuration utilities: loads settings
- Diamond server → Collector scheduler: manages polling
- Diamond server → Metric queue: creates queue
- Diamond server → Collector API: loads collectors
- Collector scheduler → Host collectors: schedules
- Collector scheduler → Service collectors: schedules
- Collector scheduler → Database collectors: schedules
- Collector scheduler → Custom collectors: schedules
- Monitored systems → Host collectors: read metrics
- Service APIs → Service collectors: query APIs
- Service APIs → Database collectors: query databases
- Collector API → Metric model: publishes metrics
- Host collectors → Metric model: publishes metrics
- Service collectors → Metric model: publishes metrics
- Database collectors → Metric model: publishes metrics
- Custom collectors → Metric model: publishes metrics
- Metric model → Metric queue: queued for dispatch
- Diamond server → Handler framework: loads handlers
- Metric queue → Handler framework: dispatches metrics
- Handler framework → Graphite handler: processes metrics
- Handler framework → InfluxDB handler: processes metrics
- Handler framework → HTTP POST handler: processes metrics
- Handler framework → Librato handler: processes metrics
- Graphite handler → Graphite: publishes
- InfluxDB handler → InfluxDB: publishes
- HTTP POST handler → HTTP endpoint: POSTs batches
- Librato handler → Librato: submits metrics