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 with stages
in 3 minutes and 22 seconds
...@@ -70,6 +70,13 @@ func main() { ...@@ -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 // infinite loop
log.Printf("Entering infinite loop") log.Printf("Entering infinite loop")
select {} select {}
......
...@@ -27,6 +27,7 @@ import ( ...@@ -27,6 +27,7 @@ import (
"sync" "sync"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"code.vereign.com/code/viam-apis/errors" "code.vereign.com/code/viam-apis/errors"
...@@ -258,3 +259,19 @@ func StartRESTServer(address, grpcAddress string, certPEM []byte) error { ...@@ -258,3 +259,19 @@ func StartRESTServer(address, grpcAddress string, certPEM []byte) error {
return nil 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.
Finish editing this message first!
Please register or to comment