什么是prometheus
Prometheus(普罗米修斯)是一个开源系统监控和警报工具,最初是在SoundCloud建立的。自2012年成立以来,许多公司和组织都采用了普罗米修斯,该项目拥有一个非常活跃的开发者和用户社区。它现在是一个独立的开放源码项目,并且独立于任何公司。为了强调这一点,为了澄清项目的治理结构,普罗米修斯在2016年加入了云计算基金会,成为继Kubernetes之后的第二个托管项目。
下载
# 下载地址
https://prometheus.io/download/#prometheus
百度网盘
链接:https://pan.baidu.com/s/1wjtvw29msDGdGbRyUP63VQ
提取码:5ux3
安装
1.安装go运行环境
tar -C /usr/local/ go1.12.linux-amd64.tar.gz -xvf
vim /etc/profile
#新增
export PATH=$PATH:/usr/local/go/bin
source /etc/profile
2.解压prometheus-2.20.0.linux-amd64.tar.gz
tar -C /usr/local/ prometheus-2.20.0.linux-amd64.tar.gz -xvf
为了以后进入目录方便,做了一个软连接:
ln -sv /usr/local/prometheus-2.20.0.linux-amd64/ /usr/local/Prometheus
#启动 当项目目录下启动
./prometheus
修改prometheus.yml,添加对服务器的监控
添加了
- job_name: 'yinchuan'
static_configs:
- targets: ['192.168.52.129:9100']
# 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']
- job_name: 'yinchuan'
static_configs:
- targets: ['192.168.52.129:9100']
在192.168.52.129 服务器上安装node_exporter
tar -C /usr/local node_exporter-0.18.1.linux-amd64.tar.gz -xvf
#启动
./node_exporter
其他安装
使用镜像进行安装
docker pull prom/prometheus
docker run -d -p 9090:9090 --name=prometheus \
-v /root/prometheus/conf/:/etc/prometheus/ \
prom/prometheus
安装node_exporter
docker run -d -p 9100:9100 \
-v "/proc:/host/proc:ro" \
-v "/sys:/host/sys:ro" \
-v "/:/rootfs:ro" \
--net="host" \
prom/node-exporter
安装grafana
docker run -d \
-p 3000:3000 \
--name=grafana \
-v /opt/grafana-storage:/var/lib/grafana \
grafana/grafana
参考
https://www.jianshu.com/p/dfd6ba5206dc
https://blog.csdn.net/csolo/article/details/82460539