package main import ( "flag" "log" "net/http" "github.com/prometheus/client_golang/prometheus" promlibvirt "sdstack.com/sdstack/prometheus-libvirt" ) func main() { var ( listenAddress = flag.String("web.listen-address", ":9177", "Address to listen on for web interface and telemetry.") metricsPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.") libvirtURI = flag.String("libvirt.uri", "qemu:///system", "Libvirt URI from which to extract metrics.") ) flag.Parse() exporter, err := promlibvirt.NewLibvirtExporter(*libvirtURI) if err != nil { panic(err) } prometheus.MustRegister(exporter) http.Handle(*metricsPath, prometheus.Handler()) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte(` Libvirt Exporter

Libvirt Exporter

Metrics

`)) }) log.Fatal(http.ListenAndServe(*listenAddress, nil)) }