Prometheus 整体架构图片:

下载地址:

https://prometheus.io/download/

下载对应系统可运行文件:提供window64、liunx64、mac64

下载后解压,直接运行:

./prometheus --config.file=your_config.yml

建议数据保留时间:90天

./prometheus --storage.tsdb.retention=90d --config.file=./prometheus.yml

看到类似下面内容证明启动成功

level=info ts=2018-11-21T07:13:29.196054Z caller=main.go:238 msg="Starting Prometheus" version="(version=2.4.3, branch=HEAD, revision=167a4b4e73a8eca8df648d2d2043e21bdb9a7449)"
level=info ts=2018-11-21T07:13:29.196142Z caller=main.go:239 build_context="(go=go1.11.1, user=root@1e42b46043e9, date=20181004-08:46:10)"
level=info ts=2018-11-21T07:13:29.196171Z caller=main.go:240 host_details=(darwin)
level=info ts=2018-11-21T07:13:29.196198Z caller=main.go:241 fd_limits="(soft=4864, hard=unlimited)"
level=info ts=2018-11-21T07:13:29.196218Z caller=main.go:242 vm_limits="(soft=unlimited, hard=unlimited)"
level=info ts=2018-11-21T07:13:29.196905Z caller=main.go:554 msg="Starting TSDB ..."
level=info ts=2018-11-21T07:13:29.196971Z caller=web.go:397 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2018-11-21T07:13:29.201797Z caller=main.go:564 msg="TSDB started"
level=info ts=2018-11-21T07:13:29.201839Z caller=main.go:624 msg="Loading configuration file" filename=prometheus.yml
level=info ts=2018-11-21T07:13:29.202732Z caller=main.go:650 msg="Completed loading of configuration file" filename=prometheus.yml
level=info ts=2018-11-21T07:13:29.20275Z caller=main.go:523 msg="Server is ready to receive web requests."

通过 http://localhost:9090/ 地址判断服务器请求是否正常

案例版本:

2.6.0

Grafana 展示数据

前提条件:

可以通过:

https://grafana.com/dashboards 基本上都可以找到你需要的 dashboards

对应可执行文件通过

./bin/grafana-server web 

Spring Boot Prometheus 整合案例

建议在 Sping Boot 2.x 版本后整合

当前官方方便内容:

57.2.13 Prometheus

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready-metrics-export-prometheus

可以通过:current 为版本号查看对应版本文档文档 2.0.5.RELEASE

https://docs.spring.io/spring-boot/docs/2.0.5.RELEASE/reference/htmlsingle/#production-ready-metrics-export-prometheus