普罗米修斯系统(普罗米修斯在线)
Prometheus使用在多维度上灵活的查询语言。PromQL 是 Prometheus 自己开发的数据查询 DSL 语言。
最近准备把我前段时间研究的多套常见的监控工具整理出来,分享给大家先整理一篇Prometheus的,希望能帮助到需要的朋友一、简介1.1 prometheus监控框架工具介绍prometheus是由谷歌研发的一款开源的监控软件,它通过安装在远程机器上的exporter,通过HTTP协议从远程的机器收集数据并存储在本地的时序数据库上。
目前已经被云计算本地基金会托管,是继k8s托管的第二个项目,号称是下一代监控1.2 优缺点
Prometheus架构图prometheus存储的是时序数据(时序列数据由metric名和一组key/value组成),即按相同时序(相同名称和标签),以时间维度存储连续的数据的集合metric名表示metric的功能,如http_request_total。
时序的名字由 ASCII 字符,数字,下划线,以及冒号组成,它必须满足正则表达式 [a-zA-Z_:][a-zA-Z0-9_:]*, 其名字应该具有语义化,一般表示一个可以度量的指标,例如 http_requests_total, 可以表示 http 请求的总数。
Prometheus使用在多维度上灵活的查询语言(PromQl)PromQL (Prometheus Query Language) 是 Prometheus 自己开发的数据查询 DSL 语言Prometheus具有易管理、易集成、可扩展、支持自动发信等优势。
同时Prometheus后端用 golang语言开发,前端是 Grafana,二次开发需要掌握相关语言。
Prometheus和其他监控系统横向比较1.3 支持类型Prometheus为了支持各种中间件以及第三方的监控提供了exporter,大家可以把它理解成监控适配器,将不同指标类型和格式的数据统一转化为Prometheus能够识别的指标类型。
例如Node exporter主要通过读取Linux的/proc以及/sys目录下的系统文件获取操作系统运行状态,reids exporter通过Reids命令行获取指标,mysql exporter通过读取数据库监控表获取MySQL的性能数据。
他们将这些异构的数据转化为标准的Prometheus格式,并提供HTTP查询接口
Prometheus各类exporter组件Prometheus的流行和Kubernetes密不可分,支持对Kubernetes、容器、OpenStack的监控。
Prometheus和k8s的结合二、部署过程2.1 安装包下载1.安装包github下载https://prometheus.io/download/
Prometheus组件包Github下载各个组件包,通过命令行方式安装配置。2.容器镜像下载https://hub.docker.com/u/prom
容器镜像在线拉取docker pull prom/prometheus2.2 prometheus安装部署1.上传已下载的各组件安装包
已下载的各组件2.部署到/usr/local/目录tar -zxvf prometheus-2.18.1.linux-amd64.tar.gz -C /usr/local/
解压部署3.修改文件夹名称mv prometheus-2.18.1.linux-amd64 prometheus
mv命令修改文件夹名称4.验证,查看版本号cd prometheus/./prometheus --version
2.18.1版本5.修改prometheus.yml配置文件vi prometheus.yml,配置相关监控项
按需修改yml文件6.设置prometheus用户groupadd prometheususeradd -g prometheus -s /sbin/nologin prometheus
7.给prometheus用户赋权cd ~chown -R prometheus:prometheus /usr/local/prometheus/
8.创建prometheus运行数据目录mkdir -p /var/lib/prometheuschown -R prometheus:prometheus /var/lib/prometheus/
9.设置开机启动touch /usr/lib/systemd/system/prometheus.servicechown prometheus:prometheus /usr/lib/systemd/system/prometheus.service
vi /usr/lib/systemd/system/prometheus.service添加下面内容,设置prometheus.service[Unit]Description=PrometheusDocumentation=https://prometheus.io/
[Service]# Type设置为notify时,服务会不断重启Type=simpleUser=prometheus# --storage.tsdb.path是可选项,默认数据目录在运行目录的./dada目录中
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/Prometheus --web.listen-address=:9090
Restart=on-failure[Install]WantedBy=multi-user.target
10.设置iptables(有防火墙要求的设置)vi /etc/sysconfig/iptables配置下面这段话:-A INPUT -p tcp -m state --state NEW -m tcp --dport 9090 -j ACCEPT
service iptables restart2.3 prometheus部署完成1.启动prometheus,并查看状态systemctl enable prometheussystemctl start prometheus
systemctl Prometheus status
netstat -tunlp | grep 9090
2.查看prometheus自带的web界面http://192.168.43.221:9090
在Status菜单下,Configuration,Rule,Targets等,Statu-->Configuration展示prometheus.yml的配置
在Statu-->Targets展示监控具体的监控目标,这里监控目标“linux”暂未设置node_exporter,所以没有数据
3.查看数据抓取情况访问http://192.168.43.221:9090/metrics,查看exporter具体能抓到的数据
2.4 grafana安装部署1. grafana下载登陆https://grafana.com/grafana/download官网,下载安装包
wget https://dl.grafana.com/oss/release/grafana-7.0.1-1.x86_64.rpm --no-check-certificate
2. grafana 安装yum install grafana-7.0.1-1.x86_64.rpm
3. 修改配置文件配置文件位于/etc/grafana/grafana.ini,这里暂时保持默认4.设置开机启动systemctl enable grafana-serversystemctl start grafana-server
5.检查服务启动状态service grafana-server status
6.设置iptables(需要防火墙的设置)vim /etc/sysconfig/iptables-A INPUT -p tcp -m state --state NEW -m tcp --dport 3000 -j ACCEPT
service iptables restart7.登陆grafana界面浏览器访问http://192.168.43.221:3000,默认登陆账号密码admin/admin
8.添加数据源点击设置按钮,通过“Add data source”添加数据源
根据配置项添加prometheus数据源相关配置
三 使用方法3.1 node_exporter方式监控服务器1. 部署到/usr/local/目录tar -zxvf node_exporter-1.0.0.linux-amd64.tar.gz -C /usr/local/
cd /usr/local/mv node_exporter-1.0.0.linux-amd64 node_exporter2. 设置用户groupadd prometheususeradd -g prometheus -s /sbin/nologin prometheus
chown -R prometheus:prometheus /usr/local/node_exporter/
3. 设置开机启动vi /usr/lib/systemd/system/node_exporter.service输入下面内容,配置node_exporter.service[Unit]Description=node_exporter
Documentation=https://prometheus.io/[Service]Type=simpleUser=prometheusExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure[Install]WantedBy=multi-user.target
3. 启动和检查服务systemctl enable node_exportersystemctl start node_exporterservice node_exporter status
4. 设置iptables(需要用到防火墙的配置)vim /etc/sysconfig/iptables-A INPUT -p tcp -m state --state NEW -m tcp --dport 9100 -j ACCEPT
service iptables restart5.检查监控界面可见node1主机已经可被监控
6.下载node_exporter监控的dashboard从官网https://grafana.com/dashboards/下载需要的dashboard到本地
7.导入dashboard通过import入口,上传导入已下载的dashboard
8.查看grafana监控展示情况
- 标签:
- 编辑:李松一
- 相关文章
-
头发软化剂(头发软化剂的作用和功效)
作用软化其实是柔顺的一种专业术语,软化是针对发质较硬的一种美发护理手段,一般效果明显。可以使头发变软,变柔顺,变贴服。且价格也很…
-
个人资料查询(高考个人资料查询)
#2023高考季#1、先了解专业,根据大部分大学毕业出来找工作的师兄师姐建议“好专业胜过好学校和高学历”。不知道怎么搜网上资料,可…
- 玩游戏花屏(玩游戏花屏是不是显卡坏了)
- dota术语(dota术语英文)
- 节目单封面(文艺汇演节目单封面)
- 教师资格证图片(教师资格证图片真实)
- 非主流转换器(非主流转换器繁体字)