1.环境
192.168.244.128 Prometheus 监控服务器
192.168.244.129 docker 服务(被监控端)
注:都是centos7.5系统
2.下载安装包
https://prometheus.io/download/ (需要的安装包都可以下载)
wget https://github.com/prometheus/prometheus/releases/download/v2.3.2/prometheus-2.3.2.linux-amd64.tar.gz
服务端(监控server)
3.安装prometheus
部署到/usr/local/目录
promethus不用编译安装,解压目录中有配置文件与启动文件
tar -zxvf prometheus-2.3.2.linux-amd64.tar.gz -C /usr/local/
cd /usr/local/ && mv prometheus-2.3.2.linux-amd64/ prometheus
验证
[root@prometheus local]# cd prometheus/
[root@prometheus prometheus]# ./prometheus --version
prometheus, version 2.3.2 (branch: HEAD, revision: 71af5e29e815795e9dd14742ee7725682fa14b7b)
build user: root@5258e0bd9cc1
build date: 20180712-14:02:52
go version: go1.10.3
备份配置文件并配置
cp prometheus.yml prometheus.yml-bak 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. scrape_timeout is set to the global default (10s). Alertmanager configuration
alerting:
alertmanagers:
static_configs:
targets:- alertmanager:9093
Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files: - "first_rules.yml" - "second_rules.yml" 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' metrics_path defaults to '/metrics' scheme defaults to 'http'.
static_configs: