prometheus在linux中的安装部署
普罗米修斯是一个开源系统 最初在 SoundCloud 上构建的监控和警报工具包。自2012年成立以来,许多 公司和组织都采用了普罗米修斯,该项目具有非常 活跃的开发人员和用户社区。它现在是一个独立的开源项目 并独立于任何公司进行维护。强调这一点,并澄清 该项目的治理结构,Prometheus于2016年加入云原生计算基金会 作为继 Kubernetes 之后的第二个托管项目。
文章共1,140字 · 阅读需要大约4分钟
一键AI生成摘要,助你高效阅读
问答
·
prometheus
普罗米修斯是一个开源系统 最初在 SoundCloud 上构建的监控和警报工具包。自2012年成立以来,许多 公司和组织都采用了普罗米修斯,该项目具有非常 活跃的开发人员和用户社区。它现在是一个独立的开源项目 并独立于任何公司进行维护。强调这一点,并澄清 该项目的治理结构,Prometheus于2016年加入云原生计算基金会 作为继 Kubernetes 之后的第二个托管项目。
特点
- 具有由指标名称和键/值对标识的时间序列数据的多维数据模型
- PromQL,一种灵活的查询语言,可利用此维度
- 不依赖分布式存储;单服务器节点是自治的
- 时序收集通过 HTTP 上的拉取模型进行
- 通过中间网关支持推送时间序列
- 通过服务发现或静态配置发现目标
- 多种图形和仪表板支持模式
组件及其架构
- 采集数据:exporter pushgateway 中间件(代理)
- 存储数据:tsdb
- 提供数据:http server
- 显示数据:grafana
- 告警、报警:alertmanager
在linux中部署prometheus
初始环境
下载地址:https://prometheus.io/download/
# 首先需要在prometheus官网去拉取安装包并且解压
[root@prometheus prometheus]# ls
prometheus-2.34.0.linux-amd64.tar.gz
[root@prometheus prometheus]# tar xf prometheus-2.34.0.linux-amd64.tar.gz
[root@prometheus prometheus]# ls
prometheus-2.34.0.linux-amd64 prometheus-2.34.0.linux-amd64.tar.gz
部署步骤
1、进入prometheus-2.34.0.linux-amd64文件夹启动prometheus
# 后台启动prometheus
[root@prometheus prometheus-2.34.0.linux-amd64]# nohup prometheus --config.file=/prometheus/prometheus-2.34.0.linux-amd64/prometheus.yml &
[1] 2383
[root@prometheus prometheus-2.34.0.linux-amd64]# nohup: ignoring input and appending output to ‘nohup.out’
2、查看promethues的状态
# 查看promethues是否运行
[root@prometheus prometheus-2.34.0.linux-amd64]# ps aux | grep prometheus
root 2383 0.2 4.3 782084 42916 pts/0 Sl 04:53 0:00 prometheus --config.file=/prometheus/prometheus-2.34.0.linux-amd64/prometheus.yml
root 2402 0.0 0.0 112808 968 pts/0 R+ 04:54 0:00 grep --color=auto prometheus
# prometheus默认监听9090端口
[root@prometheus prometheus-2.34.0.linux-amd64]# netstat -anplut | grep prometheus
tcp6 0 0 :::9090 :::* LISTEN 2383/prometheus
tcp6 0 0 ::1:9090 ::1:34326 ESTABLISHED 2383/prometheus
tcp6 0 0 ::1:34326 ::1:9090 ESTABLISHED 2383/prometheus
3、将prometheus做成一个服务来进行管理,非常方便
# 在/lib/systemd/system创建prometheus.service且开启服务
[root@prometheus system]# cat prometheus.service
[Unit]
Description=prometheus
[Service]
ExecStart=/prometheus/prometheus-2.34.0.linux-amd64/prometheus --config.file=/prometheus/prometheus-2.34.0.linux-amd64/prometheus.yml
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
# 重新加载systemd相关的服务
[root@prometheus system]# systemctl daemon-reload
4、注意
将prometheus做成服务时,第一次因为使用的是nohup方式启动的prometheus,还是需要使用kill的方式杀死第一次启动的进程,后面就可以使用systemctl或者service方式管理prometheus了。
5、开启prometheus服务后的命令
systemctl start prometheus 开启prometheus
systemctl stop prometheus 停止prometheus
systemctl restart prometheus 重启prometheus
systemctl enable prometheus 开机自启prometheus
systemctl disable prometheus 开机永远不开启prometheus
systemctl status prometheus 查看prometheus的状态
访问prometheus
prometheus部署成功!
更多推荐
已为社区贡献4条内容
所有评论(0)