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
