二进制部署Prometheus+grafana+alertmanager+node_exporter

Prometheus 是一个开源的监控和告警工具包,旨在提供高可靠性和可扩展性。它最初由 SoundCloud 开发,现已成为云原生计算基金会(CNCF)的一部分。以下是 Prometheus 的一些关键特性和概念:

1. **时间序列数据库**:Prometheus 将所有数据存储为时间序列,这些时间序列通过指标名称和一组键值对(称为标签)进行标识。这种设计允许高维度的数据收集和查询。

2. **数据收集**:Prometheus 使用拉取模型来收集指标。它会在配置的端点上以指定的时间间隔抓取指标,这些端点以简单的文本格式暴露指标。

3. **查询语言**:Prometheus 提供了一种强大的查询语言,称为 PromQL(Prometheus 查询语言),允许用户轻松提取和操作时间序列数据。

4. **告警功能**:Prometheus 内置了告警功能。用户可以基于 PromQL 查询定义告警规则,Prometheus 可以通过 Alertmanager 将告警发送到各种通知渠道(如电子邮件、Slack 等)。

5. **可视化**:虽然 Prometheus 本身不提供高级可视化功能,但可以与 Grafana 等工具集成,以创建仪表板和可视化的指标表现。

6. **可扩展性**:Prometheus 设计用于处理大量数据,可以通过使用多个实例和联邦机制进行水平扩展。

7. **服务发现**:Prometheus 可以使用各种服务发现机制(例如 Kubernetes、Consul 等)自动发现要抓取指标的目标,使其适用于动态环境。

8. **生态系统**:Prometheus 拥有丰富的导出器生态系统,导出器是将各种服务和系统(如数据库、Web 服务器等)的指标以 Prometheus 可抓取的格式暴露出来的组件。

总的来说,Prometheus 被广泛用于监控云原生应用和微服务,为系统性能和可靠性提供了宝贵的洞察。

下载安装包:
 

Prometheus下载: https://prometheus.io/download/
wget https://github.com/prometheus/prometheus/releases/download/v2.53.3/prometheus-2.53.3.linux-amd64.tar.gzGrafana下载: https://grafana.com/grafana/download?pg=get&plcmt=selfmanaged-box1-cta1
wget https://dl.grafana.com/enterprise/release/grafana-enterprise-11.3.1.linux-amd64.tar.gzAlertmanager下载: https://prometheus.io/download/#alertmanager
wget https://github.com/prometheus/alertmanager/releases/download/v0.27.0/alertmanager-0.27.0.linux-amd64.tar.gzNode_exporter下载: https://prometheus.io/download/#node_exporter
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz

解压:

mkdir /usr/local/prometheus
tar xvf prometheus-2.53.3.linux-amd64.tar.gz
mv prometheus-2.53.3.linux-amd64 /usr/local/prometheus/prometheustar xvf node_exporter-1.8.2.linux-amd64.tar.gz
mv node_exporter-1.8.2.linux-amd64 /usr/local/prometheus/node_exportertar xvf alertmanager-0.27.0.linux-amd64.tar.gz
mv alertmanager-0.27.0.linux-amd64 /usr/local/prometheus/alertmanagertar xvf grafana-enterprise-11.3.1.linux-amd64.tar.gz
mv grafana-v11.3.1 /usr/local/prometheus/grafana

配置开机Prometheus开机服务

cat > /usr/lib/systemd/system/prometheus.service << 'EOF'
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target[Service]
Type=simple
User=prometheus
Group=prometheus
Restart=on-failure
ExecStart=/usr/local/prometheus/prometheus/prometheus \--config.file=/usr/local/prometheus/prometheus/prometheus.yml \--storage.tsdb.path=/usr/local/prometheus/prometheus/data \--storage.tsdb.retention.time=60d \--web.enable-lifecycle[Install]
WantedBy=multi-user.targetEOF

配置grafana开机服务

cat > /usr/lib/systemd/system/grafana.service << 'EOF'
[Unit]
Description=Grafana server
Documentation=http://docs.grafana.org
[Service]
Type=simple
User=prometheus
Group=prometheus
Restart=on-failure
ExecStart=/usr/local/prometheus/grafana/bin/grafana-server \--config=/usr/local/prometheus/grafana/conf/defaults.ini \--homepath=/usr/local/prometheus/grafana
[Install]
WantedBy=multi-user.targetEOF

配置alertmanager开机服务

cat > /usr/lib/systemd/system/alertmanager.service << 'EOF'
[Unit]
Description=Alert Manager
Wants=network-online.target
After=network-online.target[Service]
Type=simple
User=prometheus
Group=prometheus
ExecStart=/usr/local/prometheus/alertmanager/alertmanager \--config.file=/usr/local/prometheus/alertmanager/alertmanager.yml \--storage.path=/usr/local/prometheus/alertmanager/data
Restart=always[Install]
WantedBy=multi-user.targetEOF

