mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-08 02:24:23 +08:00
add start metrics server
This commit is contained in:
@@ -2,11 +2,14 @@ package stats
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/prometheus/client_golang/prometheus/push"
|
||||
|
||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||
@@ -150,6 +153,14 @@ func LoopPushingMetric(name, instance string, gatherer *prometheus.Registry, add
|
||||
}
|
||||
}
|
||||
|
||||
func StartMetricsServer(gatherer *prometheus.Registry, port int) {
|
||||
if port == 0 {
|
||||
return
|
||||
}
|
||||
http.Handle("/metrics", promhttp.HandlerFor(gatherer, promhttp.HandlerOpts{}))
|
||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), nil))
|
||||
}
|
||||
|
||||
func SourceName(port uint32) string {
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user