diff --git a/metrics/metrics.go b/metrics/metrics.go index 1b5fb12..c978430 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -2,9 +2,11 @@ package metrics import ( "os" + "regexp" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" + log "github.com/sirupsen/logrus" ) var ( @@ -19,7 +21,11 @@ var ( func getHostname() string { hostname, err := os.Hostname() if err != nil { - hostname = "ytsync-unknown" + hostname = "ytsync_unknown" } - return hostname + reg, err := regexp.Compile("[^a-zA-Z0-9_]+") + if err != nil { + log.Fatal(err) + } + return reg.ReplaceAllString(hostname, "_") }