介绍
prometheus是由GO语言实现,以拉模式为主,支持多维度标签,黑盒白盒支持,单机性能强劲
环境搭建
国内下载较慢,我已经上传到百度云盘
链接:https://pan.baidu.com/s/1Fde2I0G1-ZAeGyxdheZTow
提取码:lh3m
下载完成后,我这里把tar.gz包放到了/opt目录下,解压
tar -zxvf prometheus-2.22.2.linux-amd64.tar.gz
解压完成后,在/opt/prometheus-2.22.2.linux-amd64目录下执行命令:
./prometheus --config.file=prometheus.yml --web.enable-lifecycle
使用此种方式启动后,可以使用如下命令可以动态更新配置
curl -X POST http://localhost:9090/-/reload
启动prometheus后,可以直接进入192.168.1.47:9090,揭开premetheus它神秘面纱。
此外,还可以进入192.168.1.47:9090/metrics观看自己的指标。
我们可以在输入框中搜索,靠找相关指标:
例如:prometheus_tsdb_head_chunks_created_total
配置文件promethues.yml初步介绍
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 抓取的时间间隔
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 计算rules的时间间隔
# scrape_timeout is set to the global default (10s). 抓取的超时时间
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093 alertmanager的端口
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml" rule_files配置
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus' # 抓取的job名
# metrics_path defaults to '/metrics' # 抓取的http path
# scheme defaults to 'http'.#抓取时所用的网络协议
static_configs:
- targets: ['localhost:9090'] #job端口,我们可以指定多个job和端口
我们可以输入up,快速查询到所有监控的job