This article is a mirror article of machine translation, please click here to jump to the original article.

View: 10481|Reply: 0

Consul HTTP API interface call

[Copy link]
Posted on 3/5/2021 11:33:28 AM | | | |
http API list, please refer to the official documentation for details:The hyperlink login is visible.

ASP.NET Core Link Tracing (3) SkyAPM is based on Consul dynamic configuration
https://www.itsvse.com/thread-9468-1-1.html

【Architecture】ASP.NET Core is highly available based on Consul services
https://www.itsvse.com/thread-9422-1-1.html

Architecture: ASP.NET Core dynamically configures hot updates based on Consul
https://www.itsvse.com/thread-9421-1-1.html

[Architecture]. net/c# implements distributed configuration of Key/Value store based on Consul
https://www.itsvse.com/thread-9420-1-1.html





agent


Agent endpoints are used to interact with local agents, and are generally used to register and check registrations

/v1/agent/checks : 返回本地agent注册的所有检查(包括配置文件和HTTP接口)
/v1/agent/services : 返回本地agent注册的所有 服务
/v1/agent/members : 返回agent在集群的gossip pool中看到的成员
/v1/agent/self : 返回本地agent的配置和成员信息
/v1/agent/join/<address> : 触发本地agent加入node
/v1/agent/force-leave/<node>>: 强制删除node
/v1/agent/check/register : 在本地agent增加一个检查项,使用PUT方法传输一个json格式的数据
/v1/agent/check/deregister/<checkID> : 注销一个本地agent的检查项
/v1/agent/check/pass/<checkID> : 设置一个本地检查项的状态为passing
/v1/agent/check/warn/<checkID> : 设置一个本地检查项的状态为warning
/v1/agent/check/fail/<checkID> : 设置一个本地检查项的状态为critical
/v1/agent/service/register : 在本地agent增加一个新的服务项,使用PUT方法传输一个json格式的数据
/v1/agent/service/deregister/<serviceID> : 注销一个本地agent的服务项


Example:

Returns all services registered by the local agent

http://itsvse:8500/v1/agent/services

{
        "20210305111225232--1862594008": {
                "ID": "20210305111225232--1862594008",
                "Service": "Itsvse.API",
                "tags": ["test"],
                "Meta": {
                        "Product": "Architect",
                        "Version": "3.9.0.0"
                },
                "Port": 9002,
                "Address": "192.168.130.7",
                "TaggedAddresses": {
                        "lan_ipv4": {
                                "Address": "192.168.130.7",
                                "Port": 9002
                        },
                        "wan_ipv4": {
                                "Address": "192.168.130.7",
                                "Port": 9002
                        }
                },
                "Weights": {
                        "Passing": 1,
                        "Warning": 1
                },
                "EnableTagOverride": false
        },
        "20210305111244420-950221525": {
                "ID": "20210305111244420-950221525",
                "Service": "Itsvse.Web.Background",
                "tags": ["test 2"],
                "Meta": {
                        "Product": "Architect",
                        "Version": "3.9.0.0"
                },
                "Port": 9001,
                "Address": "192.168.130.7",
                "TaggedAddresses": {
                        "lan_ipv4": {
                                "Address": "192.168.130.7",
                                "Port": 9001
                        },
                        "wan_ipv4": {
                                "Address": "192.168.130.7",
                                "Port": 9001
                        }
                },
                "Weights": {
                        "Passing": 1,
                        "Warning": 1
                },
                "EnableTagOverride": false
        },
        "20210305111246746-1271993326": {
                "ID": "20210305111246746-1271993326",
                "Service": "Itsvse.Web",
                "tags": ["test 3"],
                "Meta": {
                        "Product": "Architect",
                        "Version": "3.9.0.0"
                },
                "Port": 9003,
                "Address": "192.168.130.7",
                "TaggedAddresses": {
                        "lan_ipv4": {
                                "Address": "192.168.130.7",
                                "Port": 9003
                        },
                        "wan_ipv4": {
                                "Address": "192.168.130.7",
                                "Port": 9003
                        }
                },
                "Weights": {
                        "Passing": 1,
                        "Warning": 1
                },
                "EnableTagOverride": false
        }
}


catalog

catalog endpoints are used to register/log out nodes, services, checks

/v1/catalog/register : Registers a new node, service, or check (建议用agent方法
/v1/catalog/deregister : Deregisters a node, service, or check  (建议用agent方法
/v1/catalog/datacenters : Lists known datacenters
/v1/catalog/nodes : Lists nodes in a given DC
/v1/catalog/services : Lists services in a given DC
/v1/catalog/service/<service> : Lists the nodes in a given service
/v1/catalog/node/<node> : Lists the services provided by a node


Note: There is a difference between agent and catalog(agent gets the registered data on the current node, catalog gets all)

Get information on all services

http://itsvse:8500/v1/catalog/services


{
        "Itsvse.API": ["test"],
        "Itsvse.Web.Background": ["Test 1"],
        "Itsvse.Web": ["Test 2"],
        "consul": []
}
health

Health endpoints are used to query information about health conditions, which is separated from the catalog

/v1/healt/node/<node>: 返回node所定义的检查,可用参数?dc=
/v1/health/checks/<service>: 返回和服务相关联的检查,可用参数?dc=
/v1/health/service/<service>: 返回给定datacenter中给定node中service
/v1/health/state/<state>: 返回给定datacenter中指定状态的服务,state可以是"any", "unknown", "passing", "warning", or "critical",可用参数?dc=


session

session endpoints are used to create, update, destory, query sessions

/v1/session/create: Creates a new session
/v1/session/destroy/<session>: Destroys a given session
/v1/session/info/<session>: Queries a given session
/v1/session/node/<node>: Lists sessions belonging to a node
/v1/session/list: Lists all the active sessions


acl

ACL endpoints are used for create, update, destory, and query ACL

/v1/acl/create: Creates a new token with policy
/v1/acl/update: Update the policy of a token
/v1/acl/destroy/<id>: Destroys a given token
/v1/acl/info/<id>: Queries the policy of a given token
/v1/acl/clone/<id>: Creates a new token by cloning an existing token
/v1/acl/list: Lists all the active tokens


kv

put /v1/kv/key
get /v1/kv/key
delete /v1/kv/k

eyevent

Event endpoints are used to fire new events and query existing events

/v1/event/fire/<name>: 触发一个新的event,用户event需要name和其他可选的参数,使用PUT方法
/v1/event/list: 返回agent知道的events

status

status endpoints are used or consul clusters

/v1/status/leader : 返回当前集群的Raft leader
/v1/status/peers : 返回当前集群中同事





Previous:Java calls to the C# webservice server fail to recognize the value of the HTTP header SOAPAction
Next:jQuery Ajax forces all content-types to be modified
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com