监控系列之-prometheus部署说明

一、Prometheus介绍

在这里插入图片描述

Prometheus是一款开源的监控系统,主要用于收集、存储和查询时间序列数据,以便于对系统进行监控和分析Prometheus的架构由四个主要组件组成:
1、Prometheus Server :Prometheus Server是Prometheus的核心组件,主要负责从各个目标(target)中收集指标(metrics)数据,并对这些数据进行存储、聚合和查询。
2、Client Libraries :Prometheus提供了多种客户端库,用于在应用程序中嵌入Prometheus的指标收集功能。
3、Exporters :Exporters是用于将第三方系统的监控数据导出为Prometheus格式的组件。Prometheus支持多种Exporters,例如Node Exporter、MySQL Exporter、HAProxy Exporter等。
4、Alertmanager:Alertmanager是Prometheus的告警组件,用于根据用户定义的规则对监控数据进行告警。Prometheus的特点
1、灵活的数据模型:Prometheus采用的是key-value对的形式存储指标数据,每个指标都可以包含多个标签(labels),这样可以更加灵活地描述指标数据
2、高效的存储和查询:Prometheus使用自己的时间序列数据库,可以高效地存储和查询大量的指标数据。
3、强大的可视化和告警功能:Prometheus提供了Web界面和API,可以方便地展示和查询监控数据。
4、可扩展性强:Prometheus的架构非常灵活,可以根据需要选择合适的组件进行配置。
CNCF的成员项目:Prometheus作为CNCF的项目之一,得到了广泛的关注和支持,并且得到了来自全球各地的贡献者的积极参与和开发.

二、Prometheus部署搭建

1、node_exporter部署搭建

1、下载
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz2、解压部署启动
tar -xf node_exporter-1.8.2.linux-amd64.tar.gz
ln -s node_exporter-1.8.2.linux-amd64 /usr/local/node_exporter3、设置启动脚本
vim start_noder.sh
/usr/local/node_exporter/node_exporter \
--collector.textfile.directory=/usr/local/node_exporter/tmp/ \
--web.config.file=config.yml \
--web.listen-address=0.0.0.0:191004、附录config.yml文件配置(账号密码admin/123456 此文档中所有都是使用的该信息)
cat config.yml 
basic_auth_users:admin: $2y$12$Y9/tZwO8FJC2I.IPt47ufOwFZRNrjSOPk0rUtOhB97cXNdvCikFDW

2、proc_exporter部署

1、此处需要使用到pyton3,推荐使用anaconda3进行安装,此处略,对应网址
https://www.anaconda.com/download2、prometheus_client安装
python3 -m pip install  client_python-0.13.1.tar.gz 3、设置开机自启动脚本
vim /usr/lib/systemd/system/proc_exporter.service
[Unit]
Description=proc_exporter
After=network.target[Service]
Type=simple
ExecStart=/usr/bin/python3 /usr/local/proc_exporter/proc_exporter.py -c /usr/local/proc_exporter/proc_exporter.ini
Restart=on-failure[Install]
WantedBy=multi-user.target4、配置文件调整修改,按照如下格式进行业务模块添加删除
vim proc_exportter.ini
## 进程配置, 修改后生效, 不需要重启
[node_exporter]
## 进程名: 能够唯一标识进程的关键字, 如: node_exporter
name = node_exporter## 进程模块: 进程所归属的子系统或模块, 如: prometheus,
moudle = prometheus## 进程负责人: 当进程出现异常, 需要介入处理的开发人员
manager = ## core文件目录, 配置绝对路径, 如不需要检测core文件则配空
directory =## core文件名前缀
prefix = 5、启动systemctl daemon-reloadsystemctl enable proc_exporter.servicesystemctl restart proc_exporter.service

3、Alertmanager部署

