• 周六. 7月 2nd, 2022

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

四 Prometheus + consul

admin

11月 28, 2021

服务发现方式:

#Prometheus数据源的配置主要分为静态配置和动态发现, 常用的为以下几类:
static_configs:              #静态服务发现
file_sd_configs:             #文件服务发现
dns_sd_configs: DNS          #服务发现
kubernetes_sd_configs:       #Kubernetes 服务发现
consul_sd_configs: Consul    #Consul 服务发现
...

#在监控kubernetes的应用场景中,频繁更新的pod,svc,等等资源配置应该是最能体现Prometheus监控目标自动发现服务的好处


Consul:


wget https://releases.hashicorp.com/consul/1.6.1/consul_1.6.1_linux_amd64.zip
unzip consul_1.5.3_linux_amd64.zip
nohup ./consul agent -dev  -bind 0.0.0.0 -client 0.0.0.0 & 
./consul agent -server -ui -bootstrap-expect 1 -data-dir /tmp/consul &



http://ip:8500/ui

Prometheus 安装略过

。。。。。。

API注册服务到consul:

curl -X PUT -d '{"id": "node-exporter","name": "node-exporter-10.10.32.85","address": "10.10.32.85","port": 9100,"tags": ["test"],"checks": [{"http": "http://10.10.32.85:9100/metrics", "interval": "5s"}]}'  http://127.0.0.1:8500/v1/agent/service/register

 curl -X PUT -d '{"id": "node-exporter","name": "node-exporter-10.10.32.85","address": "10.10.32.85","port": 9100,"tags": ["test"],"checks": [{"http": "http://10.10.32.85:9100/metrics", "interval": "5s"}]}'  http://127.0.0.1:8500/v1/agent/service/register

10.10.159.247
curl -X PUT -d '{"id": "node-exporter","name": "node-exporter-10.10.159.247","address": "10.10.159.247","port": 9100,"tags": ["prod"],"checks": [{"http": "http://10.10.159.247:9100/metrics", "interval": "5s"}]}'  http://127.0.0.1:8500/v1/agent/service/register


发表评论

您的电子邮箱地址不会被公开。