以前,我们获得了Spring Boot Application适配器,以便为Prometheus公开端点。
该博客将重点介绍如何设置和配置Prometheus,以便为Spring Boot端点提供服务器。
因此,让我们开始使用docker来启动Prometheus服务器。
![](https://i-blog.csdnimg.cn/blog_migrate/5405a2cbc1b9aa6944d5ee72af753676.png)
在继续进行Prometheus升级之前,我们需要提供一个配置文件以从应用程序中提取数据。
因此,我们应该提供包含以下内容的prometheus.yaml文件。
scrape_configs:
- job_name: 'prometheus-spring'
scrape_interval: 1m
metrics_path: '/actuator/prometheus'
static_configs:
- targets: [ 'my.local.machine:8080' ]
让我们使用从此处获取的命令。
由于通过docker在osx上使用了prometheus,因此我们需要一些解决方法来通过应用进行连接
sudo ifconfig lo0 alias 172.16.222.111
我们可以直接使用docker
docker run - v /path/to/prometheus .yaml: /etc/prometheus/prometheus .yml -p 9090:9090 --add-host= "my.local.machine:172.16.222.111" prom /prometheus
通过执行上述操作,我们将能够从docker映像内部与本地应用程序进行交互。
因此,如果我们导航到http:// localhost:9090 / graph,我们将被Prometheus屏幕所欢迎。
同样,在我们的prometheus容器内,我们还能够与应在本地运行的应用程序进行通信。
因此,让我们花一些时间看看是否已收集数据。 然后,我们转到Prometheus状态页面http:// localhost:9090 / status 。
我们将被我们的应用程序的JVM信息所吸引。
![](https://i-blog.csdnimg.cn/blog_migrate/a8e3f47fce9ffb7e5424fef23af3e54a.png)
在下一个博客中,我们将重点介绍保护Prometheus 端点的方法 。