How arthass/sftp-exporter works
sftp-exporter is a Prometheus exporter that reads configured SFTP targets and paths, connects over SSH/SFTP, and exposes connection, filesystem-capacity, and file-count/size metrics over HTTP. The primary flow is configuration and startup, Prometheus scraping /metrics, collection from SFTP, and returning metrics. The README also documents a Grafana dashboard. Source excerpts support the startup and collection wiring; the Grafana query relationship is shown as optional based on the documented dashboard capability.
Main entry points: sftp_collector.go SFTP metrics collector · server.go HTTP server · root.go CLI and config · sftp_client.go SFTP connection
Components 16
Configuration and startup
- CLI and config
cmd/root.go - Configuration keys
pkg/constants/viperkeys/viper_keys.go - Program entry
main.go
HTTP and metrics serving
- HTTP server
pkg/server/server.go - Metrics endpoint
pkg/server/server.go - Health endpoint
pkg/server/server.go
SFTP collection
- SFTP metrics collector
pkg/collector/sftp_collector.go - Filesystem capacity
pkg/collector/sftp_collector.go - File count and size
pkg/collector/sftp_collector.go - SFTP connection
pkg/client/sftp_client.go - SSH authentication
pkg/client/ssh.go
Monitoring integrations
- Prometheus
- Grafana
- Grafana dashboard
grafana/SFTP-1621083257598.json
Other components
- Exporter operator
- SFTP server
Connections 17
- Exporter operator → CLI and config: sets options
- CLI and config → Configuration keys: binds settings
- Program entry → CLI and config: executes
- CLI and config → HTTP server: starts
- HTTP server → SFTP connection: creates
- HTTP server → SFTP metrics collector: registers
- Prometheus → Metrics endpoint: scrapes
- Metrics endpoint → SFTP metrics collector: collects metrics
- HTTP server → Health endpoint: serves
- SFTP metrics collector → SFTP connection: connects and queries
- SFTP metrics collector → Filesystem capacity: emits capacity
- SFTP metrics collector → File count and size: walks paths
- SFTP connection → SSH authentication: opens SSH session
- SSH authentication → SFTP server: authenticates and dials
- SFTP connection → SFTP server: reads SFTP data
- Grafana → Prometheus: queries metrics
- Grafana → Grafana dashboard: uses dashboard