Step 2: Configure Metricbeatedit

To configure Metricbeat, you edit the configuration file. The default configuration file is called metricbeat.yml. The location of the file varies by platform. To locate the file, see Directory layout.

There’s also a full example configuration file called metricbeat.reference.yml that shows all non-deprecated options.

Tip

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

When you configure Metricbeat, you need to specify which modules to run. Metricbeat uses modules to collect metrics. Each module defines the basic logic for collecting data from a specific service, such as Redis or MySQL. A module consists of metricsets that fetch and structure the data. Read How Metricbeat works to learn more.

To configure Metricbeat:

  1. Enable the modules that you want to run. If you accept the default configuration without enabling additional modules, Metricbeat collects system metrics only.

    You can either enable the default module configurations defined in the modules.d directory (recommended), or add the module configs to the metricbeat.yml file. The modules.d directory contains default configurations for all available Metricbeat modules.

    If you are using a Docker image, see Running Metricbeat on Docker.

    The following examples enable the apache and mysql configs in the modules.d directory :

    deb and rpm:

    metricbeat modules enable apache mysql

    mac and linux:

    ./metricbeat modules enable apache mysql

    win:

    PS > .\metricbeat.exe modules enable apache mysql

    See the modules command to learn more about this command.

    To change the default module configurations, modify the .yml files in the modules.d directory. See Standard config optionsedit for more about available settings.

    See Specify which modules to run if you want to add the module configs to the metricbeat.yml file rather than using the modules.d directory.

  2. Configure the output. Metricbeat supports a variety of outputs, but typically you’ll either send events directly to Elasticsearch, or to Logstash for additional processing.

    To send output directly to Elasticsearch (without using Logstash), set the location of the Elasticsearch installation:

    • If you’re running our hosted Elasticsearch Service on Elastic Cloud, specify your Cloud ID. For example:

      cloud.id: "staging:dXMtZWFzdC0xLmF3cy5mb3VuZC5pbyRjZWM2ZjI2MWE3NGJmMjRjZTMzYmI4ODExYjg0Mjk0ZiRjNmMyY2E2ZDA0MjI0OWFmMGNjN2Q3YTllOTYyNTc0Mw=="
    • If you’re running Elasticsearch on your own hardware, set the host and port where Metricbeat can find the Elasticsearch installation. For example:

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

    To send output to Logstash, Configure the Logstash output instead. For all other outputs, see Configure the output.

  3. If you plan to use the sample Kibana dashboards provided with Metricbeat, configure the Kibana endpoint. You can skip this step if Kibana is running on the same host as Elasticsearch.

    setup.kibana:
      host: "mykibanahost:5601" 

    The hostname and port of the machine where Kibana is running, for example, mykibanahost:5601. If you specify a path after the port number, include the scheme and port: http://mykibanahost:5601/path.

  4. If Elasticsearch and Kibana are secured, set credentials in the metricbeat.yml config file before you run the commands that set up and start Metricbeat.

    • If you’re running our hosted Elasticsearch Service on Elastic Cloud, specify your cloud auth credentials. For example:

      cloud.auth: "elastic:YOUR_PASSWORD"
    • If you’re running Elasticsearch on your own hardware, specify your Elasticsearch and Kibana credentials:

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

      This examples shows a hard-coded password, but you should store sensitive values in the secrets keystore.

      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.

      To use the pre-built Kibana dashboards, this user must have the kibana_user built-in role or equivalent privileges.

      For more information, see Securing Metricbeat.

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

Tip

Starting with Metricbeat 6.5, you can define and manage Metricbeat configurations in a central location in Kibana. For more information, see Beats central management.