Creating a metricbeat Module

Source: Internet
Author: User

Https://www.elastic.co/guide/en/beats/devguide/current/index.html

First, the local correct installation Golang

Yum install-y Golang or Https://golang.org/doc/install

Second, set up a good Gopath

Vim ~/.bash_profile

Export Goroot=/usr/local/go

Export path= $PATH: $GOROOT/bin

Export Gopath=/usr/local/go

Third, access to Metricbeat source code

Clone the Beat, the directory is $goroot/$yourdirectory/src/github.com/elastic/beats

Git clonehttps://github.com/elastic/beats.git

Or:

Go get github.com/elastic/beats/metricbeat

Iv. creation of Metricset

Proceed to $GOROOT/$yourdirectory/src/github.com/elastic/beats/metricbeat/Directory

Make Create-metricset (dependent on Yum install-y python-virtualenv)

Follow the prompts to enter the custom module name & metricset name (module name can be an existing module and add a new Metricset to an existing module)

Module Name:

Metricset Name:

V. Editing Custom Scripts

Go to {metricbeat}/module/{module name}/{metricset name}/Edit Custom Script

{metricset Name}.go # change script template will be generated automatically, generally only need to modify the Func Fetch () custom data acquisition and data output

VI. Compiling metricbeat

To the {metricbeat}/module/{module name}/directory

Perform make collect #将所做的修改录入metricbeat

Execute Make #编译

VII. Debug

After compiling, a metricbeat binary file will appear, in the MODULES.D directory you can remove the configuration file that needs to collect data disabled (by default, only system is not disabled)

Run./METRICBEAT-E-D "*" to debug to see if the compiled metricbeat is working properly, the data collected is normal

Viii. using compiled Metricbeat

Copy the normal working binary file metricbeat to the original metricbeat binary directory, replace it, copy all files under the generated MODULES.D folder to/etc/metricbeat/modules.d/and replace the original file.

Systemctl Stop Metricbeat

CP Metcibeat/usr/bin/metricbeat

CP Metricbeat/usr/share/metricbeat/bin/metricbeat

Cp-r modules.d/*/etc/metricbeat/modules.d/

Nine, start metricbeat service

Modify the configuration file/etc/metricbeat/metricbeat.yml and start the service

Configure parameters such as output

Systemctl Start Metricbeat

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.