1、下载
wget https://github.com/prometheus/alertmanager/releases/download/v0.27.0/alertmanager-0.27.0.linux-amd64.tar.gz2、解压部署
tar -xf alertmanager-0.27.0.linux-amd64.tar.gz
ln -s alertmanager-0.27.0.linux-amd64 /usr/local/alertmanager3、编写启动脚本
vim /usr/lib/systemd/system/alertmanager.service
[Unit]
Description=alertmanager server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target[Service]
Type=simple
User=root
Group=root
Restart=on-abnormal
ExecStart=/usr/local/alertmanager/alertmanager \--config.file=/usr/local/alertmanager/alertmanager.yml \--web.listen-address=0.0.0.0:19093 \--web.config.file=/usr/local/alertmanager/config.yml \[Install]
WantedBy=multi-user.target4、配置文件调整
vim alertmanager.yml
global:resolve_timeout: 5msmtp_smarthost: 'smtp.mail.139.com:25'     # 邮箱smtp服务器smtp_from: 'hly12599-alarm@139.com'             # 发送邮箱名称smtp_auth_username: 'hly12599-alarm@139.com'    # 邮箱地址smtp_auth_password: '23bb4dee88805e0fb400'          # 邮箱密码smtp_require_tls: falseroute:group_by: ['alertname']group_wait: 10s    group_interval: 5mrepeat_interval: 3mreceiver: 'alert-receiver'routes:- receiver: 'data'continue: truetemplates:- './templates/*.tmpl'
receivers:
- name: 'data'webhook_configs:- url: 'http://192.168.10.139:5000/alertinfo'
- name: 'alert-receiver'email_configs:- to: 15901283579@139.comsend_resolved: trueinhibit_rules:- source_match:severity: 'warning'target_match:severity: 'warning'equal: ['job', 'instance','severity']
####检查配置:./amtool check-config alertmanager.yml5、启动systemctl daemon-reloadsystemctl enable alertmanager.servicesystemctl restart alertmanager.service

4、pushgateway部署

1、下载
wget https://github.com/prometheus/pushgateway/releases/download/v1.9.0/pushgateway-1.9.0.linux-amd64.tar.gz2、解压部署
tar -xf pushgateway-1.9.0.linux-amd64.tar.gz
ln -s pushgateway-1.9.0.linux-amd64 /usr/local/pushgateway3、编写启动文件
vim /usr/lib/systemd/system/pushgateway.service
[Unit]
Description=pushgateway
Wants=network-online.target
After=network-online.target[Service]
Type=simple
User=root
Group=root
Restart=always
ExecStart=/usr/local/pushgateway/pushgateway \--web.listen-address=0.0.0.0:19091  \--web.config.file=/usr/local/pushgateway/config.yml [Install]
WantedBy=multi-user.target4、启动systemctl daemon-reloadsystemctl enable pushgateway.servicesystemctl restart pushgateway.service

5、prometheus部署

1、下载
wget https://github.com/prometheus/prometheus/releases/download/v2.53.2/prometheus-2.53.2.linux-amd64.tar.gz2、解压部署
tar -xf prometheus-2.53.2.linux-amd64.tar.gz
ln -s prometheus-2.53.2.linux-amd64 /usr/local/prometheus3、编写启动脚本
vim /usr/lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target[Service]
Type=simple
User=root
Group=root
Restart=on-abnormal
ExecStart=/usr/local/prometheus/prometheus \--config.file=/usr/local/prometheus/prometheus.yml \--web.listen-address=0.0.0.0:19090 \--web.config.file=/usr/local/prometheus/config.yml \--storage.tsdb.path=/usr/local/prometheus/data \--storage.tsdb.retention.time=180d \--web.console.templates=/usr/local/monitor/prometheus/consoles \--web.console.libraries=/usr/local/monitor/prometheus/console_libraries \--web.max-connections=512 \--web.enable-lifecycle[Install]
WantedBy=multi-user.target4、启动systemctl daemon-reloadsystemctl enable prometheus.servicesystemctl restart prometheus.service5、修改配置文件,添加主机监控和进程监控
vim prometheus.yml
global:scrape_interval: 60s # Set the scrape interval to every 15 seconds. Default is every 1 minute.evaluation_interval: 30s # Evaluate rules every 15 seconds. The default is every 1 minute.
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:- "./rules/*.yml"
scrape_configs:- job_name: "node_host"basic_auth:username: adminpassword: 123456scrape_interval: 1mstatic_configs:- targets: ["192.168.10.139:19100"]- job_name: "proc_host"scrape_interval: 1mscrape_timeout: 1mmetrics_path: /metricsstatic_configs:- targets: ["192.168.10.140:19001"]- job_name: "alertmanager"basic_auth:username: adminpassword: 123456static_configs:- targets: ["192.168.10.139:19093"]- job_name: "pushgateway_server"basic_auth:username: adminpassword: 123456honor_labels: truescrape_interval: 1mscrape_timeout: 1mstatic_configs:- targets: ["192.168.10.139:9091"]6、加载生效
curl -X POST -u admin:123456  http://192.168.10.139:9090/-/reload

