Prometheus是一个开源的,基于metrics(度量)的一个开源监控系统,它有一个简单而强大的数据模型和查询语言,让我们分析应用程序。Prometheus诞生于2012年主要是使用go语言编写的,并在Apache2.0许可下获得许可,目前有大量的组织正在使用Prometheus在生产。2016年,Prometheus成为云计算组织(CNCF)第二个成员。
Prometheus部署
创建 prometheus用户
下载对应平台的安装包解压的目录
hostname$ tar xf prometheus-2.10.0.linux-amd64.tar.gzhostname$ mv prometheus-2.10.0.linux-amd64 /opt/
启动脚本
hostname$ sudo vim /usr/lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus instance
Wants=network-online.target
After=network-online.target
After=postgresql.service mariadb.service mysql.service
[Service]
User=prometheus
Group=prometheus
Type=simple
Restart=on-failure
WorkingDirectory=/opt/prometheus/RuntimeDirectory=prometheus
RuntimeDirectoryMode=0750ExecStart=/opt/prometheus/prometheus \--storage.tsdb.retention=15d \--config.file=/opt/prometheus/prometheus.yml \--web.max-connections=512\--web.read-timeout=5m \--storage.tsdb.path="/opt/data/prometheus"\--query.timeout=2m \--query.max-concurrency=200LimitNOFILE=10000TimeoutStopSec=20[Install]
WantedBy=multi-user.target
启动脚本
启动参数说明
--web.read-timeout=5m 请求连接的最大等待时间, 防止太多的空闲链接,占用资源
--web.max-connections=512 最大链接数
--storage.tsdb.retention=15d prometheus开始采集监控数据后会存在内存中和硬盘中, 太长的话,硬盘和内存都吃不消,太短的话,历史数据就没有了,设置15天为宜
--storage.tsdb.path="/opt/data/prometheus 存储数据路径,这个很重要,不要随便放在一个地方,会把/根目录塞满
--query.timeout=2m --query.max-concurrency=200 防止太多的用户同时查询,也防止单个用户执行过大的查询而一直不退出<