Step 2: Configure Metricbeat

edit

To configure Metricbeat, you edit the configuration file. For rpm and deb, you’ll find the configuration file at /etc/metricbeat/metricbeat.yml. Under Docker, it’s located at /usr/share/metricbeat/metricbeat.yml. For mac and win, look in the archive that you just extracted. There’s also a full example configuration file called metricbeat.reference.yml that shows all non-deprecated options.

See the Config File Format section of the Beats Platform Reference for more about the structure of the config file.

Metricbeat uses modules to collect metrics. You configure each module individually. The following example shows the default configuration in the metricbeat.yml 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

The following example shows how to configure two modules: the system module and the Apache HTTPD module:

metricbeat.modules:
- module: system
  metricsets:
    - cpu
    - filesystem
    - memory
    - network
    - process
  enabled: true
  period: 10s
  processes: ['.*']
  cpu_ticks: false
- module: apache
  metricsets: ["status"]
  enabled: true
  period: 1s
  hosts: ["http://127.0.0.1"]

To configure Metricbeat:

  1. Define the Metricbeat modules that you want to enable. For each module, specify the metricsets that you want to collect. See Configuring Metricbeat for more details about configuring modules.

    If you accept the default configuration without specifying additional modules, Metricbeat will collect system metrics only.

  2. If you are sending output directly to Elasticsearch (and not using Logstash), set the IP address and port where Metricbeat can find the Elasticsearch installation:

    output.elasticsearch:
      hosts: ["192.168.1.42:9200"]

    If you are sending output to Logstash, make sure you Configure the Logstash output instead.

  3. If you plan to use the sample Kibana dashboards provided with Metricbeat, configure the Kibana endpoint:

    setup.kibana:
      host: "localhost:5601"

    Where host is the hostname and port of the machine where Kibana is running, for example, localhost:5601.

    If you specify a path after the port number, you need to include the scheme and port: http://localhost:5601/path.

  4. If you’ve secured Elasticsearch and Kibana, you need to specify credentials in the config file before you run the commands that set up and start Metricbeat. For example:

    output.elasticsearch:
      hosts: ["myEShost:9200"]
      username: "elastic"
      password: "elastic"
    setup.kibana:
      host: "mykibanahost:5601"
      username: "elastic"  
      password: "elastic"

    The username and password settings for Kibana are optional. If you don’t specify credentials for Kibana, Metricbeat uses the username and password specified for the Elasticsearch output.

    If you are planning to set up the Kibana dashboards, the user must have the kibana_user built-in role or equivalent privileges.

    Also see the security-related options described in Set up the Kibana endpoint and Configure the Elasticsearch output.

To test your configuration file, change to the directory where the Metricbeat binary is installed, and run Metricbeat in the foreground with the following options specified: ./metricbeat test config -e. Make sure your config files are in the path expected by Metricbeat (see Directory layout), or use the -c flag to specify the path to the config file.

Before starting metricbeat, you should look at the configuration options in the configuration file. For more information about these options, see Configuring Metricbeat.