Step 2: Configure Heartbeatedit

To configure Heartbeat, you edit the configuration file. For rpm and deb, you’ll find the configuration file at /etc/heartbeat/heartbeat.yml. Under Docker, it’s located at /usr/share/heartbeat/heartbeat.yml. For mac and win, look in the archive that you just extracted. There’s also a full example configuration file called heartbeat.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.

Heartbeat provides monitors to check the status of hosts at set intervals. You configure each monitor individually. Heartbeat currently provides monitors for ICMP, TCP, and HTTP (see Overview for more about these monitors). Here is an example that configures Heartbeat to use an icmp monitor:

heartbeat.monitors:
- type: icmp
  schedule: '*/5 * * * * * *'
  hosts: ["myhost"]
output.elasticsearch:
  hosts: ["myEShost:9200"]

To configure Heartbeat:

  1. Specify the list of monitors that you want to enable. Each item in the list begins with a dash (-). The following example configures Heartbeat to use two monitors, an icmp monitor and a tcp monitor:

    heartbeat.monitors:
    - type: icmp
      schedule: '*/5 * * * * * *' 
      hosts: ["myhost"]
    - type: tcp
      schedule: '@every 5s' 
      hosts: ["myhost:12345"]
      mode: any 

    The icmp monitor is scheduled to run exactly every 5 seconds (10:00:00, 10:00:05, and so on). The schedule option uses a cron-like syntax based on this cronexpr implementation.

    The tcp monitor is set to run every 5 seconds from the time when Heartbeat was started. Heartbeat adds the @every keyword to the syntax provided by the cronexpr package.

    The mode specifies whether to ping one IP (any) or all resolvable IPs (all).

    See Configuring Heartbeat for a full description of each configuration option.

  2. Configure the output. Heartbeat 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 Heartbeat 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 Heartbeat, 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 heartbeat.yml config file before you run the commands that set up and start Heartbeat.

    • 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, Heartbeat 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.

      For more information, see Securing Heartbeat.

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