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展現

 

相關文章
相關標籤/搜索