From 0041e43a3c223593b38a301bc62f5fca596a9618 Mon Sep 17 00:00:00 2001 From: Steve Yoon Date: Wed, 6 Apr 2022 13:50:04 -0400 Subject: [PATCH 1/8] support prometheus metrics --- go.mod | 10 ++++- go.sum | 10 +++++ server/core/config/valid/global_cfg.go | 7 +++- server/metrics/scope.go | 55 ++++++++++++++++---------- server/server.go | 8 +++- 5 files changed, 66 insertions(+), 24 deletions(-) diff --git a/go.mod b/go.mod index 373ec6d7e6..36cfc35e76 100644 --- a/go.mod +++ b/go.mod @@ -134,4 +134,12 @@ require ( github.com/uber-go/tally v3.4.3+incompatible ) -require github.com/onsi/ginkgo v1.14.0 // indirect +require ( + github.com/beorn7/perks v1.0.1 // indirect + github.com/m3db/prometheus_client_golang v0.8.1 // indirect + github.com/m3db/prometheus_client_model v0.1.0 // indirect + github.com/m3db/prometheus_common v0.1.0 // indirect + github.com/m3db/prometheus_procfs v0.8.1 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/onsi/ginkgo v1.14.0 // indirect +) diff --git a/go.sum b/go.sum index 4055869c13..15ede29933 100644 --- a/go.sum +++ b/go.sum @@ -87,6 +87,7 @@ github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLj github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= @@ -348,6 +349,14 @@ github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgx github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018 h1:MNApn+Z+fIT4NPZopPfCc1obT6aY3SVM6DOctz1A9ZU= github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018/go.mod h1:sFlOUpQL1YcjhFVXhg1CG8ZASEs/Mf1oVb6H75JL/zg= github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= +github.com/m3db/prometheus_client_golang v0.8.1 h1:t7w/tcFws81JL1j5sqmpqcOyQOpH4RDOmIe3A3fdN3w= +github.com/m3db/prometheus_client_golang v0.8.1/go.mod h1:8R/f1xYhXWq59KD/mbRqoBulXejss7vYtYzWmruNUwI= +github.com/m3db/prometheus_client_model v0.1.0 h1:cg1+DiuyT6x8h9voibtarkH1KT6CmsewBSaBhe8wzLo= +github.com/m3db/prometheus_client_model v0.1.0/go.mod h1:Qfsxn+LypxzF+lNhak7cF7k0zxK7uB/ynGYoj80zcD4= +github.com/m3db/prometheus_common v0.1.0 h1:YJu6eCIV6MQlcwND24cRG/aRkZDX1jvYbsNNs1ZYr0w= +github.com/m3db/prometheus_common v0.1.0/go.mod h1:EBmDQaMAy4B8i+qsg1wMXAelLNVbp49i/JOeVszQ/rs= +github.com/m3db/prometheus_procfs v0.8.1 h1:LsxWzVELhDU9sLsZTaFLCeAwCn7bC7qecZcK4zobs/g= +github.com/m3db/prometheus_procfs v0.8.1/go.mod h1:N8lv8fLh3U3koZx1Bnisj60GYUMDpWb09x1R+dmMOJo= github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= @@ -365,6 +374,7 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mcdafydd/go-azuredevops v0.12.1 h1:WxwLVyGuJ8oL7uWQp1/J6GefX1wMQQZUHWRGsrm+uE8= github.com/mcdafydd/go-azuredevops v0.12.1/go.mod h1:B4UDyn7WEj1/97f45j3VnzEfkWKe05+/dCcAPdOET4A= diff --git a/server/core/config/valid/global_cfg.go b/server/core/config/valid/global_cfg.go index fe17e4b620..a2bdad1684 100644 --- a/server/core/config/valid/global_cfg.go +++ b/server/core/config/valid/global_cfg.go @@ -39,7 +39,8 @@ type GlobalCfg struct { } type Metrics struct { - Statsd *Statsd + Statsd *Statsd + Prometheus *Prometheus } type Statsd struct { @@ -47,6 +48,10 @@ type Statsd struct { Host string } +type Prometheus struct { + Enabled bool +} + // Repo is the final parsed version of server-side repo config. type Repo struct { // ID is the exact match id of this config. diff --git a/server/metrics/scope.go b/server/metrics/scope.go index 023ca64179..ce6633cca1 100644 --- a/server/metrics/scope.go +++ b/server/metrics/scope.go @@ -10,44 +10,57 @@ import ( "github.com/runatlantis/atlantis/server/core/config/valid" "github.com/runatlantis/atlantis/server/logging" "github.com/uber-go/tally" + tallyprom "github.com/uber-go/tally/prometheus" tallystatsd "github.com/uber-go/tally/statsd" ) func NewLoggingScope(logger logging.SimpleLogging, statsNamespace string) (tally.Scope, io.Closer, error) { - reporter, err := newReporter(valid.Metrics{}, logger) + scope, _, closer, err := NewScope(valid.Metrics{}, logger, statsNamespace) + return scope, closer, err +} + +func NewScope(cfg valid.Metrics, logger logging.SimpleLogging, statsNamespace string) (tally.Scope, tally.BaseStatsReporter, io.Closer, error) { + reporter, err := newReporter(cfg, logger) if err != nil { - return nil, nil, errors.Wrap(err, "initializing stats reporter") + return nil, nil, nil, errors.Wrap(err, "initializing stats reporter") } - scope, closer := tally.NewRootScope(tally.ScopeOptions{ - Prefix: statsNamespace, - Reporter: reporter, - }, time.Second) + scopeOpts := tally.ScopeOptions{ + Prefix: statsNamespace, + } + + if r, ok := reporter.(tally.StatsReporter); ok { + scopeOpts.Reporter = r + } else if r, ok := reporter.(tally.CachedStatsReporter); ok { + scopeOpts.CachedReporter = r + scopeOpts.Separator = tallyprom.DefaultSeparator + } else { + return nil, nil, nil, errors.Wrap(err, "invalid stats reporter") + } - return scope, closer, nil + scope, closer := tally.NewRootScope(scopeOpts, time.Second) + return scope, reporter, closer, nil } -func NewScope(cfg valid.Metrics, logger logging.SimpleLogging, statsNamespace string) (tally.Scope, io.Closer, error) { - reporter, err := newReporter(cfg, logger) +func newReporter(cfg valid.Metrics, logger logging.SimpleLogging) (tally.BaseStatsReporter, error) { - if err != nil { - return nil, nil, errors.Wrap(err, "initializing stats reporter") + // return statsd metrics if configured + if cfg.Statsd != nil { + return newStatsReporter(cfg, logger) } - scope, closer := tally.NewRootScope(tally.ScopeOptions{ - Prefix: statsNamespace, - Reporter: reporter, - }, time.Second) + // return prometheus metrics if configured + if cfg.Prometheus != nil && cfg.Prometheus.Enabled { + return tallyprom.NewReporter(tallyprom.Options{}), nil + } + + // return logging reporter and proceed + return newLoggingReporter(logger), nil - return scope, closer, nil } -func newReporter(cfg valid.Metrics, logger logging.SimpleLogging) (tally.StatsReporter, error) { - if cfg.Statsd == nil { - // return logging reporter and proceed - return newLoggingReporter(logger), nil - } +func newStatsReporter(cfg valid.Metrics, logger logging.SimpleLogging) (tally.StatsReporter, error) { statsdCfg := cfg.Statsd diff --git a/server/server.go b/server/server.go index 0d7e750541..822eb5bd92 100644 --- a/server/server.go +++ b/server/server.go @@ -39,6 +39,7 @@ import ( "github.com/runatlantis/atlantis/server/metrics" "github.com/runatlantis/atlantis/server/scheduled" "github.com/uber-go/tally" + "github.com/uber-go/tally/prometheus" assetfs "github.com/elazarl/go-bindata-assetfs" "github.com/gorilla/mux" @@ -94,6 +95,7 @@ type Server struct { CommandRunner *events.DefaultCommandRunner Logger logging.SimpleLogging StatsScope tally.Scope + StatsReporter tally.BaseStatsReporter StatsCloser io.Closer Locker locking.Locker ApplyLocker locking.ApplyLocker @@ -188,7 +190,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { } } - statsScope, closer, err := metrics.NewScope(globalCfg.Metrics, logger, userConfig.StatsNamespace) + statsScope, statsReporter, closer, err := metrics.NewScope(globalCfg.Metrics, logger, userConfig.StatsNamespace) if err != nil { return nil, errors.Wrapf(err, "instantiating metrics scope") @@ -765,6 +767,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { CommandRunner: commandRunner, Logger: logger, StatsScope: statsScope, + StatsReporter: statsReporter, StatsCloser: closer, Locker: lockingClient, ApplyLocker: applyLockingClient, @@ -806,6 +809,9 @@ func (s *Server) Start() error { Queries(LockViewRouteIDQueryParam, fmt.Sprintf("{%s}", LockViewRouteIDQueryParam)).Name(LockViewRouteName) s.Router.HandleFunc("/jobs/{job-id}", s.JobsController.GetProjectJobs).Methods("GET").Name(ProjectJobsViewRouteName) s.Router.HandleFunc("/jobs/{job-id}/ws", s.JobsController.GetProjectJobsWS).Methods("GET") + if r, ok := s.StatsReporter.(prometheus.Reporter); ok { + s.Router.Handle("/metrics", r.HTTPHandler()) + } n := negroni.New(&negroni.Recovery{ Logger: log.New(os.Stdout, "", log.LstdFlags), From e7f80ffb267563993a2d13fe51a15a26686077b4 Mon Sep 17 00:00:00 2001 From: Steve Yoon Date: Wed, 6 Apr 2022 13:58:14 -0400 Subject: [PATCH 2/8] remove redundant error checking --- server/metrics/scope.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/metrics/scope.go b/server/metrics/scope.go index ce6633cca1..d074caaa87 100644 --- a/server/metrics/scope.go +++ b/server/metrics/scope.go @@ -35,8 +35,6 @@ func NewScope(cfg valid.Metrics, logger logging.SimpleLogging, statsNamespace st } else if r, ok := reporter.(tally.CachedStatsReporter); ok { scopeOpts.CachedReporter = r scopeOpts.Separator = tallyprom.DefaultSeparator - } else { - return nil, nil, nil, errors.Wrap(err, "invalid stats reporter") } scope, closer := tally.NewRootScope(scopeOpts, time.Second) From 685be2c2d29529c4e5804e8f05eb95b2b7f837e9 Mon Sep 17 00:00:00 2001 From: Steve Yoon Date: Sun, 17 Apr 2022 12:12:41 -0400 Subject: [PATCH 3/8] load prometheus metrics config --- repos.yaml | 6 ++++++ server/core/config/raw/metrics.go | 25 +++++++++++++++++++++---- server/core/config/raw/metrics_test.go | 13 +++++++++++++ server/core/config/valid/global_cfg.go | 2 +- server/metrics/scope.go | 2 +- server/server.go | 7 +++++-- 6 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 repos.yaml diff --git a/repos.yaml b/repos.yaml new file mode 100644 index 0000000000..79f025460c --- /dev/null +++ b/repos.yaml @@ -0,0 +1,6 @@ +metrics: + statsd: + host: 127.0.0.1 + port: 8080 + prometheus: + enabled: true \ No newline at end of file diff --git a/server/core/config/raw/metrics.go b/server/core/config/raw/metrics.go index 368c6a4dbe..0844e380ad 100644 --- a/server/core/config/raw/metrics.go +++ b/server/core/config/raw/metrics.go @@ -7,7 +7,16 @@ import ( ) type Metrics struct { - Statsd *Statsd `yaml:"statsd" json:"statsd"` + Statsd *Statsd `yaml:"statsd" json:"statsd"` + Prometheus *Prometheus `yaml:"prometheus" json:"prometheus"` +} + +type Prometheus struct { + Endpoint string `yaml:"endpoint" json:"endpoint"` +} + +func (p *Prometheus) Validate() error { + return validation.ValidateStruct(p, validation.Field(&p.Endpoint, validation.Required)) } type Statsd struct { @@ -24,9 +33,11 @@ func (s *Statsd) Validate() error { } func (m Metrics) Validate() error { - return validation.ValidateStruct(&m, - validation.Field(&m.Statsd), + res := validation.ValidateStruct(&m, + validation.Field(&m.Statsd, validation.NilOrNotEmpty), + validation.Field(&m.Prometheus, validation.NilOrNotEmpty), ) + return res } func (m Metrics) ToValid() valid.Metrics { @@ -39,6 +50,12 @@ func (m Metrics) ToValid() valid.Metrics { }, } } - + if m.Prometheus != nil { + return valid.Metrics{ + Prometheus: &valid.Prometheus{ + Endpoint: m.Prometheus.Endpoint, + }, + } + } return valid.Metrics{} } diff --git a/server/core/config/raw/metrics_test.go b/server/core/config/raw/metrics_test.go index 8bf5744edd..aeebc14942 100644 --- a/server/core/config/raw/metrics_test.go +++ b/server/core/config/raw/metrics_test.go @@ -16,6 +16,8 @@ func TestMetrics_Unmarshal(t *testing.T) { statsd: host: 127.0.0.1 port: 8125 +prometheus: + endpoint: /metrics ` var result raw.Metrics @@ -30,6 +32,9 @@ statsd: "statsd": { "host": "127.0.0.1", "port": "8125" + }, + "prometheus": { + "endpoint": "/metrics" } } ` @@ -106,6 +111,14 @@ func TestMetrics_Validate_Error(t *testing.T) { }, }, }, + { + description: "invalid endpoint", + subject: raw.Metrics{ + Prometheus: &raw.Prometheus{ + Endpoint: "", + }, + }, + }, } for _, c := range cases { diff --git a/server/core/config/valid/global_cfg.go b/server/core/config/valid/global_cfg.go index a2bdad1684..c52cc75e6b 100644 --- a/server/core/config/valid/global_cfg.go +++ b/server/core/config/valid/global_cfg.go @@ -49,7 +49,7 @@ type Statsd struct { } type Prometheus struct { - Enabled bool + Endpoint string } // Repo is the final parsed version of server-side repo config. diff --git a/server/metrics/scope.go b/server/metrics/scope.go index d074caaa87..02595f8940 100644 --- a/server/metrics/scope.go +++ b/server/metrics/scope.go @@ -49,7 +49,7 @@ func newReporter(cfg valid.Metrics, logger logging.SimpleLogging) (tally.BaseSta } // return prometheus metrics if configured - if cfg.Prometheus != nil && cfg.Prometheus.Enabled { + if cfg.Prometheus != nil { return tallyprom.NewReporter(tallyprom.Options{}), nil } diff --git a/server/server.go b/server/server.go index 822eb5bd92..a4abfd0b0f 100644 --- a/server/server.go +++ b/server/server.go @@ -809,9 +809,12 @@ func (s *Server) Start() error { Queries(LockViewRouteIDQueryParam, fmt.Sprintf("{%s}", LockViewRouteIDQueryParam)).Name(LockViewRouteName) s.Router.HandleFunc("/jobs/{job-id}", s.JobsController.GetProjectJobs).Methods("GET").Name(ProjectJobsViewRouteName) s.Router.HandleFunc("/jobs/{job-id}/ws", s.JobsController.GetProjectJobsWS).Methods("GET") - if r, ok := s.StatsReporter.(prometheus.Reporter); ok { - s.Router.Handle("/metrics", r.HTTPHandler()) + + r, ok := s.StatsReporter.(prometheus.Reporter) + if ok { + s.Router.Handle(s.CommandRunner.GlobalCfg.Metrics.Prometheus.Endpoint, r.HTTPHandler()) } + s.Router.HandleFunc("/testing", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("OK")) }).Methods("GET") n := negroni.New(&negroni.Recovery{ Logger: log.New(os.Stdout, "", log.LstdFlags), From 55c8dc29cafe390605dfddb9f0cd058999885f8f Mon Sep 17 00:00:00 2001 From: Steve Yoon Date: Sun, 17 Apr 2022 12:22:35 -0400 Subject: [PATCH 4/8] dynamic separator for subscopes --- server/scheduled/runtime_stats.go | 57 +++++++++++++++++-------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/server/scheduled/runtime_stats.go b/server/scheduled/runtime_stats.go index 78836267e4..c75097d36b 100644 --- a/server/scheduled/runtime_stats.go +++ b/server/scheduled/runtime_stats.go @@ -46,38 +46,43 @@ type runtimeMetrics struct { func NewRuntimeStats(scope tally.Scope) *RuntimeStatCollector { runtimeScope := scope.SubScope("runtime") + cpuScope := runtimeScope.SubScope("cpu") + memoryScope := runtimeScope.SubScope("memory") + heapScope := memoryScope.SubScope("heap") + stackScope := memoryScope.SubScope("stack") + gcScope := memoryScope.SubScope("gc") runtimeMetrics := runtimeMetrics{ // cpu - cpuGoroutines: runtimeScope.Gauge("cpu.goroutines"), - cpuCgoCalls: runtimeScope.Gauge("cpu.cgo_calls"), + cpuGoroutines: cpuScope.Gauge("goroutines"), + cpuCgoCalls: cpuScope.Gauge("cgo_calls"), // memory - memoryAlloc: runtimeScope.Gauge("memory.alloc"), - memoryTotal: runtimeScope.Gauge("memory.total"), - memorySys: runtimeScope.Gauge("memory.sys"), - memoryLookups: runtimeScope.Gauge("memory.lookups"), - memoryMalloc: runtimeScope.Gauge("memory.malloc"), - memoryFrees: runtimeScope.Gauge("memory.frees"), + memoryAlloc: memoryScope.Gauge("alloc"), + memoryTotal: memoryScope.Gauge("total"), + memorySys: memoryScope.Gauge("sys"), + memoryLookups: memoryScope.Gauge("lookups"), + memoryMalloc: memoryScope.Gauge("malloc"), + memoryFrees: memoryScope.Gauge("frees"), // heap - memoryHeapAlloc: runtimeScope.Gauge("memory.heap.alloc"), - memoryHeapSys: runtimeScope.Gauge("memory.heap.sys"), - memoryHeapIdle: runtimeScope.Gauge("memory.heap.idle"), - memoryHeapInuse: runtimeScope.Gauge("memory.heap.inuse"), - memoryHeapReleased: runtimeScope.Gauge("memory.heap.released"), - memoryHeapObjects: runtimeScope.Gauge("memory.heap.objects"), + memoryHeapAlloc: heapScope.Gauge("alloc"), + memoryHeapSys: heapScope.Gauge("sys"), + memoryHeapIdle: heapScope.Gauge("idle"), + memoryHeapInuse: heapScope.Gauge("inuse"), + memoryHeapReleased: heapScope.Gauge("released"), + memoryHeapObjects: heapScope.Gauge("objects"), // stack - memoryStackInuse: runtimeScope.Gauge("memory.stack.inuse"), - memoryStackSys: runtimeScope.Gauge("memory.stack.sys"), - memoryStackMSpanInuse: runtimeScope.Gauge("memory.stack.mspan_inuse"), - memoryStackMSpanSys: runtimeScope.Gauge("memory.stack.sys"), - memoryStackMCacheInuse: runtimeScope.Gauge("memory.stack.mcache_inuse"), - memoryStackMCacheSys: runtimeScope.Gauge("memory.stack.mcache_sys"), - memoryOtherSys: runtimeScope.Gauge("memory.othersys"), + memoryStackInuse: stackScope.Gauge("inuse"), + memoryStackSys: stackScope.Gauge("sys"), + memoryStackMSpanInuse: stackScope.Gauge("mspan_inuse"), + memoryStackMSpanSys: stackScope.Gauge("sys"), + memoryStackMCacheInuse: stackScope.Gauge("mcache_inuse"), + memoryStackMCacheSys: stackScope.Gauge("mcache_sys"), + memoryOtherSys: memoryScope.Gauge("othersys"), // GC - memoryGCSys: runtimeScope.Gauge("memory.gc.sys"), - memoryGCNext: runtimeScope.Gauge("memory.gc.next"), - memoryGCLast: runtimeScope.Gauge("memory.gc.last"), - memoryGCPauseTotal: runtimeScope.Gauge("memory.gc.pause_total"), - memoryGCCount: runtimeScope.Gauge("memory.gc.count"), + memoryGCSys: gcScope.Gauge("sys"), + memoryGCNext: gcScope.Gauge("next"), + memoryGCLast: gcScope.Gauge("last"), + memoryGCPauseTotal: gcScope.Gauge("pause_total"), + memoryGCCount: gcScope.Gauge("count"), } return &RuntimeStatCollector{ From 6e8405b05ea96592df2a4dbcce235b3a4ec25c5a Mon Sep 17 00:00:00 2001 From: Steve Yoon Date: Sun, 17 Apr 2022 12:27:33 -0400 Subject: [PATCH 5/8] removing unnecessary config file --- repos.yaml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 repos.yaml diff --git a/repos.yaml b/repos.yaml deleted file mode 100644 index 79f025460c..0000000000 --- a/repos.yaml +++ /dev/null @@ -1,6 +0,0 @@ -metrics: - statsd: - host: 127.0.0.1 - port: 8080 - prometheus: - enabled: true \ No newline at end of file From 85cbf50f54f00ebcf0f024bdaca032044b6278cf Mon Sep 17 00:00:00 2001 From: Steve Yoon Date: Sun, 17 Apr 2022 12:30:17 -0400 Subject: [PATCH 6/8] adding a few more metrics test cases --- server/core/config/raw/metrics_test.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/server/core/config/raw/metrics_test.go b/server/core/config/raw/metrics_test.go index aeebc14942..be9c60018c 100644 --- a/server/core/config/raw/metrics_test.go +++ b/server/core/config/raw/metrics_test.go @@ -52,7 +52,7 @@ func TestMetrics_Validate_Success(t *testing.T) { subject raw.Metrics }{ { - description: "success", + description: "success with stats config", subject: raw.Metrics{ Statsd: &raw.Statsd{ Host: "127.0.0.1", @@ -63,6 +63,26 @@ func TestMetrics_Validate_Success(t *testing.T) { { description: "missing stats", }, + { + description: "success with prometheus config", + subject: raw.Metrics{ + Prometheus: &raw.Prometheus{ + Endpoint: "/metrics", + }, + }, + }, + { + description: "success with both configs", + subject: raw.Metrics{ + Statsd: &raw.Statsd{ + Host: "127.0.0.1", + Port: "8125", + }, + Prometheus: &raw.Prometheus{ + Endpoint: "/metrics", + }, + }, + }, } for _, c := range cases { From e5ef0e32712662f165fc5bb51c852818e57186d9 Mon Sep 17 00:00:00 2001 From: Steve Yoon Date: Mon, 18 Apr 2022 19:36:42 -0400 Subject: [PATCH 7/8] remove testing handler --- server/server.go | 1 - 1 file changed, 1 deletion(-) diff --git a/server/server.go b/server/server.go index a4abfd0b0f..a5c471e0c4 100644 --- a/server/server.go +++ b/server/server.go @@ -814,7 +814,6 @@ func (s *Server) Start() error { if ok { s.Router.Handle(s.CommandRunner.GlobalCfg.Metrics.Prometheus.Endpoint, r.HTTPHandler()) } - s.Router.HandleFunc("/testing", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("OK")) }).Methods("GET") n := negroni.New(&negroni.Recovery{ Logger: log.New(os.Stdout, "", log.LstdFlags), From 59aab1c86ed8761901fe02a6bc685c3e043434ff Mon Sep 17 00:00:00 2001 From: Steve Yoon Date: Wed, 22 Jun 2022 17:34:23 -0400 Subject: [PATCH 8/8] fix upstream merge error --- go.sum | 5 ----- 1 file changed, 5 deletions(-) diff --git a/go.sum b/go.sum index 8444ffca30..7b32c7ec6e 100644 --- a/go.sum +++ b/go.sum @@ -373,7 +373,6 @@ github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018 h1:MNApn+Z+fIT4NPZopPfCc1obT6aY3SVM6DOctz1A9ZU= github.com/lusis/slack-test v0.0.0-20190426140909-c40012f20018/go.mod h1:sFlOUpQL1YcjhFVXhg1CG8ZASEs/Mf1oVb6H75JL/zg= -<<<<<<< HEAD github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= github.com/m3db/prometheus_client_golang v0.8.1 h1:t7w/tcFws81JL1j5sqmpqcOyQOpH4RDOmIe3A3fdN3w= github.com/m3db/prometheus_client_golang v0.8.1/go.mod h1:8R/f1xYhXWq59KD/mbRqoBulXejss7vYtYzWmruNUwI= @@ -383,12 +382,8 @@ github.com/m3db/prometheus_common v0.1.0 h1:YJu6eCIV6MQlcwND24cRG/aRkZDX1jvYbsNN github.com/m3db/prometheus_common v0.1.0/go.mod h1:EBmDQaMAy4B8i+qsg1wMXAelLNVbp49i/JOeVszQ/rs= github.com/m3db/prometheus_procfs v0.8.1 h1:LsxWzVELhDU9sLsZTaFLCeAwCn7bC7qecZcK4zobs/g= github.com/m3db/prometheus_procfs v0.8.1/go.mod h1:N8lv8fLh3U3koZx1Bnisj60GYUMDpWb09x1R+dmMOJo= -github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= -github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -======= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= ->>>>>>> 5da69620cfda5f5ea2b3587581e6ece32269be91 github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=