我使用 gocraft / health 来检查我的服务的运行状况,并获得每个endPoint的指标。 我使用JSON轮询接收器来获取指标。
sink := health.NewJsonPollingSink(time.Minute*5, time.Minute*5)
stream.AddSink(sink)
我想在这里使用 healthtop和healthd Link来解释具体方法。
我修复了环境变量:export HEALTHD_MONITORED_HOSTPORTS=:5001 HEALTHD_SERVER_HOSTPORT=:5002 healthd
正如他们所说
他们说“现在你可以运行它”。如何,他们没有任何命令去做。我没有真正明白他们的意思。
我导航到 src / github.com / gocraft / health / cmd / healthd 。当我运行它时,我找到了 main.go ,我在控制台中找到了它
[openrtb@sd-69536 healthd]$ go run main.go
[2015-06-17T23:04:20.871743758Z]: job:general event:starting kvs:[health_host_port::5002 monitored_host_ports::5001,:5002 server_host_port::5002]
[2015-06-17T23:04:20.87810814Z]: job:poll status:success time:4 ms kvs:[host_port::5002]
[2015-06-17T23:04:20.881896459Z]: job:poll status:success time:8 ms kvs:[host_port::5001]
[2015-06-17T23:04:20.882338024Z]: job:recalculate status:success time:231 μs
[2015-06-17T23:04:23.275370787Z]: job:recalculate status:success time:6 μs
[2015-06-17T23:04:30.875230839Z]: job:poll status:success time:1573 μs kvs:[host_port::5002]
[2015-06-17T23:04:30.881415193Z]: job:poll status:success time:7 ms kvs:[host_port::5001]
.
.
但没有在这些端点上重新填写
localhost:5002 / jobs:列出热门职位
localhost:5002 / hosts:列出所有受监控的主机及其状态
它给了我 {“error”:“not_found”}
除了 localhost:5002 / health 我得到了这个JSON响应
{
"instance_id": "sd-69536.1291",
"interval_duration": 3600000000000,
"aggregations": [
{
"interval_start": "2015-06-18T01:00:00+02:00",
"serial_number": 48,
"jobs": {
"general": {
"timers": {},
"events": {
"starting": 1
},
"event_errs": {},
"count": 0,
"nanos_sum": 0,
"nanos_sum_squares": 0,
"nanos_min": 0,
"nanos_max": 0,
"count_success": 0,
"count_validation_error": 0,
"count_panic": 0,
"count_error": 0,
"count_junk": 0
},
"poll": {
"timers": {},
"events": {},
"event_errs": {},
"count": 24,
"nanos_sum": 107049159,
"nanos_sum_squares": 6.06770682813009e+14,
"nanos_min": 1581783,
"nanos_max": 8259442,
"count_success": 24,
"count_validation_error": 0,
"count_panic": 0,
"count_error": 0,
"count_junk": 0
},
"recalculate": {
"timers": {},
"events": {},
"event_errs": {},
"count": 23,
"nanos_sum": 3501601,
"nanos_sum_squares": 6.75958305123e+11,
"nanos_min": 70639,
"nanos_max": 290877,
"count_success": 23,
"count_validation_error": 0,
"count_panic": 0,
"count_error": 0,
"count_junk": 0
}
},
"timers": {},
"events": {
"starting": 1
},
"event_errs": {}
}
]
}
但不知道这个结果意味着什么,因为它与我的没有任何关系 localhost:5001 / health EndPoint应按照他们的说法进行正常聚合。
答案 0 :(得分:1)
您下载的内容是二进制文件,因此您可以使用healthd
调用它,如果您在正确的目录中,它们实际上提供了此示例;
HEALTHD_MONITORED_HOSTPORTS=:5020 HEALTHD_SERVER_HOSTPORT=:5032 healthd
哪个设置env var与使用这两个值调用healthd一样多(导出或需要某些东西来保持更改超出一个命令)。 healthtop更清楚地说明它是什么,但正如你可以通过他们的路径看到的那样,他们都是gocraft/health/cmd/healthtop
命令。他们有几个使用bash中的healthtop的例子,对健康没有那么明确,但它是一样的。
如果您运行该命令(正如您在问题中显示的那样),那么您可能想尝试healthtop jobs
或其他类似的事情。我对这个项目知之甚少,并不关心研究它,但据我所知healthd
只是一种收集来自各种/health
端点的结果的服务它们在API上可用。他们似乎打算让您使用healthtop
来查看报告。
另请注意;
大!要了解healthd服务的数据类型,您可以手动导航到: / jobs:列出最高职位 / aggregations:提供聚合的时间序列 / aggregations / overall:将所有时间序列聚合转换为一个聚合。 / hosts:列出所有受监控的主机及其状态。 但是,查看原始JSON只是为了让您了解数据。见下一节......
我不确定域名是什么(如果您在本地运行,则为localhost:5032?)但您应该可以转到localhost:5032 / jobs并查看{{1}正在运行并做某事。同时检查您的应用以确认它已启动并正常运行。不要直接期待它的任何输出,这是healthd
的用途。