prometheus+blackbox_exporter+grafana

匿名 (未验证) 提交于 2019-12-02 23:49:02

一.安装blackbox_exporter

在我的随笔里面有百度云链接 https://www.cnblogs.com/lc226/p/11222048.html

二.配置prometheus

1.vi prometheus.yml

2.

这里用的icmp模块,,还是一样要注意yml这个文件的格式问题。

- job_name: 'ping'
metrics_path: /probe
params:
module: [icmp] # Look for icmp.
static_configs:
- targets: ['www.baidu.com','172.16.16.74','172.16.16.76']
relabel_configs: -------------------------------------------------------------------这个用法后面有空专门讲
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 172.16.16.80:9115 # The blackbox exporter's real hostname:port

3.重启prometheus

比如76那台进去看logs

这里是用到 probe_success 这个指标,这个指标表示探测成功就是1失败返回0,这里展示是grafana可以自己设计,具体后面有空再详细解释grafana一些功能

后面再附上http_2xx模块的配置,这个模块可以到测试端口,某一个url具体如下

- job_name: 'blackbox'
metrics_path: /probe
params:
module: [http_2xx] # Look for a HTTP 200 response.
static_configs:
- targets:
# - http://prometheus.io # Target to probe with http.
# - https://prometheus.io # Target to probe with https.
- http://172.16.16.76:80 # Target to probe with http on port 8080.
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 127.0.0.1:9115 # The blackbox exporter's real hostname:port

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!