本文环境 Redhat Linux 6.7, Prometheus 2.2.1,node_exporter 1.5.2html
Prometheus 是2012年由 SoundCloud 开源的系统监控和报警工具集,在 《Google SRE 运维解密》一书中也提到与Google内部的Borgmon思想一致。使用 Go 语言开发,适用于各个平台。node
[root@bj1eccap01 ~]# tar -xvzf prometheus-2.2.1.linux-amd64.tar.gz [root@bj1eccap01 ~]# cd prometheus-2.2.1.linux-amd64 [root@bj1eccap01 prometheus-2.2.1.linux-amd64]# ./prometheus --help usage: prometheus [<flags>]
安装包下有一个默认的配置文件,是 YAML 格式,默认配置文件包括三个分区:global
、rule_files
、scrape_configs
。linux
global
控制 Prometheus 服务器的全局配置。scrape_interval
决定数据抓取的间隔。evaluation_interval
决定数据计算的间隔,Prometheus会根据rule_file来产生新的时间序列值。浏览器
rule_files
决定规则文件的保存路径。服务器
scrape_config
决定Prometheus监控的资源。Prometheus经过HTTP暴露本身的数据,所以也能够监控本身的健康情况。less
启动很是简单运维
[root@bj1eccap01 prometheus-2.2.1.linux-amd64]# ./prometheus --config.file=prometheus.yml
这以后就能够经过浏览查看服务的运行情况了,打开浏览器输入 http://localhost:9090/graph函数
Prometheus 提供了两种方式查看指标 graph 模式能够直接看到指标曲线,metrics 则看到原始的监控数据。经过切换到 console 界面能够看到。工具
node_exporter 用来收集服务器的监控信息,目前稳定版本为1.15.2。node_exporter 默认使用 9100 端口监听,Prometheus 会从 node_exporter 中获取信息。lua
[root@bj1eccap01 ~]# tar -xzvf node_exporter-0.15.2.linux-amd64.tar.gz [root@bj1eccap01 ~]# cd node_exporter-0.15.2.linux-amd64 [root@bj1eccap01 node_exporter-0.15.2.linux-amd64]# ./node_exporter
Prometheus 提供了一套查询语言,支持运算以及一些经常使用的统计运算。
Prometheus 支持以下运算符。
运算符 | 说明 |
---|---|
+ | 加法 |
- | 减法 |
* | 相乘 |
/ | 相除 |
% | 取摸运算 |
== | 相等 |
!= | 不相等 |
> | 大于 |
< | 小于 |
>= | 大于或等于 |
<= | 小于或等于 |
and | 逻辑和 |
or | 逻辑或 |
unless | 除非,取补集 |
方法名 | 介绍 |
---|---|
sum | 求和 |
min | 求最小值 |
max | 求最大值 |
avg | 取平均值 |
stddev | 计算标准差 |
stdvar | |
count | 计算总数 |
count_values | 计算相同值的数量 |
bottomk | 最小的k个元素 |
topk | 最大的k个元素 |
quantile |
本文为做者原创,若是您以为本文对您有帮助,请随意打赏,您的支持将鼓励我继续创做。
参考资料:
一、Prometheus
二、Prometheus First Step
三、Prometheus 入门尝试