All Products
Search
Document Center

Elasticsearch:Use Heartbeat to check ICMP and HTTP services

Last Updated:Nov 25, 2024

This topic describes how to use Alibaba Cloud Heartbeat to check the status of Internet Control Message Protocol (ICMP) and HTTP services. It can also generate visual charts.

Background information

Heartbeat is a lightweight daemon. It can be installed on a remote server to check the availability of your services on a regular basis. Heartbeat is unlike Metricbeat. Heartbeat checks whether your services are reachable but Metricbeat checks whether your services are running.

Important

Most Beats shippers need to be installed on edge nodes. However, Heartbeat can be installed on a separate computer or even outside the network where services you want to monitor are deployed.

Heartbeat supports the following types of monitors:

  • ICMPv4 or ICMPv6 monitor: sends ICMP requests to check whether a service is available. This type of monitor connects to a service over ICMP. If you want to use an ICMP monitor, root permissions are required.

  • TCP monitor: sends or receives specific workloads to check whether a service is available. This type of monitor connects to a service over TCP.

  • HTTP monitor: checks whether a service is available based on specific status codes, response headers, or response content. This type of monitor connects to a service over HTTP.

    Note

    TCP and HTTP monitors support Secure Sockets Layer (SSL), Transport Layer Security (TLS), and some proxy settings.

Prerequisites

Procedure

  1. Log on to the Alibaba Cloud Elasticsearch console.

  2. In the left-side navigation pane, click Beats Data Shippers.

  3. In the Create Shipper section of the page that appears, click Heartbeat.

  4. Install and configure a shipper.

    For more information, see Collect the logs of an ECS instance and Prepare a YML configuration file for a shipper. The following figure shows the configurations that are used in this example.heartbeat配置

    Note
    • If you select Enable Kibana Monitoring, the system enables Heartbeat service monitoring in the Kibana console.

    • If you select Enable Kibana Dashboard, the system generates charts in the Kibana console. You do not need to configure the YML file. Alibaba Cloud Kibana is deployed in a VPC. You must enable the Private Network Access feature for Kibana on the Kibana Configuration page. For more information, see Configure a public or private IP address whitelist for Kibana.

    When you configure the shipper, configure the heartbeat.monitors parameter in heartbeat.yml to configure monitors. The following monitor configurations are used in this example:

    heartbeat.monitors:
    - type: icmp
      schedule: '*/5 * * * * * *'
      hosts: ["47.111.xx.xx"]
    - type: http
      # List or urls to query
      urls: ["https://es-cn-xxxxx.kibana.elasticsearch.aliyuncs.com:5601/"]
      # Configure task schedule
      schedule: '@every 10s'
      check.response.status: 200

    Parameter

    Description

    type

    The monitor type. In the preceding configurations, icmp and http monitors are specified.

    schedule

    The task schedule. If you set this parameter to '*/5 * * * * * *', the system runs the task at 5-second intervals. If you set this parameter to '@every 10s', the system runs the task at 10-second intervals from the time Heartbeat is started.

    hosts

    The servers that you want to ping.

    urls

    The URLs that you want to ping.

    check.response.status

    The expected HTTP status code that is returned for the HTTP request. If you set this parameter to 200, the system determines that the related service is normal if 200 is returned.

    Note

    For more information, see open source Heartbeat documentation.

  5. Select the ECS instance on which you want to install the shipper.

    The selected ECS instance must meet the preceding prerequisites.

  6. Start the shipper and check whether the shipper is installed.

    1. Click Start.

      Then, the Start Shipper message appears.

    2. Click Back to Beats Shippers. In the Manage Shippers section of the Beats Data Shippers page, view the installed shipper.

    3. After the state of the shipper changes to Enabled 1/1, click View Instances in the Actions column.

    4. In the View Instances panel, check whether the shipper is installed on the ECS instance. If the value of Installed Shippers is Normal Heartbeat, the shipper is installed.

View the result

  1. Log on to the Kibana console of the Elasticsearch cluster.

    For more information, see Log on to the Kibana console.

  2. In the left-side navigation pane, click Discover. On the page that appears, select heartbeat-* from the drop-down list in the upper-left corner and specify a period in the upper-right corner. Then, view the data collected by Heartbeat within the specified period.

    Heartbeat收集的数据

  3. In the left-side navigation pane, click Dashboard.

  4. In the Dashboards section of the page that appears, click Heartbeat HTTP monitoring. In the upper-right corner of the page that appears, select a period. Then, view HTTP status statistics within the specified period.

    HTTP监控状态图