mirror of
https://github.com/safing/portbase
synced 2025-04-23 18:59:08 +00:00
Improve metric instance detection and pushing
This commit is contained in:
parent
471c3030b7
commit
75d108001b
3 changed files with 7 additions and 3 deletions
|
@ -120,7 +120,7 @@ func writeMetricsTo(ctx context.Context, url string) error {
|
|||
|
||||
func metricsWriter(ctx context.Context) error {
|
||||
pushURL := pushOption()
|
||||
ticker := time.NewTicker(10 * time.Second)
|
||||
ticker := time.NewTicker(1 * time.Minute)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
|
|
|
@ -3,6 +3,7 @@ package metrics
|
|||
import (
|
||||
"flag"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/safing/portbase/config"
|
||||
)
|
||||
|
@ -25,7 +26,10 @@ var (
|
|||
func init() {
|
||||
hostname, err := os.Hostname()
|
||||
if err == nil {
|
||||
defaultInstance = hostname
|
||||
hostname = strings.ReplaceAll(hostname, "-", "")
|
||||
if prometheusFormat.MatchString(hostname) {
|
||||
defaultInstance = hostname
|
||||
}
|
||||
}
|
||||
|
||||
flag.StringVar(&pushFlag, "push-metrics", "", "set default URL to push prometheus metrics to")
|
||||
|
|
|
@ -35,7 +35,7 @@ var (
|
|||
)
|
||||
|
||||
func init() {
|
||||
module = modules.Register("metrics", prep, start, stop, "database", "api")
|
||||
module = modules.Register("metrics", prep, start, stop, "config", "database", "api")
|
||||
}
|
||||
|
||||
func prep() error {
|
||||
|
|
Loading…
Add table
Reference in a new issue