Domain Exporter is a Rust-based tool for monitoring domain expiration. It queries WHOIS information and outputs domain expiration time in Prometheus metrics format.
- Supports multiple WHOIS servers and date formats
- Built-in caching to avoid frequent queries
- Automatic retry mechanism for reliability
- Prometheus metrics output
- Configurable timeout and cache duration
- Embedded WHOIS server configuration
Ensure you have the Rust toolchain installed, then run:
cargo install --git https://github.com/TrisanGus/domain_exporter
Or build from source:
git clone https://github.com/TrisanGus/domain_exporter
cd domain_exporter
cargo build --release
domain_exporter [OPTIONS]
OPTIONS:
--cache-ttl <SECONDS> Cache duration in seconds [default: 86400]
--whois-timeout <SECONDS> WHOIS query timeout in seconds [default: 10]
--listen-addr <ADDR> Server listen address [default: 0.0.0.0:9222]
-h, --help Show help information
-V, --version Show version information
GET /probe?target=example.com
Example response:
# HELP domain_expiry_days Days until domain expiry
# TYPE domain_expiry_days gauge
domain_expiry_days{domain="example.com"} 365
# HELP domain_probe_success Displays whether or not the domain probe was successful
# TYPE domain_probe_success gauge
domain_probe_success{domain="example.com"} 1
The service handles the following error scenarios:
- WHOIS query failure
- Date parsing errors
- Query timeout
- Server busy
Errors are automatically retried (up to 3 times) and appropriate error metrics are returned.
- Successful query results are cached
- Cache duration is configurable (default 24 hours)
- Only valid expiration dates are cached
- Cache is in-memory and cleared on service restart
Add the following configuration to your Prometheus config file:
scrape_configs:
- job_name: 'domain_expiry'
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets:
- example.com
- example.org
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: localhost:9222 # Address of the domain exporter
src/
├── main.rs # Main program entry
├── cache.rs # Cache implementation
├── config.rs # Configuration handling
├── error.rs # Error definitions
└── whois.rs # WHOIS query implementation
# Run tests
cargo test
# Build development version
cargo build
# Build release version
cargo build --release
MIT License
Contributions are welcome! Please submit issues and pull requests.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a pull request
- Build and start the service:
docker-compose up -d
- Check the logs:
docker-compose logs -f
- Stop the service:
docker-compose down
- Build the image:
docker build -t domain-exporter .
- Run the container:
docker run -d -p 9222:9222 domain-exporter
You can configure the exporter using environment variables:
docker run -d \
-p 9222:9222 \
-e CACHE_TTL=86400 \
-e WHOIS_TIMEOUT=10 \
domain-exporter