Prometheus的部署

Prometheus的部署
Prometheus介绍

Prometheus是一个开源的系统监控和警报工具包,最初由SoundCloud构建。自2012年成立以来,许多公司和组织都采用了Prometheus,该项目拥有非常活跃的开发人员和用户社区。它现在是一个独立的开源项目,独立于任何公司进行维护。为了强调这一点,并澄清项目的治理结构,Prometheus于2016年加入了云原生计算基金会,成为Kubernetes之后的第二个托管项目。

普罗米修斯收集和存储它的指标作为时间序列数据,也就是说,指标信息与它被记录的时间戳一起存储,以及称为标签的可选键值对。

Prometheus特性:

1、一个多维数据模型,其时间序列数据由指标名称和键/值对标识
2、PromQL是一种灵活的查询语言,可以利用这个维度
3、不依赖分布式存储;单个服务器节点是自治的
4、时间序列收集通过HTTP上的拉模型进行
5、通过中间网关支持推送时间序列
6、通过服务或静态配置发现的目标
7、支持多种模式的图形化和仪表板

什么是指标:

用外行的术语来说,指标是数值度量。时间序列意味着随着时间的推移而记录的变化。用户想要指标的内容因应用程序而异。对于web服务器,可能是请求次数,对于数据库,可能是活动连接数或活动查询数等。

指标在理解应用程序为何以某种方式工作方面发挥着重要作用。让我们假设您正在运行一个web应用程序,并发现该应用程序很慢。您将需要一些信息来了解您的应用程序发生了什么。例如,当请求数量很高时,应用程序可能会变慢。如果您有请求计数指标,您可以发现原因并增加服务器数量来处理负载。

相关组件:

Prometheus生态系统由多个部分组成,其中许多部分是可选的:
1、Prometheus主服务器,用于抓取和存储时间序列数据
2、用于测试应用程序代码的客户端库
3、支持短期作业的推送网关
4、专门的服务出口HAProxy、StatsD、Graphite等。
5、用于处理警报的alertmanager
6、各种支持工具

大多数Prometheus组件都是用Go语言编写的,这使得它们很容易作为静态二进制文件构建和部署。

体系结构:
在这里插入图片描述
Prometheus从工具化作业中获取指标,要么直接获取,要么通过中介推送网关获取短期作业。它将所有抓取的样本存储在本地,并在这些数据上运行规则,从现有数据中聚合和记录新的时间序列,或生成警报。Grafana或其他API消费者可用于可视化收集的数据。

Prometheus的下载地址:https://prometheus.io/download/
在这里插入图片描述

[root@std ~]# tar -xvf prometheus-2.42.0.linux-amd64.tar.gz
[root@std ~]# mv prometheus-2.42.0.linux-amd64 /usr/local/prometheus
[root@std ~]# useradd -M -s /sbin/nologin prometheus
[root@std ~]# mkdir -p /data/prometheus
[root@std ~]# chown -R prometheus:prometheus /usr/local/prometheus /data/prometheus
将配置文件中的localhost:9090改为172.12.9.41:9090
[root@std prometheus]# vi /usr/local/prometheus/prometheus.yml

在这里插入图片描述
修改为:
在这里插入图片描述

[root@std prometheus]# vi /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus
After=network.target

[Service]
Type=simple
Environment="GOMAXPROCS=4"
User=prometheus
Group=prometheus
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/prometheus/prometheus \
  --config.file=/usr/local/prometheus/prometheus.yml \
  --storage.tsdb.path=/data/prometheus \
  --storage.tsdb.retention=30d \
  --web.console.libraries=/usr/local/prometheus/console_libraries \
  --web.console.templates=/usr/local/prometheus/consoles \
  --web.listen-address=172.12.9.41:9090 \
  --web.read-timeout=5m \
  --web.max-connections=10 \
  --query.max-concurrency=20 \
  --query.timeout=2m \
  --web.enable-lifecycle
PrivateTmp=true
PrivateDevices=true
ProtectHome=true
NoNewPrivileges=true
LimitNOFILE=infinity
ReadWriteDirectories=/data/prometheus
ProtectSystem=full

SyslogIdentifier=prometheus
Restart=always

[Install]
WantedBy=multi-user.target
[root@std prometheus]# systemctl daemon-reload
[root@std prometheus]# systemctl enable prometheus && systemctl start prometheus
Created symlink from /etc/systemd/system/multi-user.target.wants/prometheus.service to /etc/systemd/system/prometheus.service.
[root@std prometheus]# netstat -lntp | grep prometheus
-bash: netstat: command not found
[root@std prometheus]# ps -ef|grep prometheus
prometh+ 19812     1  0 11:07 ?        00:00:00 /usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/data/prometheus --storage.tsdb.retention=30d --web.console.libraries=/usr/local/prometheus/console_libraries --web.console.templates=/usr/local/prometheus/consoles --web.listen-address=0.0.0.0:9090 --web.read-timeout=5m --web.max-connections=10 --query.max-concurrency=20 --query.timeout=2m --web.enable-lifecycle
root     19869 19208  0 11:08 pts/0    00:00:00 grep --color=auto prometheus

prometheus就已经安装并启动,默认会启动9090端口,通过浏览器打开该端口页面,不需用户名和密码
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值