6、Grafana部署

1、下载地址
wget https://dl.grafana.com/oss/release/grafana-10.3.7-1.x86_64.rpm2、安装部署启动
rpm -Uvh grafana-10.3.7-1.x86_64.rpm3、修改配置文件端口,然后启动即可
echo "http_port = 13000" >> /etc/grafana/grafana.ini
systemctl daemon-reload
systemctl enable grafana-server.service
systemctl restart grafana-server.service4、通过web浏览器即可打开对应的web界面

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.xdnf.cn/news/141564.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

一步一步自制py脚本并且并且修改为exe可执行文件教学外附带SHA-1解密exe文件资源

第一步:安装 Python 下载 Python:访问 Python 官网 下载并安装最新版本的 Python。安装时选择添加到环境变量 PATH:在安装过程中,确保勾选“Add Python to PATH”选项。 第二步:编写 Python 脚本 创建一个新的 Pyth…

人脸防伪检测系统源码分享

人脸防伪检测检测系统源码分享 [一条龙教学YOLOV8标注好的数据集一键训练_70全套改进创新点发刊_Web前端展示] 1.研究背景与意义 项目参考AAAI Association for the Advancement of Artificial Intelligence 项目来源AACV Association for the Advancement of Computer Vis…

✔2848. 与车相交的点

代码实现&#xff1a; 方法一&#xff1a;哈希表 #define fmax(a, b) ((a) > (b) ? (a) : (b))int numberOfPoints(int **nums, int numsSize, int *numsColSize) {int hash[101] {0};int max 0;for (int i 0; i < numsSize; i) {max fmax(max, nums[i][1]);for …

Spring4-IoC3-手写IoC

Spring框架的IoC是基于Java反射机制实现的 Java反射机制是在运行状态中&#xff0c;对于任意一个类&#xff0c;都能够知道这个类的所有属性和方法&#xff1b;对于任意一个对象&#xff0c;都能够调用它的任意方法和属性&#xff0c;这种动态获取信息以及动态调用对象方法的功…

学习大数据DAY57 新的接口配置

作业  完成 API 接口和文件的接入, 并部署到生产调度平台, 每个任务最后至少 要有两条 不报错 的日志, 报错就驳回作业  作业不需要复制日志 API Appliation Program Interface 应用程序接口 > JSON 的地址 客户需求: 把 https://zhiyun.pub:9099/site/c-class…

【QT】定时器使用

文章目录 关于 Qt 定时器使用的注意细节总结实例-检查工具使用周期时间是否合理UI设计头文件 remind.h源文件 remind.cpp实现效果 关于 Qt 定时器使用的注意细节总结 一、创建与初始化 使用 QTimer 类来创建定时器。可以在构造函数中指定父对象&#xff0c;确保定时器在正确的…

电子电气架构——中央计算的软件定义汽车架构

我是穿拖鞋的汉子&#xff0c;魔都中坚持长期主义的汽车电子工程师。 老规矩&#xff0c;分享一段喜欢的文字&#xff0c;避免自己成为高知识低文化的工程师&#xff1a; 屏蔽力是信息过载时代一个人的特殊竞争力&#xff0c;任何消耗你的人和事&#xff0c;多看一眼都是你的不…

台风,也称为热带气旋,是一种在热带海洋上形成的强烈风暴系统。台风的形成需要满足以下几个条件:

台风&#xff0c;也称为热带气旋&#xff0c;是一种在热带海洋上形成的强烈风暴系统。台风的形成需要满足以下几个条件&#xff1a; 1. **温暖的海水**&#xff1a;台风通常在海面温度至少达到26.5C&#xff08;79.7F&#xff09;的海域形成&#xff0c;因为温暖的海水能够提供…

XShell快速连接虚拟机(Ubuntu系统)

目录 前言 一 (XShell)(虚拟机 )(Ubuntu)下载 二 虚拟机的ip查找 三 虚拟机中安装连接环境 四 开启ssh-server服务 五 验证是Ubuntu是否开启ssh-server服务 六 连接XShell软件 前言 对于刚开始探索 Linux 世界的新手来说&#xff0c;拥有一台自己的服务器可能并不现实。幸运的…

学习大数据DAY58 增量抽取数据表

