Step 3: Loading the Index Template in Elasticsearchedit

In Elasticsearch, index templates are used to define settings and mappings that determine how fields should be analyzed.

The recommended index template file for Heartbeat is installed by the Heartbeat packages. If you accept the default configuration for template loading in the heartbeat.yml config file, Heartbeat loads the template automatically after successfully connecting to Elasticsearch. If the template already exists, it’s not overwritten unless you configure Heartbeat to do so.

If you want to disable automatic template loading, or you want to load your own template, you can change the settings for template loading in the Heartbeat configuration file. If you choose to disable automatic template loading, you need to load the template manually. For more information, see:

Configuring Template Loadingedit

By default, Heartbeat automatically loads the recommended template file, heartbeat.template.json, if Elasticsearch output is enabled. You can configure heartbeat to load a different template by adjusting the and template.path options in heartbeat.yml file:

  hosts: ["localhost:9200"] "heartbeat"
  template.path: "heartbeat.template.json"
  template.overwrite: false

By default, if a template already exists in the index, it is not overwritten. To overwrite an existing template, set template.overwrite: true in the configuration file.

To disable automatic template loading, comment out the template part under the Elasticsearch output.

The options for auto loading the template are not supported if you are using the Logstash output.

Loading the Template Manuallyedit

If you disable automatic template loading, you need to run the following command to load the template:

deb or rpm:

curl -XPUT 'http://localhost:9200/_template/heartbeat' -d@/etc/heartbeat/heartbeat.template.json


cd heartbeat-5.2.2-darwin-x86_64
curl -XPUT 'http://localhost:9200/_template/heartbeat' -d@heartbeat.template.json


PS C:\Program Files\Heartbeat> Invoke-WebRequest -Method Put -InFile heartbeat.template.json -Uri http://localhost:9200/_template/heartbeat?pretty

where localhost:9200 is the IP and port where Elasticsearch is listening.


If you’ve already used Heartbeat to index data into Elasticsearch, the index may contain old documents. After you load the index template, you can delete the old documents from heartbeat-* to force Kibana to look at the newest documents. Use this command:

curl -XDELETE 'http://localhost:9200/heartbeat-*'