Elastic Stack 7 : Heartbeat インストール2021/06/22 |
|
サービスの死活監視機能を提供する Heartbeat をインストールします。
|
|
| [1] | Heartbeat をインストールします。 事前に Elasticsearch リポジトリ設定済みであることが前提です。 |
|
[root@dlp ~]# dnf -y install heartbeat-elastic
|
| [2] | 基本的な設定をして Heartbeat を起動します。 |
|
[root@dlp ~]#
vi /etc/heartbeat/heartbeat.yml # 23行目 : 監視の設定 # デフォルトは以下のように 10分毎に http://localhost:9200 を監視する設定がされている
heartbeat.monitors:
- type: http
# Set enabled to true (or delete the following line) to enable this example moo
nitor
enabled: true
# ID used to uniquely identify this monitor in elasticsearch even if the confii
g changes
id: my-monitor
# Human readable display name for this service in Uptime UI and elsewhere
name: My Monitor
# List or urls to query
urls: ["http://localhost:9200"]
# Configure task schedule
schedule: '@every 10s'
# Total test connection and data exchange timeout
#timeout: 16s
.....
.....
# 73行目 : Kibana を使用する場合はコメント解除して出力先を指定 # Kibana で SSL 有効の場合は証明書に登録したホスト名と合わせる
setup.kibana:
.....
host: "https://dlp.srv.world:5601"
# 100行目 : 出力先を指定する # デフォルト出力先は以下のように localhost の Elasticsearch # Logstash に出力する場合はコメントアウトして output.logstash 行関連を有効にする 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 # 24行目 : デフォルトでは 5分毎にローカルホストを ICMP 監視する設定
heartbeat.monitors:
- type: icmp # monitor type `icmp` (requires root) uses ICMP Echo Request to pinn
g
# configured hosts
# ID used to uniquely identify this monitor in elasticsearch even if the confii
g changes
id: my-monitor
# Human readable display name for this service in Uptime UI and elsewhere
name: my-icmp-monitor
# Name of corresponding APM service, if Elastic APM is in use for the monitoree
d service.
# service.name: my-apm-service-name
# 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"]
.....
.....
# 104行目 : 任意の TCP ポートの監視設定セクション (デフォルトはローカルホストの 9200 のみ)
- type: tcp # monitor type `tcp`. Connect via TCP and optionally verify endpoint
# by sending/receiving a custom payload
# ID used to uniquely identify this monitor in elasticsearch even if the confii
g changes
id: my-monitor
# Human readable display name for this service in Uptime UI and elsewhere
name: my-tcp-monitor
# Enable/Disable monitor
#enabled: true
# Configure task schedule
schedule: '@every 5s' # every 5 seconds from start of beat
.....
.....
hosts: ["localhost:9200"]
.....
.....
[root@dlp ~]# systemctl enable --now heartbeat-elastic
|
| [3] | データが取り込まれているか確認しておきます。 |
|
# index 一覧 [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_7.13.2_001 zA_r0rrjT7OMUMVSGmRVfg 1 0 4541 388 3.5mb 3.5mb green open .apm-custom-link d1-9Pkn-RXOu_qhMOanvVA 1 0 0 0 208b 208b yellow open filebeat-7.13.2-2021.06.22-000001 c18zEwqAQVeNecW7d6EAQg 1 1 11757 0 1.7mb 1.7mb green open .kibana-event-log-7.13.2-000001 Y-rCmM6yTBKa9W5H1LeJ1g 1 0 1 0 5.6kb 5.6kb green open .apm-agent-configuration y3hQme2SQpGMtb64NLsNdA 1 0 0 0 208b 208b green open .async-search WRLoMwCITRKD3C_BrFJ9bw 1 0 49 239 157kb 157kb green open .kibana_task_manager_7.13.2_001 x6V232xKQLinqRedJRAbgw 1 0 10 4310 499.5kb 499.5kb yellow open packetbeat-7.13.2-2021.06.22-000001 nYN59YPRQwGmDrMRXijZxA 1 1 29267 0 8.7mb 8.7mb yellow open test_index Vh0HutpLRciaMWX3pFo7Zg 1 1 1 0 5.5kb 5.5kb yellow open heartbeat-7.13.2-2021.06.22-000001 LHK787g7S92UFiUXDDrwpQ 1 1 3 0 42.5kb 42.5kb yellow open sshd_fail-2021.06 HiOI2ac-RzK2BiwQ_gb-VQ 1 1 43 0 68.7kb 68.7kb yellow open metricbeat-7.13.2-2021.06.22-000001 aVbbCHScQBujmT8JMRdRBw 1 1 14678 0 8.8mb 8.8mb # index のドキュメント一覧 [root@dlp ~]# curl localhost:9200/heartbeat-7.13.2-2021.06.22-000001/_search?pretty
{
{
"took" : 1,
"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.13.2-2021.06.22-000001",
"_type" : "_doc",
"_id" : "IKImMnoB8xzJeutJLVGI",
"_score" : 1.0,
"_source" : {
"@timestamp" : "2021-06-22T05:16:38.294Z",
"observer" : {
"ip" : [
"10.0.0.30",
"fe80::e38e:e34:9b82:29a2"
],
"mac" : [
"52:54:00:76:3b:03"
],
"hostname" : "dlp.srv.world"
},
"monitor" : {
"type" : "http",
"timespan" : {
"gte" : "2021-06-22T05:16:38.300Z",
"lt" : "2021-06-22T05:16:48.300Z"
},
"status" : "up",
"duration" : {
"us" : 6699
},
.....
.....
|
| Sponsored Link |
|
|