custom metric 추가
This commit is contained in:
@ -6,21 +6,12 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"repositories.action2quare.com/ayo/gocommon/flagx"
|
||||
"repositories.action2quare.com/ayo/houston/client"
|
||||
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/prometheus/common/promlog"
|
||||
"github.com/prometheus/common/promlog/flag"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/prometheus/common/version"
|
||||
"github.com/prometheus/exporter-toolkit/web"
|
||||
"github.com/prometheus/exporter-toolkit/web/kingpinflag"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -33,25 +24,13 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var (
|
||||
toolkitFlags = kingpinflag.AddFlags(kingpin.CommandLine, ":9100")
|
||||
)
|
||||
|
||||
promlogConfig := &promlog.Config{}
|
||||
flag.AddFlags(kingpin.CommandLine, promlogConfig)
|
||||
kingpin.Version(version.Print("node_exporter"))
|
||||
kingpin.CommandLine.UsageWriter(os.Stdout)
|
||||
kingpin.HelpFlag.Short('h')
|
||||
kingpin.Parse()
|
||||
logger := promlog.New(promlogConfig)
|
||||
|
||||
http.Handle("/metrics", client.NewHandlerForNodeExporter(true, 2, logger))
|
||||
|
||||
server := &http.Server{}
|
||||
go web.ListenAndServe(server, toolkitFlags, logger)
|
||||
http.Handle("/metrics", promhttp.Handler())
|
||||
server := &http.Server{Addr: ":9100", Handler: nil}
|
||||
go server.ListenAndServe()
|
||||
|
||||
hc.Start()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
|
||||
server.Shutdown(ctx)
|
||||
cancel()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user