Skip to content
Snippets Groups Projects
Commit ace8dace authored by Gospodin Bodurov's avatar Gospodin Bodurov
Browse files

Start prometheus

parent f4cefc5b
No related branches found
No related tags found
1 merge request!62Prometheus integration
Pipeline #27272 failed
......@@ -70,6 +70,13 @@ func main() {
}
}()
go func() {
err := server.StartPrometheusServer()
if err != nil {
log.Printf("failed to start prometheus server: %v", err)
}
}()
// infinite loop
log.Printf("Entering infinite loop")
select {}
......
......@@ -27,6 +27,7 @@ import (
"sync"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"code.vereign.com/code/viam-apis/errors"
......@@ -258,3 +259,19 @@ func StartRESTServer(address, grpcAddress string, certPEM []byte) error {
return nil
}
func StartPrometheusServer() error {
if config.PrometeusListenAddress != "" {
// start prometheus
promHandler := http.NewServeMux()
promHandler.Handle("/metrics", promhttp.Handler())
log.Println("Starting prometheus...")
err := http.ListenAndServe(config.PrometeusListenAddress, promHandler)
if err != nil {
return err
}
}
return nil
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment