一、概述node
Consul 是一個支持多數據中心分佈式高可用的服務發現和配置共享的服務軟件. Consul 由 HashiCorp公司用Go語言開發, 基於Mozilla Public License 2.0的協議進行開源. Consul 支持健康檢查,並容許 HTTP 和 DNS 協議調用 API 存儲鍵值對. 命令行超級好用的虛擬機管理軟件 vgrant 也是 HashiCorp 公司開發的產品. 一致性協議採用 Raft 算法,用來保證服務的高可用. 使用 GOSSIP 協議管理成員和廣播消息, 而且支持 ACL 訪問控制.
docker run -d --name=qas-consul -p 8500:8500 consul
vim prometheus.yml docker
scrape_configs: - job_name: qas_discover metrics_path: /metrics scheme: http consul_sd_configs: - server: 172.16.8.80:8500 scheme: http services: - node_exporter - cadvisor - prometheus-node tag_separator: '' relabel_configs: - source_labels: ['__meta_consul_tags'] target_label: 'product' - source_labels: ['__meta_consul_dc'] target_label: 'idc' - source_labels: ['__meta_consul_service'] target_label: 'service' - source_labels: ['job'] target_label: 'environment' regex: '(.*)_discover' replacement: '${1}'
curl -X PUT -d '{"id": "zabbix","name": "prometheus-node","address": "172.16.8.59","port":9100,"tags": ["node-exporter"],"checks": [{"http": "http://172.16.8.59:9100/","interval": "5s"}]}' http://172.16.8.80:8500/v1/agent/service/register curl -X PUT -d '{"id": "habor","name": "prometheus-node","address": "172.16.8.55","port":9100,"tags": ["node-exporter"],"checks": [{"http": "http://172.16.8.55:9100/","interval": "5s"}]}' http://172.16.8.80:8500/v1/agent/service/register curl -X PUT -d '{"id": "node","name": "harbor","address": "172.16.8.55","port":8080,"tags": [""],"checks": [{"http": "http://172.16.8.55:8080/","interval": "5s"}]}' http://172.16.8.80:8500/v1/agent/service/register