Logging¶
Configure and analyze logs from the Bindy operator and BIND9 instances.
Operator Logging¶
Log Levels¶
Set log level via RUST_LOG environment variable:
Log Format¶
Set log output format via RUST_LOG_FORMAT environment variable:
Text format (default): - Human-readable compact format - Ideal for development and local debugging - Includes timestamps, file locations, and line numbers
JSON format: - Structured JSON output - Recommended for production Kubernetes deployments - Easy integration with log aggregation tools (Loki, ELK, Splunk) - Enables programmatic log parsing and analysis
Viewing Operator Logs¶
# View recent logs
kubectl logs -n dns-system deployment/bindy --tail=100
# Follow logs in real-time
kubectl logs -n dns-system deployment/bindy -f
# Filter by log level
kubectl logs -n dns-system deployment/bindy | grep ERROR
# Search for specific resource
kubectl logs -n dns-system deployment/bindy | grep "example-com"
BIND9 Instance Logging¶
BIND9 instances are configured by default to log to stderr, making logs available through standard Kubernetes logging commands.
Default Logging Configuration¶
Bindy automatically configures BIND9 with the following logging channels:
- stderr_log: All logs directed to stderr for container-native logging
- Severity: Info level by default (configurable)
- Categories: Default, queries, security, zone transfers (xfer-in/xfer-out)
- Format: Includes timestamps, categories, and severity levels
Viewing BIND9 Logs¶
# Logs from all BIND9 pods
kubectl logs -n dns-system -l app=bind9
# Logs from specific instance
kubectl logs -n dns-system -l instance=primary-dns
# Follow logs
kubectl logs -n dns-system -l instance=primary-dns -f --tail=50
Common Log Messages¶
Successful Zone Load:
Zone Transfer:
Query Logging (if enabled):
Log Aggregation¶
Using Fluentd/Fluent Bit¶
Collect logs to centralized logging:
Using Loki¶
Store and query logs with Grafana Loki:
# Query logs for DNS zone
{namespace="dns-system", app="bind9"} |= "example.com"
# Query for errors
{namespace="dns-system"} |= "ERROR"
Structured Logging¶
JSON Format¶
Enable JSON logging with RUST_LOG_FORMAT=json:
Example JSON output:
{
"timestamp": "2025-11-30T10:00:00.123456Z",
"level": "INFO",
"message": "Reconciling DNSZone: dns-system/example-com",
"file": "dnszone.rs",
"line": 142,
"threadName": "bindy-operator"
}
Text Format¶
Default human-readable format (RUST_LOG_FORMAT=text or unset):
2025-11-30T10:00:00.123456Z dnszone.rs:142 INFO bindy-operator Reconciling DNSZone: dns-system/example-com
Log Retention¶
Configure log retention based on your needs:
- Development: 7 days
- Production: 30-90 days
- Compliance: As required by regulations
Troubleshooting with Logs¶
Find Failed Reconciliations¶
Track Zone Transfer Issues¶
Monitor Resource Creation¶
Best Practices¶
- Use appropriate log levels - info for production, debug for troubleshooting
- Use JSON format in production - Enable structured logging for better integration with log aggregation tools
- Use text format for development - More readable for local debugging and development
- Centralize logs - Use log aggregation for easier analysis
- Set up log rotation - Prevent disk space issues
- Create alerts - Alert on ERROR level logs
- Regular review - Periodically review logs for issues