配置node_exporter开机服务

cat > /usr/lib/systemd/system/node_exporter.service << 'EOF'
[Unit]
Description=node_exporter
Documentation=https://prometheus.io/
After=network.target
[Service]
User=prometheus
Group=prometheus
ExecStart=/usr/local/prometheus/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.targetEOF

配置开机自启

useradd --no-create-home --shell /bin/false prometheus
或者
useradd -M -s /usr/sbin/nologin prometheuschown -R prometheus.prometheus /usr/local/prometheus
systemctl daemon-reloadsystemctl enable --now prometheus
systemctl status prometheussystemctl enable --now alertmanager
systemctl status alertmanagersystemctl enable --now node_exporter
systemctl status node_exportersystemctl enable --now grafana
systemctl status grafana

端口说明:

root@u22pro:~# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      677/systemd-resolve
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      36805/sshd: /usr/sb
tcp6       0      0 :::3000                 :::*                    LISTEN      104697/grafana
tcp6       0      0 :::22                   :::*                    LISTEN      36805/sshd: /usr/sb
tcp6       0      0 :::9100                 :::*                    LISTEN      104555/node_exporte
tcp6       0      0 :::9090                 :::*                    LISTEN      104520/prometheus
tcp6       0      0 :::9093                 :::*                    LISTEN      104539/alertmanager
tcp6       0      0 :::9094                 :::*                    LISTEN      104539/alertmanager
root@u22pro:~#3000 - grafana 管理页面 
9100 - node_exporter上报metrics 端口 
9090 - prometheus 管理页面
9093 - alertmanager 管理页面
9094 - alertmanager 

prometheus.yml配置

root@u22pro:/usr/local/prometheus/prometheus# cat prometheus.yml | grep -v '#'
global:alerting:alertmanagers:- static_configs:- targets:rule_files:- "alert.yml"scrape_configs:- job_name: "prometheus"static_configs:- targets: ["localhost:9090"]- job_name: 'node-exporter'scrape_interval: 15sstatic_configs:- targets: ['localhost:9100']labels:instance: Prometheus服务器- targets: ['192.168.50.5:9100']labels:instance: linux-192.168.50.5- targets: ['192.168.50.6:9100']labels:instance: linux-192.168.50.6

alert.yml

root@u22pro:/usr/local/prometheus/prometheus# cat alert.yml
groups:
- name: Prometheus alertrules:# 对任何实例超过30s无法联系的情况 发出警报- alert: 服务告警expr: up == 0for: 30slabels:severity: criticalannotations:instance: "{{ $labels.instance }}"description: "{{ $labels.job  }} 服务已关闭"- name: 服务器资源监控rules:- alert: 内存使用率过高expr: 100 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100 > 80 #这里的监控参数根据自己实际监控的指标去修改,其他维度的同理for: 3mlabels:severity: 严重告警annotations:summary: "{{ $labels.instance }} 内存使用率过高, 请尽快处理!"description: "{{ $labels.instance }}内存使用率超过80%,当前使用率{{ $value }}%."- alert: 服务器宕机expr: up == 0for: 1slabels:severity: 严重告警annotations:summary: "{{$labels.instance}} 服务器宕机, 请尽快处理!"description: "{{$labels.instance}} 服务器延时超过3分钟,当前状态{{ $value }}. "- alert: CPU高负荷expr: 100 - (avg by (instance,job)(irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 90for: 5mlabels:severity: 严重告警annotations:summary: "{{$labels.instance}} CPU使用率过高,请尽快处理!"description: "{{$labels.instance}} CPU使用大于90%,当前使用率{{ $value }}%. "- alert: 磁盘IO性能expr: avg(irate(node_disk_io_time_seconds_total[1m])) by(instance,job)* 100 > 90for: 5mlabels:severity: 严重告警annotations:summary: "{{$labels.instance}} 流入磁盘IO使用率过高,请尽快处理!"description: "{{$labels.instance}} 流入磁盘IO大于90%,当前使用率{{ $value }}%."- alert: 网络流入expr: ((sum(rate (node_network_receive_bytes_total{device!~'tap.*|veth.*|br.*|docker.*|virbr*|lo*'}[5m])) by (instance,job)) / 100) > 102400for: 5mlabels:severity: 严重告警annotations:summary: "{{$labels.instance}} 流入网络带宽过高,请尽快处理!"description: "{{$labels.instance}} 流入网络带宽持续5分钟高于100M. RX带宽使用量{{$value}}."- alert: 网络流出expr: ((sum(rate (node_network_transmit_bytes_total{device!~'tap.*|veth.*|br.*|docker.*|virbr*|lo*'}[5m])) by (instance,job)) / 100) > 102400for: 5mlabels:severity: 严重告警annotations:summary: "{{$labels.instance}} 流出网络带宽过高,请尽快处理!"description: "{{$labels.instance}} 流出网络带宽持续5分钟高于100M. RX带宽使用量{$value}}."- alert: TCP连接数expr: node_netstat_Tcp_CurrEstab > 10000for: 2mlabels:severity: 严重告警annotations:summary: " TCP_ESTABLISHED过高!"description: "{{$labels.instance}} TCP_ESTABLISHED大于100%,当前使用率{{ $value }}%."- alert: 磁盘容量expr: 100-(node_filesystem_free_bytes{fstype=~"ext4|xfs"}/node_filesystem_size_bytes {fstype=~"ext4|xfs"}*100) > 90for: 1mlabels:severity: 严重告警annotations:summary: "{{$labels.mountpoint}} 磁盘分区使用率过高,请尽快处理!"description: "{{$labels.instance}} 磁盘分区使用大于90%,当前使用率{{ $value }}%."

