CentOS 7
Sponsored Link

Elastic Stack 7 : Install Heartbeat
2019/06/18
 
Install Heartbeat that can monitor services for their availability with active probing.
[1] Install Heartbeat. Configure Elasticsearch repository before it.
[root@dlp ~]#
yum -y install heartbeat-elastic
[2] Configure basic settings and start Heartbeat.
[root@dlp ~]#
vi /etc/heartbeat/heartbeat.yml
# line 13: set items

# by default, monitored the URL http://localhost:9200 like follows

heartbeat.monitors:
- type: http

  # List or urls to query
  urls: ["http://localhost:9200"]

  # Configure task schedule
  schedule: '@every 10s'

  # Total test connection and data exchange timeout
  #timeout: 16s

.....
.....

# line 74: if use Kibana, uncomment and specify output host

# if SSL is enabled on Kibana, hostname should be the same with the hostname in certs

setup.kibana:
.....
  host: "https://dlp.srv.world:5601"

# line 105: specify output host

# the default is localhost's Elasticsearch

# if output to Logstash, comment out Elasticsearch and uncomment logstash lines

output.elasticsearch:
  # Array of hosts to connect to.l
  hosts: ["localhost:9200"]

.....
.....

#output.logstash:
  # The Logstash hosts
  #hosts: ["localhost:5044"]

[root@dlp ~]#
vi /etc/heartbeat/heartbeat.reference.yml
# line 24: bt default, monitored localhost with ICMP every 5 min

heartbeat.monitors:
- type: icmp # monitor type `icmp` (requires root) uses ICMP Echo Request to ping
             # configured hosts

  # Monitor name used for job name and document type.
  #name: icmp

  # Enable/Disable monitor
  #enabled: true

  # Configure task schedule using cron-like syntax
  schedule: '*/5 * * * * * *' # exactly every 5 seconds like 10:00:00, 10:00:05,...

  # List of hosts to ping
  hosts: ["localhost"]

.....
.....
# line 87: TCP monitoring section

- type: tcp # monitor type `tcp`. Connect via TCP and optionally verify endpoint
            # by sending/receiving a custom payload

  # Monitor name used for job name and document type
  #name: tcp

  # Enable/Disable monitor
  #enabled: true

  # Configure task schedule
  schedule: '@every 5s' # every 5 seconds from start of beat

.....
.....

  hosts: ["localhost:9200"]
.....
.....

[root@dlp ~]#
systemctl start heartbeat-elastic

[root@dlp ~]#
systemctl enable heartbeat-elastic
[3] Make sure the data has been collected normally.
# index list

[root@dlp ~]#
curl localhost:9200/_cat/indices?v

health status index                              uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   .kibana_1                          OD2lQaCLQFeG7RQbYXigEA   1   0       1526          110    910.4kb        910.4kb
yellow open   test_index                         u5nanOeOSCmGbSIlrqluZA   1   1          1            0      5.2kb          5.2kb
yellow open   packetbeat-7.1.1-2019.06.14-000001 azF2ujw4RAeZ9pgdDvRBUg   1   1       7636            0      5.5mb          5.5mb
green  open   .kibana_task_manager               yuJ1nGaBSDeoeP6GToztbg   1   0          2            0     12.8kb         12.8kb
yellow open   heartbeat-7.1.1-2019.06.14-000001  XdKYmJr1QKmj1LOtVaz-hQ   1   1          2            0     35.7kb         35.7kb
yellow open   sshd_fail-2019.06                  Q689hZJTTjG6beQ6XtZsXw   1   1         33            0     74.9kb         74.9kb
yellow open   metricbeat-7.1.1-2019.06.14-000001 5cFmXcywQVWZTKvPMsZdoQ   1   1       7784            0      5.1mb          5.1mb
yellow open   filebeat-7.1.1-2019.06.14-000001   sWGv-hPVRuqon6m4ElZYng   1   1      41222            0      7.8mb          7.8mb

# document list on the index

[root@dlp ~]#
curl localhost:9200/heartbeat-7.1.1-2019.06.14-000001/_search?pretty

{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 5,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "heartbeat-7.1.1-2019.06.14-000001",
        "_type" : "_doc",
        "_id" : "cyf4VGsBAsE_Rtb7s7_i",
        "_score" : 1.0,
        "_source" : {
          "@timestamp" : "2019-06-14T07:51:51.999Z",
          "tcp" : {
            "rtt" : {
              "connect" : {
                "us" : 1174
              }
            }
          },
.....
.....
Matched Content