Execute a custom SQL query using mysql metricbeat module

I want to run a custom SQL query (to get the count of records in a table) using mysql metricbeat module. Is this possible?

If this is not possible, then I want to create a custom metricset in mysql metricbeat module using the command "make create-metricset" but I dont know what is the location of Beat directory? (I tried /usr/share/metricbeat, /usr/share/metricbeat/bin, /etc/metricbeat but none of them worked)

Also, Where can I view the configuration (({metricset}.go, _meta/docs.asciidoc, meta/data.json, _meta/fields.yml)) for existing metricsets like the "status" metricset of mysql metricbeat module?

It is not possible to run a custom SQL query right now using the MySQL module.

To generate a new metricset, you need to clone our repository: https://github.com/elastic/beats
You need to run make create-metricset inside the metricbeat folder of the repository. The default value of the path of the beats directory would be sufficient in this case. This make target generates and copies the files you mentioned in your comment.

Hi Kvch,
What should be the GOPATH and GOROOT environment variable values?

Also, after I create the metricset, how do I install the new package in Linux machine. Earlier I have used the rpm package to deploy metricbeat in CentOS

@firstpostcommenter You should take a look at our contributing guide to get your environment configured.

Hi @pierhugues,
How to do a build in local machine, since I get the error that the package "github.com/elastic/beats/metricbeat/cmd" is not found when I try to run the main.go file present in metricbeat folder using the command go run main.go

If you have following the instruction in the documentation $GOROOT and $GOPATH, should be set correct.

After that inside the metricbeat directory you should be able to run make which will create the metricbeat binary.

Hi @pierhugues,
When I try to run make command in the metricbeat directory I get the below error. I am running in windows:
: 67.6% of statements
ok github.com/elastic/beats/metricbeat/module/vsphere/virtualmachine
1.363s coverage: 39.8% of statements
ok github.com/elastic/beats/metricbeat/module/windows/service 1.517s
coverage: 74.9% of statements
command [go test -race -cover -coverprofile C:\Users{user}\AppData\Local\Temp
gotestcover-004682626 github.com/elastic/beats/metricbeat/module/windows/perfmon
]: exit status 1
--- FAIL: TestData (0.83s)
modules.go:77: failed to create new MetricSet 1 error: initialization of
reader failed: failed to add counter (query="\FileSystem Disk Activity(_Total)
FileSystem Bytes Read"): The specified object was not found on the computer.
coverage: 76.0% of statements
FAIL github.com/elastic/beats/metricbeat/module/windows/perfmon 5.941s

What version of go you are running?

Hi @pierhugues,
I am using 1.10 version (go version go1.10.1 windows/amd64).

I have manually created gotestcover using the code https://github.com/pierrre/gotestcover

I am unable to run make package command due to this error

Hi @pierhugues,
Is there any other way for me to create rpm file from the metricbeat code
If I have the code in github, is there a travis-CI build setting that I can configure to generate rpm file from the code. I want to generate the rpm file and install this rpm file in Cent OS

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