Prometheus(1)简介

Prometheus,翻译过来就是普罗米修斯,是一个开源的监控和报警系统,诞生于2012年,有着众多的开发者和非常活跃的社区。

Prometheus在2016年加入了Cloud Native Computing Foundation(CNCF),成为了在Kubernetes之后的第二个被托管的项目。

Prometheus收集和存储数据,并且保存为时序数据。每一个数据指标都带有时间戳(timestamp),还有特定的key-value格式的标签(Label)。

模块

Prometheus Server

Prometheus Server主服务会抓取和保存对应目标的时序数据。

Client Library

这是客户端使用的代码库,Prometheus的监控是嵌入式的,为了能够监控到目标服务或者机器的状态数据,需要在我们对应的服务里面使用这些库。

比如spring-boot项目想接入Prometheus监控,可以使用spring-actuator模块,再做一定的配置就行了。

spring-boot可以引入下面的包。

1
2
3
4
5
6
7
8
9
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.10.1</version>
</dependency>

Push Gateway

用于接收目标服务或者机器主动推送上来的数据。

Prometheus Server默认是主动定时去拉取目标的指标参数的,但是对于有些服务,比如定时任务,server并不能抓取到,需要服务主动推送。

Exporter

用于将一些第三方的系统(比如Linux系统或者MySQL)的指标数据暴露给Prometheus Server。

Alertmanager

用于接收和处理告警信息,支持很多消息发送渠道,比如邮件、企业微信等。

参考文档

深入浅出监控神器Prometheus