Prometheus exporter for NixOS-specific metrics including: - Generation collector: count, current, booted, age, config mismatch - Flake collector: input age, input info, revision behind Includes NixOS module, flake packaging, and documentation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
32 lines
815 B
Go
32 lines
815 B
Go
package config
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
type Config struct {
|
|
ListenAddr string
|
|
FlakeCollector bool
|
|
FlakeURL string
|
|
FlakeCheckInterval time.Duration
|
|
}
|
|
|
|
func Parse() (*Config, error) {
|
|
cfg := &Config{}
|
|
|
|
flag.StringVar(&cfg.ListenAddr, "listen", ":9971", "Address to listen on")
|
|
flag.BoolVar(&cfg.FlakeCollector, "collector.flake", false, "Enable flake collector")
|
|
flag.StringVar(&cfg.FlakeURL, "flake.url", "", "Flake URL for revision comparison (required if flake collector enabled)")
|
|
flag.DurationVar(&cfg.FlakeCheckInterval, "flake.check-interval", time.Hour, "Interval between remote flake checks")
|
|
|
|
flag.Parse()
|
|
|
|
if cfg.FlakeCollector && cfg.FlakeURL == "" {
|
|
return nil, fmt.Errorf("--flake.url is required when --collector.flake is enabled")
|
|
}
|
|
|
|
return cfg, nil
|
|
}
|