Step 2: Configuring 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.full.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.

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: ["myhost: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 Configuration Options for a full description of each configuration option.

  2. If you are sending output to Elasticsearch, set the IP address and port where Heartbeat can find the Elasticsearch installation:

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

    If you are sending output to Logstash, see Configuring Heartbeat to use Logstash instead.

To test your configuration file, change to the directory where the Heartbeat binary is installed, and run Heartbeat in the foreground with the following options specified: ./heartbeat -configtest -e. Make sure your config files are in the path expected by Heartbeat (see Directory Layout). If you installed from DEB or RPM packages, run ./heartbeat.sh -configtest -e.