From 6169b0cbde8bb36f498e61c941039cdaafc0f07e Mon Sep 17 00:00:00 2001 From: Chris Mark Date: Tue, 12 Nov 2019 10:45:56 +0200 Subject: [PATCH] Move light modules to OSS (#14369) (cherry picked from commit 4d1979b9ef15bbd655e575de629aade9008b6500) --- CHANGELOG-developer.next.asciidoc | 1 + metricbeat/beater/metricbeat.go | 34 +++++++++++ metricbeat/cmd/root.go | 18 +----- .../mb/lightmodules.go | 34 +++++++---- .../mb/lightmodules_test.go | 58 +++++++++++-------- .../testdata/lightmodules/broken/module.yml | 0 .../testdata/lightmodules/empty/.placeholder | 0 .../service/metricset/manifest.yml | 0 .../testdata/lightmodules/service/module.yml | 0 .../service/nondefault/manifest.yml | 0 x-pack/metricbeat/beater/metricbeat.go | 20 ------- x-pack/metricbeat/cmd/root.go | 29 +--------- x-pack/metricbeat/module/aws/ebs/ebs_test.go | 3 +- x-pack/metricbeat/module/aws/elb/elb_test.go | 3 +- .../status/status_integration_test.go | 4 +- .../module/cockroachdb/status/status_test.go | 3 +- x-pack/metricbeat/scripts/msetlists/main.go | 3 +- 17 files changed, 103 insertions(+), 107 deletions(-) rename {x-pack/metricbeat => metricbeat}/mb/lightmodules.go (82%) rename {x-pack/metricbeat => metricbeat}/mb/lightmodules_test.go (81%) rename {x-pack/metricbeat => metricbeat}/mb/testdata/lightmodules/broken/module.yml (100%) rename {x-pack/metricbeat => metricbeat}/mb/testdata/lightmodules/empty/.placeholder (100%) rename {x-pack/metricbeat => metricbeat}/mb/testdata/lightmodules/service/metricset/manifest.yml (100%) rename {x-pack/metricbeat => metricbeat}/mb/testdata/lightmodules/service/module.yml (100%) rename {x-pack/metricbeat => metricbeat}/mb/testdata/lightmodules/service/nondefault/manifest.yml (100%) delete mode 100644 x-pack/metricbeat/beater/metricbeat.go diff --git a/CHANGELOG-developer.next.asciidoc b/CHANGELOG-developer.next.asciidoc index 3510a97e842..10f92aa8f83 100644 --- a/CHANGELOG-developer.next.asciidoc +++ b/CHANGELOG-developer.next.asciidoc @@ -26,6 +26,7 @@ The list below covers the major changes between 7.0.0-rc2 and master only. - Need to register new processors to be used in the JS processor in their `init` functions. {pull}13509[13509] - The custom beat generator now uses mage instead of python, `mage GenerateCustomBeat` can be used to create a new beat, and `mage vendorUpdate` to update the vendored libbeat in a custom beat. {pull}13610[13610] - Altered all remaining uses of mapval to use the renamed and enhanced version: https://github.com/elastic/go-lookslike[go-lookslike] instead, which is a separate project. The mapval tree is now gone. {pull}14165[14165] +- Move light modules to OSS. {pull}14369[14369] ==== Bugfixes diff --git a/metricbeat/beater/metricbeat.go b/metricbeat/beater/metricbeat.go index eb8e61f70ab..f071d6e7bff 100644 --- a/metricbeat/beater/metricbeat.go +++ b/metricbeat/beater/metricbeat.go @@ -22,6 +22,7 @@ import ( "github.com/elastic/beats/libbeat/common/reload" "github.com/elastic/beats/libbeat/management" + "github.com/elastic/beats/libbeat/paths" "github.com/joeshaw/multierror" "github.com/pkg/errors" @@ -69,6 +70,14 @@ func WithModuleOptions(options ...module.Option) Option { } } +// WithLightModules enables light modules support +func WithLightModules() Option { + return func(*Metricbeat) { + path := paths.Resolve(paths.Home, "module") + mb.Registry.SetSecondarySource(mb.NewLightModulesSource(path)) + } +} + // Creator returns a beat.Creator for instantiating a new instance of the // Metricbeat framework with the given options. func Creator(options ...Option) beat.Creator { @@ -90,6 +99,7 @@ func Creator(options ...Option) beat.Creator { // ) func DefaultCreator() beat.Creator { return Creator( + WithLightModules(), WithModuleOptions( module.WithMetricSetInfo(), module.WithServiceName(), @@ -97,6 +107,30 @@ func DefaultCreator() beat.Creator { ) } +// DefaultTestModulesCreator returns a customized instance of Metricbeat +// where startup delay has been disabled to workaround the fact that +// Modules() will return the static modules (not the dynamic ones) +// with a start delay. +// +// This is equivalent to calling +// +// beater.Creator( +// beater.WithLightModules(), +// beater.WithModuleOptions( +// module.WithMetricSetInfo(), +// module.WithMaxStartDelay(0), +// ), +// ) +func DefaultTestModulesCreator() beat.Creator { + return Creator( + WithLightModules(), + WithModuleOptions( + module.WithMetricSetInfo(), + module.WithMaxStartDelay(0), + ), + ) +} + // newMetricbeat creates and returns a new Metricbeat instance. func newMetricbeat(b *beat.Beat, c *common.Config, options ...Option) (*Metricbeat, error) { config := defaultConfig diff --git a/metricbeat/cmd/root.go b/metricbeat/cmd/root.go index 9c0d24cc932..d54b72cb464 100644 --- a/metricbeat/cmd/root.go +++ b/metricbeat/cmd/root.go @@ -22,12 +22,10 @@ import ( "github.com/spf13/pflag" - cmd "github.com/elastic/beats/libbeat/cmd" + "github.com/elastic/beats/libbeat/cmd" "github.com/elastic/beats/libbeat/cmd/instance" "github.com/elastic/beats/metricbeat/beater" "github.com/elastic/beats/metricbeat/cmd/test" - "github.com/elastic/beats/metricbeat/mb/module" - // import modules _ "github.com/elastic/beats/metricbeat/include" _ "github.com/elastic/beats/metricbeat/include/fields" @@ -39,22 +37,10 @@ var Name = "metricbeat" // RootCmd to handle beats cli var RootCmd *cmd.BeatsRootCmd -var ( - // Use a customized instance of Metricbeat where startup delay has - // been disabled to workaround the fact that Modules() will return - // the static modules (not the dynamic ones) with a start delay. - testModulesCreator = beater.Creator( - beater.WithModuleOptions( - module.WithMetricSetInfo(), - module.WithMaxStartDelay(0), - ), - ) -) - func init() { var runFlags = pflag.NewFlagSet(Name, pflag.ExitOnError) runFlags.AddGoFlag(flag.CommandLine.Lookup("system.hostfs")) RootCmd = cmd.GenRootCmdWithSettings(beater.DefaultCreator(), instance.Settings{RunFlags: runFlags, Name: Name}) RootCmd.AddCommand(cmd.GenModulesCmd(Name, "", BuildModulesManager)) - RootCmd.TestCmd.AddCommand(test.GenTestModulesCmd(Name, "", testModulesCreator)) + RootCmd.TestCmd.AddCommand(test.GenTestModulesCmd(Name, "", beater.DefaultTestModulesCreator())) } diff --git a/x-pack/metricbeat/mb/lightmodules.go b/metricbeat/mb/lightmodules.go similarity index 82% rename from x-pack/metricbeat/mb/lightmodules.go rename to metricbeat/mb/lightmodules.go index d01d887a72d..f39e8152ca9 100644 --- a/x-pack/metricbeat/mb/lightmodules.go +++ b/metricbeat/mb/lightmodules.go @@ -1,6 +1,19 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. package mb @@ -15,7 +28,6 @@ import ( "github.com/elastic/beats/libbeat/common" "github.com/elastic/beats/libbeat/logp" - "github.com/elastic/beats/metricbeat/mb" ) const ( @@ -105,15 +117,15 @@ func (s *LightModulesSource) HasMetricSet(moduleName, metricSetName string) bool } // MetricSetRegistration obtains a registration for a light metric set -func (s *LightModulesSource) MetricSetRegistration(register *mb.Register, moduleName, metricSetName string) (mb.MetricSetRegistration, error) { +func (s *LightModulesSource) MetricSetRegistration(register *Register, moduleName, metricSetName string) (MetricSetRegistration, error) { lightModule, err := s.loadModule(moduleName) if err != nil { - return mb.MetricSetRegistration{}, errors.Wrapf(err, "failed to load module '%s'", moduleName) + return MetricSetRegistration{}, errors.Wrapf(err, "failed to load module '%s'", moduleName) } ms, found := lightModule.MetricSets[metricSetName] if !found { - return mb.MetricSetRegistration{}, fmt.Errorf("metricset '%s/%s' not found", moduleName, metricSetName) + return MetricSetRegistration{}, fmt.Errorf("metricset '%s/%s' not found", moduleName, metricSetName) } return ms.Registration(register) @@ -141,7 +153,7 @@ type lightModuleConfig struct { // LightModule contains the definition of a light module type LightModule struct { Name string - MetricSets map[string]mb.LightMetricSet + MetricSets map[string]LightMetricSet } func (s *LightModulesSource) loadModule(moduleName string) (*LightModule, error) { @@ -186,8 +198,8 @@ func (s *LightModulesSource) loadModuleConfig(modulePath string) (*lightModuleCo return &moduleConfig, nil } -func (s *LightModulesSource) loadMetricSets(moduleDirPath, moduleName string, metricSetNames []string) (map[string]mb.LightMetricSet, error) { - metricSets := make(map[string]mb.LightMetricSet) +func (s *LightModulesSource) loadMetricSets(moduleDirPath, moduleName string, metricSetNames []string) (map[string]LightMetricSet, error) { + metricSets := make(map[string]LightMetricSet) for _, metricSet := range metricSetNames { manifestPath := filepath.Join(moduleDirPath, metricSet, manifestYML) @@ -203,7 +215,7 @@ func (s *LightModulesSource) loadMetricSets(moduleDirPath, moduleName string, me return metricSets, nil } -func (s *LightModulesSource) loadMetricSetConfig(manifestPath string) (ms mb.LightMetricSet, err error) { +func (s *LightModulesSource) loadMetricSetConfig(manifestPath string) (ms LightMetricSet, err error) { config, err := common.LoadFile(manifestPath) if err != nil { return ms, errors.Wrapf(err, "failed to load metricset manifest from '%s'", manifestPath) diff --git a/x-pack/metricbeat/mb/lightmodules_test.go b/metricbeat/mb/lightmodules_test.go similarity index 81% rename from x-pack/metricbeat/mb/lightmodules_test.go rename to metricbeat/mb/lightmodules_test.go index 71ea2f550a7..e24c5d847eb 100644 --- a/x-pack/metricbeat/mb/lightmodules_test.go +++ b/metricbeat/mb/lightmodules_test.go @@ -1,6 +1,19 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. // +build !integration @@ -15,7 +28,6 @@ import ( "github.com/elastic/beats/libbeat/common" "github.com/elastic/beats/libbeat/logp" - "github.com/elastic/beats/metricbeat/mb" ) // TestLightModulesAsModuleSource checks that registry correctly lists @@ -27,7 +39,7 @@ func TestLightModulesAsModuleSource(t *testing.T) { name string module string isDefault bool - hostParser mb.HostParser + hostParser HostParser } cases := map[string]struct { @@ -77,19 +89,19 @@ func TestLightModulesAsModuleSource(t *testing.T) { }, } - fakeMetricSetFactory := func(base mb.BaseMetricSet) (mb.MetricSet, error) { + fakeMetricSetFactory := func(base BaseMetricSet) (MetricSet, error) { return &base, nil } - newRegistry := func(metricSets []testMetricSet) *mb.Register { - r := mb.NewRegister() + newRegistry := func(metricSets []testMetricSet) *Register { + r := NewRegister() for _, m := range metricSets { - opts := []mb.MetricSetOption{} + opts := []MetricSetOption{} if m.isDefault { - opts = append(opts, mb.DefaultMetricSet()) + opts = append(opts, DefaultMetricSet()) } if m.hostParser != nil { - opts = append(opts, mb.WithHostParser(m.hostParser)) + opts = append(opts, WithHostParser(m.hostParser)) } r.MustAddMetricSet(m.module, m.name, fakeMetricSetFactory, opts...) } @@ -174,7 +186,7 @@ func TestNewModuleFromConfig(t *testing.T) { config common.MapStr err bool expectedOption string - expectedQuery mb.QueryParams + expectedQuery QueryParams expectedPeriod time.Duration }{ "normal module": { @@ -196,7 +208,7 @@ func TestNewModuleFromConfig(t *testing.T) { "light module with query": { config: common.MapStr{"module": "service", "query": common.MapStr{"param": "foo"}}, expectedOption: "test", - expectedQuery: mb.QueryParams{"param": "foo"}, + expectedQuery: QueryParams{"param": "foo"}, }, "light module with custom period": { config: common.MapStr{"module": "service", "period": "42s"}, @@ -217,7 +229,7 @@ func TestNewModuleFromConfig(t *testing.T) { }, } - r := mb.NewRegister() + r := NewRegister() r.MustAddMetricSet("foo", "bar", newMetricSetWithOption) r.SetSecondarySource(NewLightModulesSource("testdata/lightmodules")) @@ -226,7 +238,7 @@ func TestNewModuleFromConfig(t *testing.T) { config, err := common.NewConfigFrom(c.config) require.NoError(t, err) - module, metricSets, err := mb.NewModule(config, r) + module, metricSets, err := NewModule(config, r) if c.err { assert.Error(t, err) return @@ -248,7 +260,7 @@ func TestNewModuleFromConfig(t *testing.T) { assert.Equal(t, c.expectedQuery, ms.Module().Config().Query) expectedPeriod := c.expectedPeriod if expectedPeriod == 0 { - expectedPeriod = mb.DefaultModuleConfig().Period + expectedPeriod = DefaultModuleConfig().Period } assert.Equal(t, expectedPeriod, ms.Module().Config().Period) }) @@ -260,31 +272,31 @@ func TestNewModuleFromConfig(t *testing.T) { func TestNewModulesCallModuleFactory(t *testing.T) { logp.TestingSetup() - r := mb.NewRegister() + r := NewRegister() r.MustAddMetricSet("foo", "bar", newMetricSetWithOption) r.SetSecondarySource(NewLightModulesSource("testdata/lightmodules")) called := false - r.AddModule("foo", func(base mb.BaseModule) (mb.Module, error) { + r.AddModule("foo", func(base BaseModule) (Module, error) { called = true - return mb.DefaultModuleFactory(base) + return DefaultModuleFactory(base) }) config, err := common.NewConfigFrom(common.MapStr{"module": "service"}) require.NoError(t, err) - _, _, err = mb.NewModule(config, r) + _, _, err = NewModule(config, r) assert.NoError(t, err) assert.True(t, called, "module factory must be called if registered") } type metricSetWithOption struct { - mb.BaseMetricSet + BaseMetricSet Option string } -func newMetricSetWithOption(base mb.BaseMetricSet) (mb.MetricSet, error) { +func newMetricSetWithOption(base BaseMetricSet) (MetricSet, error) { config := struct { Option string `config:"option"` }{ @@ -301,4 +313,4 @@ func newMetricSetWithOption(base mb.BaseMetricSet) (mb.MetricSet, error) { }, nil } -func (*metricSetWithOption) Fetch(mb.ReporterV2) error { return nil } +func (*metricSetWithOption) Fetch(ReporterV2) error { return nil } diff --git a/x-pack/metricbeat/mb/testdata/lightmodules/broken/module.yml b/metricbeat/mb/testdata/lightmodules/broken/module.yml similarity index 100% rename from x-pack/metricbeat/mb/testdata/lightmodules/broken/module.yml rename to metricbeat/mb/testdata/lightmodules/broken/module.yml diff --git a/x-pack/metricbeat/mb/testdata/lightmodules/empty/.placeholder b/metricbeat/mb/testdata/lightmodules/empty/.placeholder similarity index 100% rename from x-pack/metricbeat/mb/testdata/lightmodules/empty/.placeholder rename to metricbeat/mb/testdata/lightmodules/empty/.placeholder diff --git a/x-pack/metricbeat/mb/testdata/lightmodules/service/metricset/manifest.yml b/metricbeat/mb/testdata/lightmodules/service/metricset/manifest.yml similarity index 100% rename from x-pack/metricbeat/mb/testdata/lightmodules/service/metricset/manifest.yml rename to metricbeat/mb/testdata/lightmodules/service/metricset/manifest.yml diff --git a/x-pack/metricbeat/mb/testdata/lightmodules/service/module.yml b/metricbeat/mb/testdata/lightmodules/service/module.yml similarity index 100% rename from x-pack/metricbeat/mb/testdata/lightmodules/service/module.yml rename to metricbeat/mb/testdata/lightmodules/service/module.yml diff --git a/x-pack/metricbeat/mb/testdata/lightmodules/service/nondefault/manifest.yml b/metricbeat/mb/testdata/lightmodules/service/nondefault/manifest.yml similarity index 100% rename from x-pack/metricbeat/mb/testdata/lightmodules/service/nondefault/manifest.yml rename to metricbeat/mb/testdata/lightmodules/service/nondefault/manifest.yml diff --git a/x-pack/metricbeat/beater/metricbeat.go b/x-pack/metricbeat/beater/metricbeat.go deleted file mode 100644 index 09069aa2f26..00000000000 --- a/x-pack/metricbeat/beater/metricbeat.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package beater - -import ( - "github.com/elastic/beats/libbeat/paths" - "github.com/elastic/beats/metricbeat/beater" - "github.com/elastic/beats/metricbeat/mb" - xpackmb "github.com/elastic/beats/x-pack/metricbeat/mb" -) - -// WithLightModules enables light modules support -func WithLightModules() beater.Option { - return func(*beater.Metricbeat) { - path := paths.Resolve(paths.Home, "module") - mb.Registry.SetSecondarySource(xpackmb.NewLightModulesSource(path)) - } -} diff --git a/x-pack/metricbeat/cmd/root.go b/x-pack/metricbeat/cmd/root.go index 684ce920f24..0acd6dbdc01 100644 --- a/x-pack/metricbeat/cmd/root.go +++ b/x-pack/metricbeat/cmd/root.go @@ -9,14 +9,12 @@ import ( "github.com/spf13/pflag" - cmd "github.com/elastic/beats/libbeat/cmd" + "github.com/elastic/beats/libbeat/cmd" "github.com/elastic/beats/libbeat/cmd/instance" "github.com/elastic/beats/metricbeat/beater" mbcmd "github.com/elastic/beats/metricbeat/cmd" "github.com/elastic/beats/metricbeat/cmd/test" - "github.com/elastic/beats/metricbeat/mb/module" xpackcmd "github.com/elastic/beats/x-pack/libbeat/cmd" - xpackbeater "github.com/elastic/beats/x-pack/metricbeat/beater" // Register the includes. _ "github.com/elastic/beats/x-pack/metricbeat/include" @@ -32,32 +30,11 @@ var Name = "metricbeat" // RootCmd to handle beats cli var RootCmd *cmd.BeatsRootCmd -var ( - rootCreator = beater.Creator( - xpackbeater.WithLightModules(), - beater.WithModuleOptions( - module.WithMetricSetInfo(), - module.WithServiceName(), - ), - ) - - // Use a customized instance of Metricbeat where startup delay has - // been disabled to workaround the fact that Modules() will return - // the static modules (not the dynamic ones) with a start delay. - testModulesCreator = beater.Creator( - xpackbeater.WithLightModules(), - beater.WithModuleOptions( - module.WithMetricSetInfo(), - module.WithMaxStartDelay(0), - ), - ) -) - func init() { var runFlags = pflag.NewFlagSet(Name, pflag.ExitOnError) runFlags.AddGoFlag(flag.CommandLine.Lookup("system.hostfs")) - RootCmd = cmd.GenRootCmdWithSettings(rootCreator, instance.Settings{RunFlags: runFlags, Name: Name}) + RootCmd = cmd.GenRootCmdWithSettings(beater.DefaultCreator(), instance.Settings{RunFlags: runFlags, Name: Name}) RootCmd.AddCommand(cmd.GenModulesCmd(Name, "", mbcmd.BuildModulesManager)) - RootCmd.TestCmd.AddCommand(test.GenTestModulesCmd(Name, "", testModulesCreator)) + RootCmd.TestCmd.AddCommand(test.GenTestModulesCmd(Name, "", beater.DefaultTestModulesCreator())) xpackcmd.AddXPack(RootCmd, Name) } diff --git a/x-pack/metricbeat/module/aws/ebs/ebs_test.go b/x-pack/metricbeat/module/aws/ebs/ebs_test.go index 3017894f945..6709a935d1d 100644 --- a/x-pack/metricbeat/module/aws/ebs/ebs_test.go +++ b/x-pack/metricbeat/module/aws/ebs/ebs_test.go @@ -8,7 +8,6 @@ import ( "os" "github.com/elastic/beats/metricbeat/mb" - xpackmb "github.com/elastic/beats/x-pack/metricbeat/mb" // Register input module and metricset _ "github.com/elastic/beats/x-pack/metricbeat/module/aws" @@ -18,5 +17,5 @@ import ( func init() { // To be moved to some kind of helper os.Setenv("BEAT_STRICT_PERMS", "false") - mb.Registry.SetSecondarySource(xpackmb.NewLightModulesSource("../../../module")) + mb.Registry.SetSecondarySource(mb.NewLightModulesSource("../../../module")) } diff --git a/x-pack/metricbeat/module/aws/elb/elb_test.go b/x-pack/metricbeat/module/aws/elb/elb_test.go index eb91b04395d..ed2632028ac 100644 --- a/x-pack/metricbeat/module/aws/elb/elb_test.go +++ b/x-pack/metricbeat/module/aws/elb/elb_test.go @@ -8,7 +8,6 @@ import ( "os" "github.com/elastic/beats/metricbeat/mb" - xpackmb "github.com/elastic/beats/x-pack/metricbeat/mb" // Register input module and metricset _ "github.com/elastic/beats/x-pack/metricbeat/module/aws" @@ -18,5 +17,5 @@ import ( func init() { // To be moved to some kind of helper os.Setenv("BEAT_STRICT_PERMS", "false") - mb.Registry.SetSecondarySource(xpackmb.NewLightModulesSource("../../../module")) + mb.Registry.SetSecondarySource(mb.NewLightModulesSource("../../../module")) } diff --git a/x-pack/metricbeat/module/cockroachdb/status/status_integration_test.go b/x-pack/metricbeat/module/cockroachdb/status/status_integration_test.go index ca1e1a9a22b..2dd7a68ed61 100644 --- a/x-pack/metricbeat/module/cockroachdb/status/status_integration_test.go +++ b/x-pack/metricbeat/module/cockroachdb/status/status_integration_test.go @@ -15,8 +15,6 @@ import ( "github.com/elastic/beats/libbeat/tests/compose" "github.com/elastic/beats/metricbeat/mb" mbtest "github.com/elastic/beats/metricbeat/mb/testing" - xpackmb "github.com/elastic/beats/x-pack/metricbeat/mb" - // Register input module and metricset _ "github.com/elastic/beats/metricbeat/module/prometheus" _ "github.com/elastic/beats/metricbeat/module/prometheus/collector" @@ -25,7 +23,7 @@ import ( func init() { // To be moved to some kind of helper os.Setenv("BEAT_STRICT_PERMS", "false") - mb.Registry.SetSecondarySource(xpackmb.NewLightModulesSource("../../../module")) + mb.Registry.SetSecondarySource(mb.NewLightModulesSource("../../../module")) } func TestFetch(t *testing.T) { diff --git a/x-pack/metricbeat/module/cockroachdb/status/status_test.go b/x-pack/metricbeat/module/cockroachdb/status/status_test.go index b796fcf6d9c..7002202b608 100644 --- a/x-pack/metricbeat/module/cockroachdb/status/status_test.go +++ b/x-pack/metricbeat/module/cockroachdb/status/status_test.go @@ -13,7 +13,6 @@ import ( "github.com/elastic/beats/libbeat/logp" "github.com/elastic/beats/metricbeat/mb" mbtest "github.com/elastic/beats/metricbeat/mb/testing" - xpackmb "github.com/elastic/beats/x-pack/metricbeat/mb" // Register input module and metricset _ "github.com/elastic/beats/metricbeat/module/prometheus" @@ -23,7 +22,7 @@ import ( func init() { // To be moved to some kind of helper os.Setenv("BEAT_STRICT_PERMS", "false") - mb.Registry.SetSecondarySource(xpackmb.NewLightModulesSource("../../../module")) + mb.Registry.SetSecondarySource(mb.NewLightModulesSource("../../../module")) } func TestEventMapping(t *testing.T) { diff --git a/x-pack/metricbeat/scripts/msetlists/main.go b/x-pack/metricbeat/scripts/msetlists/main.go index c5994e88b98..c1cb9ef1cc8 100644 --- a/x-pack/metricbeat/scripts/msetlists/main.go +++ b/x-pack/metricbeat/scripts/msetlists/main.go @@ -14,7 +14,6 @@ import ( "github.com/elastic/beats/libbeat/paths" "github.com/elastic/beats/metricbeat/mb" _ "github.com/elastic/beats/x-pack/metricbeat/include" - xpackmb "github.com/elastic/beats/x-pack/metricbeat/mb" ) func main() { @@ -22,7 +21,7 @@ func main() { os.Setenv("BEAT_STRICT_PERMS", "false") path := paths.Resolve(paths.Home, "../x-pack/metricbeat/module") - lm := xpackmb.NewLightModulesSource(path) + lm := mb.NewLightModulesSource(path) mb.Registry.SetSecondarySource(lm) msList := msetlists.DefaultMetricsets()