安装
官方介绍:Getting started | Prometheus
下载二进制安装
wget https://github.com/prometheus/prometheus/releases/download/v2.45.3/prometheus-2.45.3.linux-amd64.tar.gz
tar xvfz prometheu-*.tar.gz
cd prometheus-*
代码编译安装
安装依赖包
#yum install git
#yum install go
#yum install npm
#yum install bzip2
下载代码与编译
#git clone https://github.com/prometheus/prometheus.git
#cd prometheus/
#git checkout -b release-2.45 origin/release-2.45
配置go 代理
#export GOPROXY=Goproxy.cn
#export GO111MODULE=on
# make build
编译错误处理
# make build npm ERR! network request to https://registry.npmjs.org/yocto-queue failed, reason: connect ETIMEDOUT 104.16.25.34:443
#npm config set registry https://registry.npmmirror.com* #修改源*
启动服务
cat prometheus.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.# 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:- targets: ["localhost:9090"]# Start Prometheus.
# By default, Prometheus stores its database in ./data (flag --storage.tsdb.path).
./prometheus --config.file=prometheus.yml