修改配置之后,手动重载配置
curl -X POST http://localhost:9090/-/reload

检测Prometheus配置文件是否正确
./promtool check config prometheus.yml

打开gafana管理页面,添加prometheus datasource

添加node_exportor dashboard

grafana服务器监控显示面板:

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

工业智能网关如何为企业实现智能制造赋能?

在数字化转型的浪潮中&#xff0c;工业智能网关作为连接物理世界与数字世界的桥梁&#xff0c;正逐步成为智能制造领域的核心组件。本文将通过一个实际使用案例&#xff0c;深入剖析工业智能网关如何助力企业实现生产流程的优化、数据的高效采集与分析&#xff0c;以及智能化决…

算法设计6_随机化算法

随机化算法 随机算法的随机性&#xff08;基本特征&#xff09; – 对于同一实例的多次执行, 效果可能完全不同 – 时间复杂性的一个随机变量 – 解的正确性和准确性也是随机的 数值随机化算法 随机数值算法 – 主要用于数值问题求解 – 算法的输出往往是近似解 – 近似…

使用mmdeploy框架C++预测mask并绘制最小外接矩形

目录 解决目标 逻辑思路 代码实现 第1部分 第2部分 解决目标 这段代码实现了&#xff0c;一个基于深度学习的图像检测程序。它使用mmdeploy框架&#xff0c;加载一个预训练的模型【实例分割模型】来检测图像中的物体。 逻辑思路 程序首先加载模型&#xff0c;然后&#…

Java --- JVM编译运行过程

目录 一.Java编译与执行流程&#xff1a; 二.编译过程&#xff1a; 1.编译器&#xff08;javac&#xff09;&#xff1a; 2.字节码文件&#xff08;.class&#xff09;&#xff1a; 三.执行过程&#xff1a; 1.启动JVM&#xff08;Java虚拟机&#xff09;&#xff1a; 2…

【Makefile】编译日志之输出重定向符号 >

用法1 make all >& compilelog.txt make all > compilelog.txt这两个编译命令在功能上有一些细微的区别&#xff0c;主要在于标准输出和标准错误的处理方式。 make all >& compilelog.txt 这个命令会将标准输出&#xff08;stdout&#xff09;和标准错误&a…

使用 `typing_extensions.TypeAlias` 简化类型定义:初学者指南

使用 typing_extensions.TypeAlias 简化类型定义&#xff1a;初学者指南 什么是 TypeAlias&#xff1f;安装 typing_extensions示例代码&#xff1a;如何使用 TypeAlias示例 1&#xff1a;为简单类型定义别名示例 2&#xff1a;为复杂类型定义别名示例 3&#xff1a;结合 Union…

11.关于vim编辑器的简单配置

1. 说明 在linux系统中编辑文件内容的方式有很多种&#xff0c;比如直接在系统中暗中某些IDE&#xff0c;方便快捷&#xff0c;也可以直接在windows系统中编辑好文件后上传到linux系统中&#xff0c;这些方式对于编写内容较多的文件或者整个项目的文件还是非常适合的。不过有时…

qq空间管理小助手教程代码演示

headers {"Authorization": "Bearer YOUR_ACCESS_TOKEN","Content-Type": "application/json" }# 发布说说示例&#xff08; def post_moment(content):url "https://qzone-api.example.com/post_moment"data {"con…

pytest 的简单介绍

官方文档&#xff1a;pytest 文档 1. pytest 概述 pytest 是一个功能强大的 Python 测试框架&#xff0c;旨在简化单元测试和功能测试的编写与执行。它不仅支持简单的单元测试&#xff0c;还能进行更复杂的测试&#xff0c;如数据驱动的测试、并发测试等。pytest 支持自动化发…

