Prometheus(普罗米修斯)是一套开源的监控&报警&时间序列数据库的组合,起始是由 SoundCloud 公司开发。
输出被监控组件信息的 HTTP 接口被叫做 exporter(相当于 zabbix_agent)。目前互联网公司常用的组件大部分都有 exporter 可以直接使用,比如 Varnish、Haproxy、Nginx、MySQL、Linux 系统信息 (包括磁盘、内存、CPU、网络等等),具体支持的源看:https://github.com/prometheus。
Grafana 是一个跨平台的开源的度量分析和可视化工具,可以通过将采集的数据查询然后可视化的展示,并及时通知。
Prometheus 中存储的数据,通过 Grafana 很优美的展现出来。
这里测试安装将 Prometheus、Grafana、node_exporter 都安装在一台机器上。
go 环境配置
Golang的官网可能由于政策原因登陆不上,所以可以到Go语言中文网下载:https://studygolang.com/dl。
在 Ubuntu 系统上使用apt install golang-go
命令安装即可。
在 CentOS 系统上下载二进制包解压后即可:
- wget https://studygolang.com/dl/golang/go1.11.10.linux-amd64.tar.gz
- tar zxvf go1.11.10.linux-amd64.tar.gz -C /usr/local/
- ln -s /usr/local/go/bin/* /usr/local/bin/
Prometheus 部署
下载地址:https://prometheus.io/download/
- wget https://github.com/prometheus/prometheus/releases/download/v2.11.1/prometheus-2.11.1.linux-amd64.tar.gz
- tar zxvf prometheus-2.11.1.linux-amd64.tar.gz
- mv prometheus-2.11.1.linux-amd64 /usr/local/prometheus
- # 启动
- /usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml &
- # 启动后默认端口是 9090
Grafana 部署
- wget https://dl.grafana.com/oss/release/grafana-6.2.5.linux-amd64.tar.gz
- tar zxvf grafana-6.2.5.linux-amd64.tar.gz
- mv grafana-6.2.5.linux-amd64 /usr/local/grafana
- cp /usr/local/grafana/conf/defaults.ini /usr/local/grafana/conf/custom.ini
rafana 默认使用 sqllite3 数据库存储,这里修改为 MySQL,编辑/usr/local/grafana/conf/custom.ini
配置文件:
- [database]
- # You can configure the database connection by specifying type, host, name, user and password
- # as separate properties or as on string using the url property.
- # Either "mysql", "postgres" or "sqlite3", it's your choice
- type = mysql
- host = 127.0.0.1:3306
- name = grafana
- user = root
- # If the password contains # or ; you have to wrap it with triple quotes. Ex """#password;"""
- password = pwd123
先要创建好数据库,然后启动:
- /usr/local/grafana/bin/grafana-server &
- # 启动后默认端口是 3000,可使用 Nginx 反向代理进行访问。
登录后,默认用户名/密码都是:admin,首次登录会提示修改密码。
exporter 部署
下载地址:https://github.com/prometheus/node_exporter/releases
- wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
- tar zxvf node_exporter-0.18.1.linux-amd64.tar.gz
- mv node_exporter-0.18.1.linux-amd64/node_exporter /usr/local/bin/
- # 启动
- node_exporter &
启动后需要在 Prometheus 配置文件 prometheus.yml 中添加:
- - job_name: 'node'
- static_configs:
- - targets: ['127.0.0.1:9100']
然后重启 Prometheus 生效。
1.本站所有内容只做学习和交流使用。 版权归原作者所有。
2.保证站内提供的所有可下载源码资源(软件等)都是按“原样”提供,本站未做过任何改动;但本网站不保证本站提供的下载资源的准确性、安全性和完整性;同时本网站也不承担用户因使用这些下载资源对自己和他人造成任何形式的损失或伤害。
3.本站部分内容均收集于网络!如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。请联系站长邮箱:admin#ibian.online(#换成@)处理!