Prometheus简介
Prometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud. Since its inception in 2012, many companies and organizations have adopted Prometheus, and the project has a very active developer and user community. It is now a standalone open source project and maintained independently of any company. To emphasize this, and to clarify the project’s governance structure, Prometheus joined the Cloud Native Computing Foundation in 2016 as the second hosted project, after Kubernetes.
特性、组件和架构等更多信息,参考Prometheus官方文档。
安装Prometheus server
本节在CentOS7虚拟机上安装Prometheus server,虚拟机IP为192.168.56.130,安装流程主要参考Prometheus - GETTING STARTED。
1、下载Prometheus server
访问Prometheus官网下载页,这里选择下载prometheus-2.15.2.linux-amd64.tar.gz
1 | cd /opt |
2、解压并进行配置
1 | tar -xzvf prometheus-2.15.2.linux-amd64.tar.gz |
修改targets为0.0.0.0:9090,修改后的prometheus.yml如下:
1 |
|
3、启动prometheus./prometheus --config.file=prometheus.yml
除了上面的安装方法,还可以下载Prometheus的Docker images,使用Docker安装。
简单使用
1、访问metrics
浏览器访问 http://192.168.56.130:9090/metrics
可以看到prometheus的一些信息:
1 | # HELP go_gc_duration_seconds A summary of the GC invocation durations. |
2、查看图表
浏览器访问 http://192.168.56.130:9090/graph
在Expression输入框中输入:prometheus_target_interval_length_seconds
,然后点击Execute,再点击下面Tab中的Graph。
可以看到一个图表,图表的含义是,emm,不知道。
3、收集其他metrics
想要收集metrics,首先要安装配置好exporter。
比如想要收集jmx metrics,那么需要安装prometheus/jmx_exporter。
Prometheus服务发现
1 | static_configs: #静态服务发现,基于prometheus配置文件指定的监控目标 |
参考文档:
后记
Prometheus也有不少问题,比如数据量大的时候需要拆分集群,聚合数据很难数据去重,可用性较低等。因此出现了Thanos,能够解决Prometheus的很多问题,详情参考分布式 Promethues 之 Thanos。