diff --git a/NOTICE-fips.txt b/NOTICE-fips.txt index 20f465f333..70314a76fc 100644 --- a/NOTICE-fips.txt +++ b/NOTICE-fips.txt @@ -842,11 +842,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-l -------------------------------------------------------------------------------- Dependency : github.com/elastic/elastic-agent-system-metrics -Version: v0.11.15 +Version: v0.13.2 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-system-metrics@v0.11.15/LICENSE.txt: +Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-system-metrics@v0.13.2/LICENSE.txt: Apache License Version 2.0, January 2004 @@ -1053,11 +1053,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-s -------------------------------------------------------------------------------- Dependency : github.com/elastic/go-elasticsearch/v8 -Version: v8.17.1 +Version: v8.19.0 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/go-elasticsearch/v8@v8.17.1/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/elastic/go-elasticsearch/v8@v8.19.0/LICENSE: Apache License Version 2.0, January 2004 @@ -5178,11 +5178,11 @@ SOFTWARE. -------------------------------------------------------------------------------- Dependency : github.com/elastic/elastic-transport-go/v8 -Version: v8.6.1 +Version: v8.7.0 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-transport-go/v8@v8.6.1/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-transport-go/v8@v8.7.0/LICENSE: Apache License Version 2.0, January 2004 diff --git a/NOTICE.txt b/NOTICE.txt index 02fcbd8531..33ea0fe6f4 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -842,11 +842,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-l -------------------------------------------------------------------------------- Dependency : github.com/elastic/elastic-agent-system-metrics -Version: v0.11.15 +Version: v0.13.2 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-system-metrics@v0.11.15/LICENSE.txt: +Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-system-metrics@v0.13.2/LICENSE.txt: Apache License Version 2.0, January 2004 @@ -1053,11 +1053,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-s -------------------------------------------------------------------------------- Dependency : github.com/elastic/go-elasticsearch/v8 -Version: v8.17.1 +Version: v8.19.0 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/go-elasticsearch/v8@v8.17.1/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/elastic/go-elasticsearch/v8@v8.19.0/LICENSE: Apache License Version 2.0, January 2004 @@ -5178,11 +5178,11 @@ SOFTWARE. -------------------------------------------------------------------------------- Dependency : github.com/elastic/elastic-transport-go/v8 -Version: v8.6.1 +Version: v8.7.0 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-transport-go/v8@v8.6.1/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-transport-go/v8@v8.7.0/LICENSE: Apache License Version 2.0, January 2004 diff --git a/go.mod b/go.mod index d3c58d60a3..557d665943 100644 --- a/go.mod +++ b/go.mod @@ -8,8 +8,8 @@ require ( github.com/docker/go-units v0.5.0 github.com/elastic/elastic-agent-client/v7 v7.17.2 github.com/elastic/elastic-agent-libs v0.24.1 - github.com/elastic/elastic-agent-system-metrics v0.11.15 - github.com/elastic/go-elasticsearch/v8 v8.17.1 + github.com/elastic/elastic-agent-system-metrics v0.13.2 + github.com/elastic/go-elasticsearch/v8 v8.19.0 github.com/elastic/go-ucfg v0.8.8 github.com/fxamacker/cbor/v2 v2.8.0 github.com/go-chi/chi/v5 v5.2.3 @@ -52,7 +52,7 @@ require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect - github.com/elastic/elastic-transport-go/v8 v8.6.1 // indirect + github.com/elastic/elastic-transport-go/v8 v8.7.0 // indirect github.com/elastic/go-structform v0.0.12 // indirect github.com/elastic/go-sysinfo v1.15.0 // indirect github.com/elastic/go-windows v1.0.2 // indirect diff --git a/go.sum b/go.sum index 25aa7809f4..f86e97537b 100644 --- a/go.sum +++ b/go.sum @@ -35,12 +35,12 @@ github.com/elastic/elastic-agent-client/v7 v7.17.2 h1:Cl2TeABqWZgW40t5fchGWT/sRk github.com/elastic/elastic-agent-client/v7 v7.17.2/go.mod h1:5irRFqp6HLqtu1S+OeY0jg8x7K6PLL+DW+PwVk1vJnk= github.com/elastic/elastic-agent-libs v0.24.1 h1:kFPpOG5mbdaGRRNXPb2KfEaR65Uoi8nsMbDOKA02/Go= github.com/elastic/elastic-agent-libs v0.24.1/go.mod h1:o/iXtbHYaojpG4BOY7Z3hFMQAgEoqq2owO17JPGpf3A= -github.com/elastic/elastic-agent-system-metrics v0.11.15 h1:RWX0n6LakadsqB6YB2I7AIXyMlEO4qBUGWn4A+aGeKA= -github.com/elastic/elastic-agent-system-metrics v0.11.15/go.mod h1:qiZC5p1hd8te4XVnhh7FkXdcYhxFnl5i9GJpROtf6zo= -github.com/elastic/elastic-transport-go/v8 v8.6.1 h1:h2jQRqH6eLGiBSN4eZbQnJLtL4bC5b4lfVFRjw2R4e4= -github.com/elastic/elastic-transport-go/v8 v8.6.1/go.mod h1:YLHer5cj0csTzNFXoNQ8qhtGY1GTvSqPnKWKaqQE3Hk= -github.com/elastic/go-elasticsearch/v8 v8.17.1 h1:bOXChDoCMB4TIwwGqKd031U8OXssmWLT3UrAr9EGs3Q= -github.com/elastic/go-elasticsearch/v8 v8.17.1/go.mod h1:MVJCtL+gJJ7x5jFeUmA20O7rvipX8GcQmo5iBcmaJn4= +github.com/elastic/elastic-agent-system-metrics v0.13.2 h1:R4ogKHESuWhWTtopnw/aHnBxxSZbxd7KHV4GefdwT2M= +github.com/elastic/elastic-agent-system-metrics v0.13.2/go.mod h1:ezM1kzDUT+vWXFh5oK8QXB/AEB0UoLWqWA8rkRicFFo= +github.com/elastic/elastic-transport-go/v8 v8.7.0 h1:OgTneVuXP2uip4BA658Xi6Hfw+PeIOod2rY3GVMGoVE= +github.com/elastic/elastic-transport-go/v8 v8.7.0/go.mod h1:YLHer5cj0csTzNFXoNQ8qhtGY1GTvSqPnKWKaqQE3Hk= +github.com/elastic/go-elasticsearch/v8 v8.19.0 h1:VmfBLNRORY7RZL+9hTxBD97ehl9H8Nxf2QigDh6HuMU= +github.com/elastic/go-elasticsearch/v8 v8.19.0/go.mod h1:F3j9e+BubmKvzvLjNui/1++nJuJxbkhHefbaT0kFKGY= github.com/elastic/go-structform v0.0.12 h1:HXpzlAKyej8T7LobqKDThUw7BMhwV6Db24VwxNtgxCs= github.com/elastic/go-structform v0.0.12/go.mod h1:CZWf9aIRYY5SuKSmOhtXScE5uQiLZNqAFnwKR4OrIM4= github.com/elastic/go-sysinfo v1.15.0 h1:54pRFlAYUlVNQ2HbXzLVZlV+fxS7Eax49stzg95M4Xw= diff --git a/internal/pkg/api/metrics.go b/internal/pkg/api/metrics.go index 7e4c6f096d..0d1f143816 100644 --- a/internal/pkg/api/metrics.go +++ b/internal/pkg/api/metrics.go @@ -10,23 +10,23 @@ import ( "fmt" "sync" + "github.com/elastic/elastic-agent-system-metrics/report" + "github.com/elastic/fleet-server/v7/version" + "github.com/rs/zerolog" + "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" - "github.com/rs/zerolog" apmprometheus "go.elastic.co/apm/module/apmprometheus/v2" "go.elastic.co/apm/v2" "github.com/elastic/elastic-agent-libs/api" cfglib "github.com/elastic/elastic-agent-libs/config" "github.com/elastic/elastic-agent-libs/monitoring" - "github.com/elastic/elastic-agent-system-metrics/report" - "github.com/elastic/fleet-server/v7/internal/pkg/build" "github.com/elastic/fleet-server/v7/internal/pkg/config" "github.com/elastic/fleet-server/v7/internal/pkg/dl" "github.com/elastic/fleet-server/v7/internal/pkg/limit" "github.com/elastic/fleet-server/v7/internal/pkg/logger" - "github.com/elastic/fleet-server/v7/version" ) var ( @@ -55,11 +55,6 @@ var ( // metrics must be explicitly exposed with a call to InitMetrics // FIXME we have global metrics but an internal and external API; this may lead to some confusion. func init() { - err := report.SetupMetrics(logger.NewZapStub("instance-metrics"), build.ServiceName, version.DefaultVersion) - if err != nil { - zerolog.Ctx(context.TODO()).Error().Err(err).Msg("unable to initialize metrics") // TODO is used because this may logged during the package load - } - registry = newMetricsRegistry("http_server") cntHTTPNew = newCounter(registry, "tcp_open") cntHTTPClose = newCounter(registry, "tcp_close") @@ -78,6 +73,18 @@ func init() { cntFileDeliv.Register(routesRegistry.newRegistry("deliverFile")) cntGetPGP.Register(routesRegistry.newRegistry("getPGPKey")) cntAuditUnenroll.Register(routesRegistry.newRegistry("auditUnenroll")) + + err := report.SetupMetricsOptions(report.MetricOptions{ + Logger: logger.NewZapStub("instance-metrics"), + Name: build.ServiceName, + Version: version.DefaultVersion, + SystemMetrics: monitoring.NewRegistry(), + ProcessMetrics: registry.registry, + }) + if err != nil { + zerolog.Ctx(context.TODO()).Error().Err(err).Msg("unable to initialize metrics") // TODO is used because this may logged during the package load + } + } // metricsRegistry wraps libbeat and prometheus registries @@ -91,7 +98,7 @@ func newMetricsRegistry(name string) *metricsRegistry { reg := monitoring.Default return &metricsRegistry{ fullName: name, - registry: reg.NewRegistry(name), + registry: reg.GetOrCreateRegistry(name), promReg: prometheus.NewRegistry(), } } @@ -103,7 +110,7 @@ func (r *metricsRegistry) newRegistry(name string) *metricsRegistry { } return &metricsRegistry{ fullName: fullName, - registry: r.registry.NewRegistry(name), + registry: r.registry.GetOrCreateRegistry(name), promReg: r.promReg, } }