fix prom allowed chars
This commit is contained in:
parent
7907ee3579
commit
1ae32d638b
1 changed files with 8 additions and 2 deletions
|
@ -2,9 +2,11 @@ package metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -19,7 +21,11 @@ var (
|
||||||
func getHostname() string {
|
func getHostname() string {
|
||||||
hostname, err := os.Hostname()
|
hostname, err := os.Hostname()
|
||||||
if err != nil {
|
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, "_")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue