Metricbeat is an open source shipping agent used to collect and ship operating system and service metrics to one or more destinations, including Logstash.

Install

  Package managers Apt/Yum users can install from official repositories.

deb (Debian/Ubuntu)

$ curl -L -O https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-oss-6.4.0-amd64.deb 
$ sudo dpkg -i metricbeat-oss-6.4.0-amd64.deb

rpm (Redhat/Centos/Fedora)

$ curl -L -O https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-oss-6.4.0-x86_64.rpm 
$ sudo rpm -vi metricbeat-oss-6.4.0-x86_64.rpm

macOS

$ curl -L -O https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-oss-6.4.0-darwin-x86_64.tar.gz 
$ tar xzvf metricbeat-oss-6.4.0-darwin-x86_64.tar.gz

Windows

  • Download the Metricbeat Windows zip file from the official downloads page.

  • Extract the contents of the zip file into C:\Program Files.

  • Rename the metricbeat-<version>-windows directory to Metricbeat.

  • Open a PowerShell prompt as an Administrator (right-click the PowerShell icon and select Run As Administrator). If you are running Windows XP, you may need to download and install PowerShell.

  • Run the following commands to install Metricbeat as a Windows service:

    PS > cd 'C:\Program Files\Metricbeat'
    PS C:\Program Files\Metricbeat> .\install-service-metricbeat.ps1`
    
    Security warning
    Run only scripts that you trust. While scripts from the internet can be useful,
    this script can potentially harm your computer. If you trust this script, use
    the Unblock-File cmdlet to allow the script to run without this warning message.
    Do you want to run C:\Program Files\Winlogbeat\install-service-metricbeat.ps1?
    [D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"): R
    
    Status   Name               DisplayName
    ------   ----               -----------
    Stopped  metricbeat         metricbeat
    
      If script execution is disabled on your system, you need to set the execution policy for the current session to allow the script to run. For example: PowerShell.exe -ExecutionPolicy UnRestricted -File .\install-service-metricbeat.ps1.
  My OS isn't here! Don't see your system? Check out the official downloads page for more options (including 32-bit versions).

Locate the configuration file

deb/rpm /etc/metricbeat/metricbeat.yml
mac/win <EXTRACTED_ARCHIVE>/metricbeat.yml

Configure the Modules

Setup the data you wish to send us, by editing the modules. Examples of these settings are found in metricbeat.reference.yml, in the same folder as the configuration file. The system status module is enabled by default to collect metrics about your server, such as CPU usage, memory usage, network IO metrics, and process statistics:

metricbeat.modules:
- module: system
  metricsets:
    - cpu
    - filesystem
    - memory
    - network
    - process
  enabled: true
  period: 10s
  processes: ['.*']
  cpu_ticks: false
  There's also a large range of modules to collect metrics see here.

Configure output

We'll be shipping to Logstash so that we have the option to run filters before the data is indexed.
Comment out the elasticsearch output block.

## Comment out elasticsearch output
#output.elasticsearch:
#  hosts: ["localhost:9200"]

Uncomment and change the logstash output to match below.

output.logstash:
    hosts: ["your-logstash-host:your-port"]
    loadbalance: true
    ssl.enabled: true

Validate configuration

Let's check the configuration file is syntactically correct.

deb/rpm

$ sudo chown -R root /etc/metricbeat
$ sudo chmod go-w /etc/metricbeat/metricbeat.yml
$ sudo metricbeat -e -c /etc/metricbeat/metricbeat.yml

mac
Navigate to the extracted archive directory and enter the following command.

$ sudo ./metricbeat -e -c metricbeat.yml

win
This time using the command prompt and not PowerShell, navigate to the extracted archive directory and enter the following command.

metricbeat -e -c metricbeat.yml

Start metricbeat

Ok, time to start ingesting data!

deb/rpm

$ sudo service metricbeat start

mac

$ sudo chown root metricbeat.yml
$ sudo chown root modules.d/system.yml
$ sudo ./metricbeat -e -c metricbeat.yml -d "publish"

win

PS C:\Program Files\Metricbeat> Start-Service metricbeat