- 1.prometheus简介
- 1.1 prometheus特点
- 1.2 组件
- 2.安装
Prometheus是由SoundCloud开发的开源监控报警系统和时序列数据库(TSDB)。Prometheus使用Go语言开发,是Google BorgMon监控系统的开源版本
1.1 prometheus特点- 多维度数据模型。
- 灵活的查询语言。
- 不依赖分布式存储,单个服务器节点是自主的。
- 通过基于HTTP的pull方式采集时序数据。
- 可以通过中间网关进行时序列数据推送。
- 通过服务发现或者静态配置来发现目标服务对象。
- 支持多种多样的图表和界面展示,比如Grafana等。
| 名称 | 功能 |
|---|---|
| Server | 主要负责数据采集和存储,提供PromQL查询语言的支持。 |
| alertmanager | 警告管理器,用来进行报警。 |
| Push Gateway | 支持临时性Job主动推送指标的中间网关。 |
安装go 语言环境
https://golang.google.cn/dl/
[root@localhost ~]# wget https://dl.google.com/go/go1.17.3.linux-amd64.tar.gz [root@localhost ~]# tar xf go1.17.3.linux-amd64.tar.gz -C /usr/local/ [root@localhost ~]# tail -1 /etc/profile export PATH=$PATH:/usr/local/go/bin [root@localhost ~]# source /etc/profile [root@localhost ~]# go version go version go1.17.3 linux/amd64
安装prometheus
https://prometheus.io/download/
[root@localhost ~]# ls anaconda-ks.cfg go1.17.3.linux-amd64.tar.gz prometheus-2.31.1.linux-amd64.tar.gz wget-log //解压 [root@localhost ~]# tar xf prometheus-2.31.1.linux-amd64.tar.gz -C /usr/local/ [root@localhost ~]# ls /usr/local/ bin etc games go include lib lib64 libexec prometheus-2.31.1.linux-amd64 sbin share src //重命名 [root@localhost ~]# mv /usr/local/prometheus-2.31.1.linux-amd64/ /usr/local/prometheus [root@localhost ~]# ls /usr/local/ bin etc games go include lib lib64 libexec prometheus sbin share src //启动 [root@localhost ~]# cat /usr/lib/systemd/system/prometheus.service [Unit] Description=prometheus service [Service] User=root ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/usr/local/prometheus/data ExecStop=/bin/kill -9 $MAINPID TimeoutStopSec=10 Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target [root@localhost ~]# systemctl daemon-reload [root@localhost ~]# systemctl enable --now prometheus.service Created symlink /etc/systemd/system/multi-user.target.wants/prometheus.service → /usr/lib/systemd/system/prometheus.service. [root@localhost ~]# ss -anltu Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:* tcp LISTEN 0 128 [::]:22 [::]:* tcp LISTEN 0 128 *:9090 *:*
浏览器输入ip+9090访问Prometheus自带的监控页面
被监控主机安装exporter
https://prometheus.io/download/
往下翻找到node_exporter’
[root@localhost ~]# wget https://github.com/prometheus/node_exporter/releases/download/v1.3.0/node_exporter-1.3.0.linux-amd64.tar.gz
prometheus搭配grafana使用
安装grafana
https://grafana.com/grafana/download



