二、监控搭建-Prometheus-采集端部署

news/2024/5/18 23:41:41 标签: prometheus

二、监控搭建-Prometheus-采集端部署

  • 1、背景
  • 2、目标
  • 3、传承
  • 4、操作

1、背景

在上一篇中我们搭建了Prometheus平台,平台的搭建跟Linux系统上面安装了vim软件一样,给的只是一个很好的铸剑玄铁,具体的使用需要打磨和配件的运用。

2、目标

使用prometheus平台监控Linux主机资源

3、传承

本篇操作依赖《监控搭建-Prometheus》的基础上的操作

4、操作

1、准备资源包
将上篇中的软件包下载至本地

Linux系统采集模块: node_exporter 下载

上传至指定目录
2、进入程序目录并解压

cd /home
tar xf node_exporter-1.6.1.linux-amd64.tar.gz

3、部署

mv node_exporter-1.6.1.linux-amd64 /usr/local/node_exporter-1.6.1

4、创建符号链接

ln -s /usr/local/node_exporter-1.6.1/ /usr/local/node_exporter

5、创建服务文件

vi /usr/lib/systemd/system/node_exporter.service

[Unit]
Description=Prometheus node_exporter

[Service]
User=nobody
ExecStart=/usr/local/node_exporter/node_exporter --log.level=error
ExecStop=/usr/bin/killall node_exporter

[Install]
WantedBy=default.target

6、启动服务

systemctl start node_exporter

查看服务启动状态

systemctl status node_exporter
● node_exporter.service - Prometheus node_exporter
   Loaded: loaded (/usr/lib/systemd/system/node_exporter.service; disabled; vendor preset: disabled)
   Active: active (running) since Sat 2023-09-23 21:17:33 CST; 53s ago
 Main PID: 1549 (node_exporter)
   CGroup: /system.slice/node_exporter.service
           └─1549 /usr/local/node_exporter/node_exporter --log.level=error

Sep 23 21:17:33 devops systemd[1]: Started Prometheus node_exporter.

查看进程

ps -ef|grep node_exporter
nobody    1549     1  0 21:17 ?        00:00:00 /usr/local/node_exporter/node_exporter --log.level=error
root      1559  1500  0 21:19 pts/0    00:00:00 grep --color=auto node_exporter

7、将node_exporter加载到promtheus平台

vi /usr/local/prometheus/prometheus.yml

在scrape_configs模块下加入

scrape_configs:
  - job_name: 'prometheus'
  static_configs:
  - targets: ['localhost:9090']
  
  - job_name: 'host_monitor'
  static_configs:
  - targets: ['localhost:9100']

修改完毕配置文件,验证查看一下配置文件

cd /usr/local/prometheus
./promtool check config prometheus.yml
Checking prometheus.yml
 SUCCESS: prometheus.yml is valid prometheus config file syntax

验证端口

netstat -nltp | grep 9100
tcp6       0      0 :::9100                 :::*                    LISTEN      1586/node_exporter 

重启prometheus服务

systemctl restart prometheus

8、验证
查看
浏览器中输入 http://ip:9090在打开的浏览器页面的Statuc—Targets页面可以查看到host_monitor目标节点
在这里插入图片描述
指定查询
在首页页面中的检索框中使用node_cpu_seconds_total 进行检索。
在这里插入图片描述
查看到16个CPU

标签查看
单标签查询
node_cpu_seconds_total{mode=“idle”}
在这里插入图片描述
多标签查询
node_cpu_seconds_total{instance="localhost:9100",mode="idle"}
在这里插入图片描述
CPU使用率
在这里插入图片描述
内存使用率
(node_memory_MemTotal_bytes - node_memory_MemFree_bytes) / node_memory_MemTotal_bytes
在这里插入图片描述

硬盘使用率
100 - (((node_filesystem_size_bytes{fstype=~"xfs|ext4"} - node_filesystem_free_bytes{fstype=~"xfs|ext4"}) / node_filesystem_size_bytes{fstype=~"xfs|ext4"}) * 100)

在这里插入图片描述
以上为prometheus监控单机设备,后续会针对多台主机进行的自动发现,将主机信息进行手机获取。


http://www.niftyadmin.cn/n/5079619.html

相关文章

ChatGPT prompt汇总-个人使用-持续更新....

用途 学术写作更新记录 学术写作 中译英(GPT-4) I am a researcher studying deep learning and now trying to revise my manuscript which will be submitted to the Journal of Nature . I want you to act as a scientific English-Chinese translator, I will provide yo…

2023品牌新媒体矩阵营销洞察报告:流量内卷下,如何寻找增长新引擎?

近年来,随着移动互联网的发展渗透,短视频、直播的兴起,新消费/新零售、兴趣电商/社交电商等的驱动下,布局线上渠道已成为绝大多数品牌的必然选择。 2022年,越来越多的品牌加入到自运营、自播的行列中,并且从…

windows部署django服务器

windows部署django服务器 1、安装IIS1.1 控制面板-----程序----程序和功能----启用或关闭windows功能1.2安装IIS服务器,完成后,重新进入,把CGI安装进系统 2、安装python与虚拟环境2.1 安装python2.2 安装virtualenv虚拟环境2.3 创建一个虚拟环…

云数据库(林子雨慕课课程)

文章目录 6.云数据库6.1 云数据库概述6.2 云数据库产品6.3 UMP系统6.3.1 UMP系统概述6.3.2 UMP系统架构6.3.3 UMP系统功能 6.4 Amazon云数据库6.4.1 Amazon和云计算的渊源6.4.2 Amazon AWS6.4.3 AWS平台上的云数据库6.5 微软云数据库SQL Azure 6.云数据库 6.1 云数据库概述 云…

软考高项-项目管理概述2

领导力技能 领导力技能包括指导、激励和带领团队的能力。这些技能可能包括协商、抗压、沟通、解决问题、批判性思考和人际关系技能等基本能力。 领导者的品质和技能有:有远见、积极乐观、管理关系和冲突、正确沟通、终身学习结果导向、关注重要事情、能运用批判性思…

数据仓库与数据湖的区别以及数据入湖方式

数据仓库与数据湖的区别 1)从使用对象来看,数据仓库主要是给 BI分析的数据分析师使用的,而数据湖是给AI处理的数据科学家使用,数据仓库也可以给AI使用,但是侧重点是 BI. 2)从数据处理的过程来看,数据仓库是ETL&#…

12.验证码以及付费代理

文章目录 一、验证码的处理1、验证码概述1、2 什么是图片验证码?1、2 验证码的作用1、3 图片验证码使用场景1、4 图片验证码的处理方案 2、图片在网页页面中的形式2、1 如何进行图片形式的转化 3、打码平台 二、代理的使用2、1 付费代理2、1、1 找付费代理服务站点2…

vscode 连接ubuntu git下载缓慢

在ubuntu20.04下载: git clone https://github.com/introlab/rtabmap.git src/rtabmap 挂掉情况 export https_proxyhttp://10.10.10.176:7890export http_proxyhttp://10.10.10.176:7890 其中 10.10.10.176是我本机的ip地址,7890是我的代理后几位 如…