• 四 Prometheus + consul


    服务发现方式:

    #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
    
    
    
  • 相关阅读:
    xxx
    04消息队列zmq的发布者-订阅者的计算π的简单程序。
    03网络编程从之异步服务器
    03Python网络编程之多线程服务端。
    03Python网络编程之单线程服务端
    03Python网络编程之客户端。
    03Python网络编程系列之服务端
    02select监听客户端
    02select监听服务端
    07爬虫之-urllib总结
  • 原文地址:https://www.cnblogs.com/zhenxing06/p/15009729.html
Copyright © 2020-2023  润新知