Consul常用接口使用

一个人想着一个人 提交于 2019-12-03 07:40:01

prometheus.yml 配置

  - job_name: 'node_exporter'
    consul_sd_configs:
      - server: 'consul_ip:8500'
        services: ['node_exporter']
# 匹配service关键字
 - job_name: 'service'
    consul_sd_configs:
    - server: 'consul_ip:8500'
      services: []
    relabel_configs:
    - source_labels: [__meta_consul_tags]
      regex: .*service.*
      action: keep 注册服务
curl -X PUT -d '{"id": "test1","name": "test1","address": "10.80.229.55","port": 9100,"tags": ["service"],"checks": [{"http": "http:// 10.80.229.55:9100/","interval": "5s"}]}' http://consul_ip:8500/v1/agent/service/register
    查询指定节点以及指定的服务信息
curl http://consul_ip:8500/v1/catalog/service/mysql
删除服务
curl --request PUT http://consul_ip:8500/v1/agent/service/deregister/mysql
列出数据中心
curl http://consul_ip:8500/v1/catalog/datacenters列出节点
curl http://consul_ip:8500/v1/catalog/nodes列出服务
curl http://consul_ip:8500/v1/catalog/services列出服务节点
curl http://consul_ip:8500/v1/catalog/service/my-service    


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!