prometheus+consul 动态注册+blackbox_exporter

首先为啥用consul动态注册html

1.这个有健康检测,能够检测exporter的状态,node

2.避免频繁的修改prometheus配置文件,方便管理json

3.consul能够作集群避免单点故障bootstrap

这里就用blackbox_exporter+consul+prometheus+grafanaapi

一。安装blackbox_exporter

在个人随笔里面有百度云连接 https://www.cnblogs.com/lc226/p/11222048.htmlcurl

1.下载解压后 nohup ./blackbox_exporter  &ui

2.查看输出结果  tail -f nohup.out url

二.配置prometheus,yml,注意格式

- job_name: http_2xx
params:
module:
- http_2xx
scrape_interval: 2s
scrape_timeout: 2s
metrics_path: /probe
consul_sd_configs:
- server: localhost:8500
tag_separator: ','
services:
- http_2xx
relabel_configs:
- source_labels: ['__address__']
target_label: __param_target
- source_labels: ['__meta_consul_service_address']
target_label: instance
- target_label: __address__
replacement: localhost:9115spa

3。重启prometheus3d

 

 

三。安装consul

1.解压后就一个consul程序,而后直接 用server模式

nohup ./consul agent -server -bootstrap-expect=1 -data-dir=/home/date -node=server-110 -bind=172.16.16.80 -client 0.0.0.0 -ui &

 

 注册blackbox_exporter

这里有两种方式,

1.是创建json文件(之后有空再介绍)

2.经过consul提供的httpAPI接口注册。接口是:http://localhost:8500/v1/agent/service/register

而后咱们用api的方式注册,而且用http_2xx模块

curl -X PUT -d '{"id": "http_2xx","name": "http_2xx","address": "172.16.16.74","port": 80 ,"tags": ["node"],"checks": [{"http": "http://172.16.16.80:9115/","interval": "5s"}]}' http://localhost:8500/v1/agent/service/register

http://localhost:8500/v1/agent/service/register

 

 

 这里要注意ID是惟一标识,name要和prometheus.yml的services同样的名字

3.检测是否成功

1.curl http://localhost:8500/v1/catalog/service/http_2xx

 

 

 

 2经过prometheus查看 .http://172.16.16.80:9090/targets

 

 3.查看指标

 

 四。grafana展现

 

相关文章
相关标签/搜索