项目 需要 用到prometheus 来监控系统,
俺们本来是用nagios 的, 转到 prometheus 还是有点不太顺手。
不过还是很快解决问题了。
-
关于网络丢包率。 系统底层监控的一个核心项目。
2. 采用 premetheus 的 blackbox_exporter 做监控项目:
blackboz.yml :
[code]
modules:
http_2xx:
prober: http
http_post_2xx:
prober: http
http:
method: POST
tcp_connect:
prober: tcp
pop3s_banner:
prober: tcp
tcp:
query_response:
- expect: "^+OK"
tls: true
tls_config:
insecure_skip_verify: false
ssh_banner:
prober: tcp
tcp:
query_response:
- expect: "^SSH-2.0-"
irc_banner:
prober: tcp
tcp:
query_response:
- send: "NICK prober"
- send: "USER prober prober prober :prober"
- expect: "PING :([^ ]+)"
send: "PONG ${1}"
- expect: "^:[^ ]+ 001"
icmp:
prober: icmp
tcp:
query_response:
- send: "NICK prober"
- send: "USER prober prober prober :prober"
- expect: "PING :([^ ]+)"
send: "PONG ${1}"
- expect: "^:[^ ]+ 001"
[/code]
prometheus 的配置文件:
- job_name: 'ping_all'
scrape_interval: 5s
metrics_path: /probe
params:
module: [icmp] #ping
static_configs:
- targets: ['x','10x','10.x4']
labels:
group: "IDC DATA Center"
- targets: ['10.4x10.44.2x0.44.0.2x0.44.x]
group: "AliYun.com"
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 #blackbox expoter
然后 在 grafana 里面, 新建一个panel
数据源 选 premetheus
查询 (1-(sum_over_time(probe_success{job="ping_all"}[1m])/12))*100
就是这句了。
blackbox 每次 icmp ping 之后, 如果成功 probe_success = 0 失败 =1
我们就统计 5秒钟内的 失败次数。 然后计算。
当然了 ,里面的其他的查询语法自己去研究。
总之丢包率, 就这么解决了。
probe_icmp_duration_seconds 是网络延时 。 这个问题不大。

