Error running the "metricbeat test modules" command: not registered, module not found

Hi ,

Let me introduce you guys to my setup. I have a development environment where a created my own modules with my custom metricsets. I can run the binary mode and see that all is working fine with this command: (./metricbeat -e -d "*"). I also modified my metricbeat.yml file with a file output settings to make sure i'm getting all the data.

All is working fine, but the only problem is when I try the "metricbeat test modules" command. I get this error:

Error getting metricbeat modules: module initialization error: 4 errors: metricset 'datapower/cpuusage' is not registered, module not found; metricset 'datapower/mem_status' is not registered, module not found; metricset 'datapower/conn_accepted' is not registered, module not found; metricset 'datapower/avg_time_processing' is not registered, module not found

It basically says that all my customs metricsets are'nt registered, but they're all working fine?

Is it because the "test modules" command only work with modules that are implemented in the metricbeat source versions and my custom modules with my customs metricsets aren't compatible with this command?

Im running my setup on Ubuntu 16.04.4 LTS,

Is there someone who's using custom modules who's having the same problem or can someone confirm me that the "modules test" command doesn't work if I made my modules and metricsets?

Thank you everyone!
Antoine Adam

It should be working with custom modules, too.
Have you registered it in the init function of the module package?

You should have something like this:

func init() {
    if err := mb.Registry.AddModule("datapower", NewModule); err != nil {
        panic(err)
    }
}

You also need to register metricsets the same way.

Thank you for your fast reply!

I am doing the init function for each metricset:

func init() {
    debugf("Entering function init")
    
	// Register the MetricSetFactory function for the "cpuusage" MetricSet.
	if err := mb.Registry.AddMetricSet("datapower", "cpuusage", NewMetricSet, hostParser); err != nil {
		panic(err)
	}
}

But i wasn't doing the init for my module, so thank you for that ! I just created one for my module relying on the working examples on github ( I saved it under /module/datapower/datapower.go):

package datapower

import (
        "github.com/elastic/beats/metricbeat/mb"
)

func init() {
        // Register the ModuleFactory function for the "datapower" module.
        if err := mb.Registry.AddModule("datapower", NewModule); err != nil {
                panic(err)
        }
}

func NewModule(base mb.BaseModule) (mb.Module, error) {
        // Validate that at least one host has been specified.
        config := struct {
                Hosts []string `config:"hosts"    validate:"nonzero,required"`
        }{}
        if err := base.UnpackConfig(&config); err != nil {
                return nil, err
        }

        return &base, nil
}

I then made the make collect and the make command to make sure everything was fine, but i still get the same error after doing the "metricbeat test modules":

Error getting metricbeat modules: module initialization error: 4 errors: metricset 'datapower/cpuusage' is not registered, module not found; metricset 'datapower/mem_status' is not registered, module not found; metricset 'datapower/conn_accepted' is not registered, module not found; metricset 'datapower/avg_time_processing' is not registered, module not found

Do I need to make another command to make sure my new file is taking into account?

Thanks again !
Antoine Adam

Hi,

Quick update on my problem. The metricbeat test modules is working now!

It seems like the problem was with the path in the development environment, because I still get the same error in DEV, but after I created a custom .deb file with my custom module and installed it on my machine, the metricbeat test modules started working now.

It might be because when I was doing the metricbeat command in DEV, I had to actually be in .../devbeats/src/github.com/elastic/beats/metricbeat/ and it couldn't find the necessary file to check if my modules were good or not.

If someone has another idea why, please do not hesitate to contact me

Thank you :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.