我一直在尝试使用配置文件为REST服务创建http运行状况检查。
在加载领事时,它会从配置文件中读取服务详细信息,并反映在8500 Web UI中。
但它没有添加该服务的运行状况检查详细信息。
当运行状况检查与服务定义一起时,也不会显示错误(案例1)。
但是当尝试单独提供运行状况检查配置时,它通知了一个错误。 (案例2)
但是,通过rest api添加时,我可以成功添加http运行状况检查。 (案例3)
健康检查服务详情: - (案例1)
{
"service": {
"id":"somename",
"name":"nameofthissevice",
"service": "myservice",
"address": "127.0.0.1",
"port": 62133,
"enableTagOverride": false,
"check": {
"HTTP": "http://127.0.0.1:62133/Service1.svc/MyService/PingMe",
"Interval": "5s"
}
}
}
仅健康检查配置: - (案例2)
"check": {
"http": "http://127.0.0.1:62133/Service1.svc/MyService/PingMe",
"interval": "5s",
"timeout": "150s",
"ttl" : "100s"
}
通过C#中的代码进行健康检查: - (案例3)
var check = new AgentServiceCheck()
{
Interval = TimeSpan.FromSeconds(10),
HTTP = "http://127.0.0.1:62133/Service1.svc/MyService/PingMe",
DeregisterCriticalServiceAfter = TimeSpan.FromSeconds(10)
};
var srv = new AgentServiceRegistration()
{
XXXXX,
Check = check
};
var result = client.Agent.ServiceRegister(srv).GetAwaiter().GetResult();
我正在使用Consul V.0.9.0 for windows。
这是我的领事日志。
==>领事代理人正在运行!
版本:'v0.9.0'
节点ID:'d0afc715-46d0-6087-27e9-a388cc274bd2'
节点名称:'BETA-PC'
数据中心:'dc1'
服务器:true(bootstrap:false)
客户端地址:127.0.0.1(HTTP:8500,HTTPS:-1,DNS:8600)
Cluster Addr:127.0.0.1(LAN:8301,WAN:8302)
Gossip加密:false,RPC-TLS:false,TLS-Incoming:false
==>现在,日志数据将在发生时流入:
2017/08/11 00:18:23 [DEBUG] Using random ID "d0afc715-46d0-6087-27e9-a388cc274bd2" as node ID
2017/08/11 00:18:23 [DEBUG] agent: restored service definition "somename" from "services\\ServiceRegister.json"
2017/08/11 00:18:23 [WARN] raft: Heartbeat timeout from "" reached, starting election
2017/08/11 00:18:23 [INFO] consul: member 'BETA-PC' joined, marking health alive
2017/08/11 00:18:24 [INFO] agent: Synced service 'somename'
2017/08/11 00:18:24 [DEBUG] agent: Node info in sync
2017/08/11 00:22:33 [DEBUG] http: Request GET /v1/internal/ui/nodes?dc=dc1&token=<hidden> (0s) from=127.0.0.1:52479
2017/08/11 00:22:33 [DEBUG] http: Request GET /v1/catalog/datacenters (37.0021ms) from=127.0.0.1:52478
2017/08/11 00:22:33 [DEBUG] http: Request GET /v1/coordinate/nodes?dc=dc1&token=<hidden> (14.0008ms) from=127.0.0.1:52480
2017/08/11 00:22:33 [DEBUG] http: Request GET /v1/internal/ui/services?dc=dc1&token=<hidden> (0s) from=127.0.0.1:52480
2017/08/11 00:22:33 [DEBUG] http: Request GET /v1/health/service/myservice?dc=dc1&token=<hidden> (1.0001ms) from=127.0.0.1:52480
任何人都可以提供一些关于这个的信息。
THX
答案 0 :(得分:0)
案例1具有大写的HTTP密钥,这似乎是一个错误 - https://www.consul.io/docs/agent/checks.html
案例2 - 如果这是您的整个检查文件,则JSON无效(用{}包装)。您可能还希望通过指定service_id
将其链接到服务