Prometheus是一套开源的系统监控和报警框架,灵感源自Google的Borgmon监控系统。2012年,SoundCloud的Google前员工创造了Prometheus,并作为社区开源项目进行开发。2015年,该项目正式发布。2016年,Prometheus加入云原生计算基金会(Cloud Native Computing Foundation),成为受欢迎度仅次于Kubernetes的项目。
我们在Centos7 上安装Prometheus
> groupadd prometheus
> useradd -g prometheus -M -s /sbin/nologin prometheus
> wget https://github.com/prometheus/prometheus/releases/download/v2.28.1/prometheus-2.28.1.linux-amd64.tar.gz
> tar -xzvf prometheus-2.28.1.linux-amd64.tar.gz
> mv prometheus-2.28.1.linux-amd64 /usr/local/prometheus
> mkdir /usr/local/prometheus/data
> chown -R prometheus:prometheus /usr/local/prometheus
> vim /usr/lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target
[Service]
User=prometheus
Restart=on-failure
ExecStart=/usr/local/prometheus/prometheus \
--config.file=/usr/local/prometheus/prometheus.yml \
--storage.tsdb.path=/usr/local/prometheus/data
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
> vim /usr/local/prometheus/prometheus.yaml
global:
scrape_interval: 15s
evaluation_interval: 15s
alerting:
alertmanagers:
- static_configs:
- targets: ["localhost:9093"]
rule_files:
#- "alert.rules"
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
- job_name: 'node'
scrape_interval: 10s
static_configs:
- targets: ['localhost:9100']
> systemctl daemon-reload
> systemctl start prometheus.service
> systemctl enable prometheus.service
> systemctl status prometheus.service
Prometheus 服务支持热加载配置
> systemctl reload prometheus.service
访问http://ip:9090