【ArcGIS微课1000例】0133:二维建筑物依据高度生成三维模型

拓展阅读:【ArcGIS Pro微课1000例】0032:创建具有指定高程Z值的矢量数据 文章目录 一、二维面要素拉伸实现三维显示二、依据高度实现要素转3D一、二维面要素拉伸实现三维显示 打开ArcScene软件,加载实验配套数据0133.rar中的建筑物.shp数据,如下图: 数据属性表中的Z为建筑…

快速搭建SpringBoot3+Vue3+ElementPlus管理系统

快速搭建SpringBoot3Vue3管理系统 前端项目搭建&#xff08;默认开发环境&#xff1a;node20,Jdk17&#xff09;创建项目并下载依赖--执行以下命令 前端项目搭建&#xff08;默认开发环境&#xff1a;node20,Jdk17&#xff09; 创建项目并下载依赖–执行以下命令 创建项目 y…

力扣--LCR 134.Pow(x,n)

题目 实现 pow(x, n) &#xff0c;即计算 x 的 n 次幂函数&#xff08;即&#xff0c;xn&#xff09;。 示例 1&#xff1a; 输入&#xff1a;x 2.00000, n 10 输出&#xff1a;1024.00000 示例 2&#xff1a; 输入&#xff1a;x 2.10000, n 3 输出&#xff1a;9.2610…

道可云人工智能元宇宙每日资讯|全国工商联人工智能委员会成立会议在南京举办

道可云元宇宙每日简报&#xff08;2024年12月5日&#xff09;讯&#xff0c;今日元宇宙新鲜事有&#xff1a; 全国工商联人工智能委员会成立会议在南京举办 全国工商联人工智能委员会成立会议日前在江苏省南京市举办。中央统战部副部长、全国工商联党组书记沈莹出席会议并讲话…

基于Qt的文字处理软件(二)

这期文章我们进行主窗口的一些函数的定义&#xff0c;同时导入一些文字处理软件的状态栏会用到的图标。下面图片是图标导入到项目后的一个示例&#xff0c;图标可以到阿里矢量图标库里面找到。 一、导入图标资源: 1.首先在项目目录的位置创建一个images的文件,然后将收集好的图…

如何使用WinCC DataMonitor基于Web发布浏览Excel报表文档

本文介绍使用 WinCC DataMonitor 的 "Excel Workbooks" 功能&#xff0c;通过 Excel 表格显示 WinCC 项目的过程值、归档变量值和报警归档消息。并可以通过 Web 发布浏览访问数据 1&#xff0e;WinCC DataMonitor是什么 ? DataMonitor 是 SIMATIC WinCC 工厂智能中…

element plus table组件多选获取数据id

首先给table加上 selection-change"handleSelectionChange"事件 示例 <el-table selection-change"handleSelectionChange" stripe:data"data?.slice((currentPage3 - 1) * pageSize3, currentPage3 * pageSize3)" style"width: 100%…

信号的捕捉

目录 一、内核态与用户态的切换 二、 sigaction 参数介绍​编辑 三、 signal 四、某个信号在正在捕捉期间&#xff0c;该信号不允许再次被递达 五、可重入与不可重入函数&#xff08;描述函数的特性&#xff09; 六、volatile关键字 七、SIGCHLD信号 一、内核态与用户态的…

UTS 2022 致命问题修复:达梦数据库,记录数支持100万条

UTS 数据传输系统升级说明 升级内容&#xff1a; 致命问题修复 达梦数据库作为数据源&#xff1a; 当单个时间戳的记录数超过 10,000 条时&#xff0c;系统读取可能出现问题&#xff0c;已针对该场景优化数据处理逻辑&#xff0c;提升读取性能与稳定性。当单个时间戳值的重复…

华为HCIE-Datacom认证笔试+实验考试介绍

华为HCIE数通认证考试是面向那些希望成为数通网络领域专家的人员&#xff0c;考试通常两部分&#xff1a;笔试和实验考试。 考试科目&#xff1a; HCIE-Datacom笔试考试内容&#xff1a; HCIE-Datacom V1.0考试覆盖数据通信领域路由交换高阶技术、企业网络架构全景、园区网络…

【Linux】NUMA如何梆核

在 NUMA&#xff08;非统一内存访问&#xff09;架构中&#xff0c;“绑核” 通常是指将特定的 CPU 核心&#xff08;或者 NUMA 节点&#xff09;与特定的内存区域绑定&#xff0c;以提高内存访问的局部性&#xff0c;减少跨节点的内存访问延迟。这个操作通常用于性能优化&…