prometheus使用consul注册发现

1、安装Consul

1.下载 https://www.consul.io/downloads.htmlhtml

2.解压 unzip consul_*.zipnode

3.启动 nohup ./consul agent -ui -server -bootstrap -data-dir=/workspace/service/consul_cluster/data -pid-file=/workspace/service/consul_cluster/consul.pid -client=0.0.0.0 -advertise=10.10.21.15 -join=10.10.21.15 -node=consul-c1 &git

4.配置文档github

-ui 启动 web ui 服务,默认端口8500web

-server 服务器模式(开发环境可使用-dev,不写入磁盘,内存存储)bootstrap

-data-dir 数据存储路径服务器

-pid-file PID文件路径app

-client 绑定的客户端IPui

-advertiselua

-join

-node

5.默认访问地址 http://localhost:8500

2、安装Prometheus

1.下载 https://prometheus.io/download/

2.解压 tar xvfz prometheus-*.tar.gz

3.启动 nohup ./prometheus --config.file=prometheus.yml 

4.配置文档

global:
  scrape_interval: 5s
  scrape_timeout: 1s
  evaluation_interval: 5s
scrape_configs:
- job_name: 'prometheus'
  scrape_interval: 5s
  scrape_timeout: 5s
  metrics_path: '/metrics'
  scheme: http
  static_configs:
  - targets:
    - 10.10.21.15:9090
- job_name: 'security'
  scrape_interval: 5s
  scrape_timeout: 5s
  metrics_path: '/prometheus'
  scheme: http
- job_name: 'consul-prometheus'
  scrape_interval: 5s
  scrape_timeout: 1s
  metrics_path: '/metrics'
  scheme: http
  consul_sd_configs:
  - server: '10.10.21.15:8500'
    tag_separator: ','
    scheme: http
    allow_stale: true
    refresh_interval: 30s
    services: []
  relabel_configs:
  - source_labels: ['__meta_consul_service']
    separator: ;
    regex: (.*)
    target_label: 'app'
    replacement: $1
    action: replace

5.默认访问地址 http://localhost:9090

3、安装Grafana

1.下载

wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-3.1.1-1470047149.x86_64.rpm

2.安装
sudo yum localinstall grafana-3.1.1-1470047149.x86_64.rpm 

3.启动

sudo /sbin/chkconfig --add grafana-server

sudo service grafana-server start

4.默认访问地址 http://localhost:3000

 

结合示例代码上报数据

https://github.com/chenjunlong/prometheus-client-example/tree/1.1

相关文章
相关标签/搜索