作业 1 SQL 优化的常见写法有哪些 - 面试经常被问 使用索引&#xff1a;合理创建和使用索引是提高查询效率的关键。索引可以加速数据的检 索速度&#xff0c;但是索引也会占用额外的存储空间&#xff0c;并且在插入、删除和更新操作时会 有额外的开销。 避免全表扫描&…

【ARM】中断术语介绍

外设产生中断给到gic&#xff0c;gic通过内部判断此中断是FIQ还是IRQ&#xff0c;这个过程就称为assert&#xff08;断言&#xff09; 此中断被发到哪里面去叫target cpu跳转到此中断的中断向量表中叫做taken 整个过程就做routing distribute决定将中断发给哪个cpu&#xff08…

【STM32】DAC数字模拟转换

本篇博客重点在于标准库函数的理解与使用&#xff0c;搭建一个框架便于快速开发 目录 前言 DAC简介 DAC配置 DAC时钟使能 GPIO初始化 DAC配置 DAC使能 读写DAC值 驱动代码 MyDAC.h MyDAC.c main.c 前言 大容量的STM32F101xx和STM32F103xx产品才有DAC外设 大容量…

基于SpringBoot的在线考试系统【附源码】

基于SpringBoot的在线考试系统&#xff08;源码L文说明文档&#xff09; 目录 4 系统设计 4.1 系统概述 4.2系统功能结构设计 4.3.2 数据库表结构设计 5 系统实现 5.1管理员功能介绍 5.1.1管理员登录 5.1.2 试卷管理 5.1.3 公告信息管理 5.1.…

_Array类,类似于Vector,其实就是_string

例子&#xff1a; using namespace lf; using namespace std;int main() {_Array<int> a(10, -1);_Array<_string> s { _t("one"), _t("two") };_pcn(a);_pcn(s);} 结果&#xff1a; 源代码_Array.h&#xff1a; /***********************…

基础物理-直线运动2

2-1 位置、位移和平均速度 位置与位移 为了确定物体的位置&#xff0c;通常需要相对于某个参考点来测量&#xff0c;这个参考点通常是某个坐标轴的原点&#xff08;或零点&#xff09;&#xff0c;如图 2-1 中的 x 轴。坐标轴的正方向是坐标增大的方向&#xff0c;在图 2-1 中…

掌握远程管理的艺术:揭秘Python的pywinrm库

文章目录 &#x1f525; 掌握远程管理的艺术&#xff1a;揭秘Python的pywinrm库 &#x1f525;背景&#xff1a;为何选择pywinrm&#xff1f;pywinrm库简介安装pywinrm库简单库函数使用方法场景应用常见问题与解决方案总结 &#x1f525; 掌握远程管理的艺术&#xff1a;揭秘Py…

【ARM】Cache深度解读

Cache的基本概念和使用场景 不同的Master硬件共享数据时—invalid cache 外设和DDR之间没有cache&#xff0c;所以外设直接把数据写入DDR中&#xff0c;但是cpu和DDR之间有cache&#xff0c;cpu会首先访问cache&#xff0c;如果命中直接从cache中拿数据&#xff0c;但是此时的…

浪潮信息首推3秒智能控温!告别服务器开机噪音

在当前的数据中心运维实践中&#xff0c;运维人员在部署服务器时常被“飞机起飞”般的开机噪音所困扰。服务器刚刚接通电源&#xff0c;其内部元件尚处于预热待命状态&#xff0c;而风扇却已全速运转&#xff0c;这不仅加剧了噪音污染&#xff0c;还拖慢了启动速度&#xff0c;…

[数据集][目标检测]智慧交通铁路人员危险行为躺站坐检测数据集VOC+YOLO格式3766张4类别

图片数量(jpg文件个数)&#xff1a;3766 标注数量(xml文件个数)&#xff1a;3766 标注数量(txt文件个数)&#xff1a;3766 标注类别数&#xff1a;4 标注类别名称:["sitting","sleeping","standing","track"] 每个类别标注的框数&…

OpenCore Legacy Patcher 2.0.0 发布,83 款不受支持的 Mac 机型将能运行最新的 macOS Sequoia

在不受支持的 Mac 上安装 macOS Sequoia (OpenCore Legacy Patcher v2.0.0) Install macOS on unsupported Macs 请访问原文链接&#xff1a;https://sysin.org/blog/install-macos-on-unsupported-mac/&#xff0c;查看最新版。原创作品&#xff0c;转载请保留出处。 作者主…