Skip to content
Snippets Groups Projects
Select Git revision
  • a6830bcf1ed3c2b36def72dd1a5fbfdb315829f0
  • master default
2 results

resolve_duplicates.py

Blame
  • main.go 958 B
    package main
    
    import (
    	"flag"
    	"net/http"
    	"os"
    	"os/signal"
    
    	"github.com/prometheus/client_golang/prometheus"
    )
    
    var (
    	listenAddress = flag.String("web.listen-address", ":9104", "Address to listen on for web interface and telemetry.")
    	metricPath    = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.")
    )
    
    func main() {
    	flag.Parse()
    	exporter := newRsyslogExporter()
    
    	go func() {
    		c := make(chan os.Signal, 1)
    		signal.Notify(c, os.Interrupt)
    		<-c
    		os.Exit(0)
    	}()
    
    	go func() {
    		exporter.run()
    	}()
    
    	prometheus.MustRegister(exporter)
    	http.Handle(*metricPath, prometheus.Handler())
    	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    		w.Write([]byte(`<html>
    <head><title>Rsyslog exporter</title></head>
    <body>
    <h1>Rsyslog exporter</h1>
    <p><a href='` + *metricPath + `'>Metrics</a></p>
    </body>
    </html>
    `))
    	})
    
    	err := http.ListenAndServe(*listenAddress, nil)
    	if err != nil {
    		panic(err)
    	}
    }