prometheus服务发现 + Prometheus 查询说明 + 正则模糊查询

0.数据抓取的生命周期

1.通过文件发现

- job_name: node

  file_sd_configs:

  - targets/nodes/*.json

  reflesh_interval: 5m

2.添加标签

cat ./node/node.json
[{"targets":["10.0.0.111:9100"], "labels":{"instance":"node_111"}}, {"targets":["10.0.0.134:9100"], "labels":{"datacenter":"node_134"}} ]

 3.正则模糊查询

up{myjob=~"node119.*"}

rate(node_network_receive_bytes_total{myjob=~"node119.*",device="eth0"}[1m])

参考:https://www.cnblogs.com/zhoujinyi/p/11951779.html   Prometheus学习系列(六)之Prometheus 查询说明

用一个例子来演示会更加清晰
原文地址:https://www.cnblogs.com/hixiaowei/p/13549158.html