This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Run tests
go test -v ./...
# Build locally
go build -o exporter
# Build Docker image
docker build -t rsync-exporter .
# Run the exporter (requires log file)
./exporterRSYNC_EXPORTER_PORT- HTTP port for metrics (default: 9150)RSYNC_LOG_PATH- Path to rsync log file (default: /logs/rsync.log)
Single-file Go application that:
- Tails an rsync log file watching for stats output
- Parses
sent X bytes received Y bytesandtotal size is Zlines - Exposes parsed values as Prometheus gauges on
/metrics
Key functions in main.go:
parseBytesToken()- Converts byte strings with units (K/M/G/T, KB/MiB/etc) to float64parseLogLine()- Extracts sent/received/total metrics from log linestailLogFile()- Handles log tailing with rotation/truncation detection
The exporter handles logrotate by detecting inode changes and file truncation.