今日本篇重点是要安装Heartbeat,以如何设定要监控的服务项目。
步骤一: 下载 Heartbeat 安装包, 下载地址。
curl -L -O https://artifacts.elastic.co/downloads/beats/heartbeat/heartbeat-7.14.1-darwin-x86_64.tar.gz
tar xzvf heartbeat-7.14.1-darwin-x86_64.tar.gz
cd heartbeat-7.14.1-darwin-x86_64/
步骤二:修改配置档案heartbeat.yml。
output.elasticsearch:
hosts: ["localhost:9200"]
username: "elastic"
password: "<password>"
setup.kibana:
host: "localhost:5601"
步骤三:启动heartbeat
./heartbeat setup #建立索引
./heartbeat -e # 启动
为了使 heartbeat 知道要检查那些服务,所以可以在heartbeat.yml设定要检查的服务项目,如下面范例:
# 监控服务设定
heartbeat.monitors:
- type: http # 使用http方式监控,可以为TCP、icmp等
enabled: true
id: my-monitor
name: My Monitor
urls: ["http://localhost:9200"]
schedule: '@every 10s' # 每 10s 抓取一次
在heartbeat安装目录下monitors.d的目录,底下的每个yml档都可以是一个可监控的服务文件。
# 副档名为 .disabled 是还没启用的设定
$ ls monitors.d/
sample.http.yml.disabled sample.icmp.yml.disabled sample.tcp.yml.disabled
我们来看一下monitors.d的目录下 .yml的内容。
- type: http
id: it13-http-monitor
name: it13 HTTP Monitor
schedule: '@every 5s' # every 5 seconds from start of beat
hosts: ["http://localhost:8080/api/ping"]
check.request:
method: GET
check.response:
body: "PING PONG" # 检查回应的字串要等於"PING PONG"
ipv4: true
ipv6: true
mode: any
接下来我们只要重新启重heartbeat後,就可以到kibana中查看服务运行的状态。
<<: Day18 用python写UI-聊聊Listbox与事件绑定
平衡灯 ( 旋转感测 ) 教学原文参考:平衡灯 ( 旋转感测 ) 这篇文章会介绍如何使用「旋转感测值...
测试Router正确跳转 'clicking on a button should redirect...
单元测试的好朋友—整合测试 (Integration Test) 在昨天 Day 2-什麽是单元测试...
MVC是什麽 MVC是一种软件架构,着重在关注点分离,此架构分成三类 M : Model : 专注於...
指派/指定 运算子(Assignment Operator) 可以用来设定变数值的运算子,前面用过的...