0.说明

监控主要构成。
在这里插入图片描述

软件版本。
在这里插入图片描述

1.exporter监控配置

1.1 node_exporter

启动命令

nohup ./node_exporter &

服务
创建文件 /etc/systemd/system/node_exporter.service:

[Unit]
Description=Prometheus Node Exporter
Wants=network-online.target
After=network-online.target[Service]
User=bigdatabit9
Group=bigdatabit9
Type=simple
ExecStart=/opt/apps/node_exporter/node_exporter
Restart=always[Install]
WantedBy=multi-user.target

1.2 kafka_exporter

启动脚本

#!/bin/bash
cd /opt/apps/exporters/kafka_exporter 
nohup ./kafka_exporter --kafka.server=instance-kafka01:9092 --kafka.server=instance-kafka02:9092 --kafka.server=instance-kafka03:9092 \
--zookeeper.server=instance-kafka03:2181,instance-kafka02:2181,instance-kafka01:2181 \
--web.listen-address="172.16.0.243:9340" >/dev/null 2>&1 &

服务
创建文件 /etc/systemd/system/kafka_exporter.service:

[Unit]
Description=Kafka Exporter for Prometheus
Wants=network-online.target
After=network-online.target[Service]
User=bigdatabit9
Group=bigdatabit9
Type=simple
ExecStart=/opt/apps/exporters/kafka_exporter/kafka_exporter \--kafka.server=instance-kafka01:9092 \--kafka.server=instance-kafka02:9092 \--kafka.server=instance-kafka03:9092 \--zookeeper.server=instance-kafka03:2181,instance-kafka02:2181,instance-kafka01:2181 \--web.listen-address=0.0.0.0:9340
Restart=always
RestartSec=5[Install]
WantedBy=multi-user.target

启动exporter

这里以kafka_exporter为例,其他服务一样。

命令

sudo systemctl daemon-reload
sudo systemctl enable kafka_exporter
sudo systemctl start kafka_exporter

检查服务状态

sudo systemctl status kafka_exporter

在这里插入图片描述

2. prometheus 配置

2.1 配置prometheus.yml

# my global config
global:scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.# scrape_timeout is set to the global default (10s).# Alertmanager configuration
alerting:alertmanagers:- static_configs:- targets:- instance-metric01:9093# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:# - "first_rules.yml"# - "second_rules.yml"- "rules/*.yml"# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.- job_name: "prometheus"# metrics_path defaults to '/metrics'# scheme defaults to 'http'.static_configs:- targets: ["localhost:9090"]- job_name: "pushgateway"static_configs:- targets: ["instance-metric01:9091"]- job_name: "kafka"static_configs:- targets: ["1instance-kafka02:9340"]- job_name: "node"static_configs:- targets: ["instance-kafka01:9100","instance-kafka02:9100","instance-kafka03:9100","instance-metric01:9100"]metric_relabel_configs:- action: replacesource_labels: ["instance"]regex: ([^:]+):([0-9]+)replacement: $1target_label: "host_name"

2.2 告警规则rules 配置

在prometheus目录rules目录下。

cpu.yml

groups:
- name: cpu_staterules:- alert: cpu使用率告警expr: (1 - avg(rate(node_cpu_seconds_total{mode="idle"}[2m])) by (host_name)) * 100 > 90for: 30slabels:severity: warningannotations:summary: "{{$labels.host_name}}CPU使用率超过90%"description: " 服务器【{{$labels.host_name}}】:当前CPU使用率{{$value}}%超过90%"

disk.yml

groups:
- name: disk_staterules:- alert: 磁盘使用率告警expr: (node_filesystem_size_bytes{fstype=~"ext.?|xfs"} - node_filesystem_avail_bytes{fstype=~"ext.?|xfs"}) / node_filesystem_size_bytes{fstype=~"ext.?|xfs"} * 100 > 80for: 30slabels:severity: warningannotations:summary: "{{$labels.host_name}}磁盘分区使用率超过80%"description: " 服务器【{{$labels.host_name}}】上的挂载点:【{{ $labels.mountpoint }}】当前值{{$value}}%超过80%"

dispatcher.yml

groups:
- name: dispatcher_staterules:- alert: dispatcher06状态expr: sum(dispatcher06_data) == 0for: 30slabels:severity: criticalannotations:summary: "dispatcher写入数据为0"description: "服务器172.16.0.218上的dispatcher写入数据为0,进程发生问题!"- alert: dispatcher07状态expr: sum(dispatcher07_data) == 0for: 30slabels:severity: criticalannotations:summary: "dispatcher写入数据为0"description: "服务器172.16.0.219上的dispatcher写入数据为0,进程发生问题!"- alert: dispatcherk1状态expr: sum(dispatcherk1_data) == 0for: 30slabels:severity: criticalannotations:summary: "dispatcher写入数据为0"description: "服务器172.16.0.243上的dispatcher写入数据为0,进程发生问题!"- alert: dispatcherk2状态expr: sum(dispatcherk2_data) == 0for: 30slabels:severity: criticalannotations:summary: "dispatcher写入数据为0"description: "服务器172.16.0.244上的dispatcher写入数据为0,进程发生问题!"- alert: dispatcherk3状态expr: sum(dispatcherk3_data) == 0for: 30slabels:severity: criticalannotations:summary: "dispatcher写入数据为0"description: "服务器172.16.0.245上的dispatcher写入数据为0,进程发生问题!"- alert: dispatcherk4状态expr: sum(dispatcherk4_data) == 0for: 30slabels:severity: criticalannotations:summary: "dispatcher写入数据为0"description: "服务器172.16.0.246上的dispatcher写入数据为0,进程发生问题!"- alert: dispatcherk5状态expr: sum(dispatcherk5_data) == 0for: 30slabels:severity: criticalannotations:summary: "dispatcher写入数据为0"description: "服务器172.16.0.247上的dispatcher写入数据为0,进程发生问题!"- alert: dispatcherk6状态expr: sum(dispatcherk6_data) == 0for: 30slabels:severity: criticalannotations:summary: "dispatcher写入数据为0"description: "服务器172.16.0.140上的dispatcher写入数据为0,进程发生问题!"- alert: dispatcherk7状态expr: sum(dispatcherk7_data) == 0for: 30slabels:severity: criticalannotations:summary: "dispatcher写入数据为0"description: "服务器172.16.0.141上的dispatcher写入数据为0,进程发生问题!"- alert: dispatcherk8状态expr: sum(dispatcherk8_data) == 0for: 30slabels:severity: criticalannotations:summary: "dispatcher写入数据为0"description: "服务器172.16.0.142上的dispatcher写入数据为0,进程发生问题!"- alert: dispatcherk9状态expr: sum(dispatcherk9_data) == 0for: 30slabels:severity: criticalannotations:summary: "dispatcher写入数据为0"description: "服务器172.16.0.143上的dispatcher写入数据为0,进程发生问题!"- alert: dispatcherk13状态expr: sum(dispatcherk13_data) == 0for: 30slabels:severity: criticalannotations:summary: "dispatcher写入数据为0"description: "服务器172.16.0.155上的dispatcher写入数据为0,进程发生问题!"

dn.yml

groups:
- name: dn_staterules:- alert: DataNode容量告警expr: (sum(Hadoop_DataNode_DfsUsed{name="FSDatasetState"}) by (host_name) / sum(Hadoop_DataNode_Capacity{name="FSDatasetState"}) by(host_name)) * 100 > 80for: 30slabels:severity: warningannotations:summary: "DataNode节点:{{$labels.host_name}}已使用容量超过80%"description: "DataNode节点:{{$labels.host_name}},当前已使用容量:{{$value}}超过总容量的80%"

kafka_lag.yml

groups:
- name: kafka_lagrules:- alert: kafka消息积压报警expr: sum(kafka_consumergroup_lag{ topic!~"pct_.+"}) by(consumergroup,topic) > 500000 or sum(kafka_consumergroup_lag{topic=~"pct_.+"}) by(consumergroup,topic) > 2000000for: 30slabels:severity: warningannotations:summary: "Topic:{{$labels.topic}}的消费组{{$labels.consumergroup}}消息积压"description: "消息Lag:{{$value}}"

mem.yml

groups:
- name: memory_staterules:- alert: 内存使用率告警expr: (1 - (node_memory_MemAvailable_bytes / (node_memory_MemTotal_bytes)))* 100 > 90for: 30slabels:severity: warningannotations:summary: "{{$labels.host_name}}内存使用率超过90%"description: " 服务器【{{$labels.host_name}}】:当前内存使用率{{$value}}%超过90%"

process.yml

groups:
- name: proc_staterules:- alert: 进程存活告警expr: namedprocess_namegroup_num_procs<1for: 60slabels:severity: criticaltarget: "{{$labels.app_name}}"annotations:summary: "进程{{$labels.app_name}}已停止"description: "进程 {{$labels.app_name}} 在服务器:{{$labels.host_name}}上已经停止."

prometheus_process.yml

groups:
- name: proc_staterules:- alert: prometheus组件进程存活告警expr: sum(up) by(instance,job) == 0for: 30slabels:severity: criticaltarget: "{{$labels.job}}"annotations:summary: "进程{{$labels.job}}已停止"description: "进程 {{$labels.job}} 在服务器:{{$labels.instance}}上已经停止."

yarn.yml

groups:
- name: yarn_noderules:- alert: yarn节点不足expr: sum(Hadoop_ResourceManager_NumActiveNMs{job='rm'}) by (job) < 13 or sum(Hadoop_ResourceManager_NumActiveNMs{job='rmf'}) by (job) < 12for: 30slabels:severity: warningannotations:summary: "yarn集群:{{$labels.job}}节点不足"

2.3 启动

启动命令

nohup /opt/apps/prometheus/prometheus \
--web.listen-address="0.0.0.0:9090" \
--web.read-timeout=5m \
--web.max-connections=10  \
--storage.tsdb.retention=7d  \
--storage.tsdb.path="data/" \
--query.max-concurrency=20   \
--query.timeout=2m \
--web.enable-lifecycle \
> /opt/apps/prometheus/logs/start.log 2>&1 &

2.4 重新加载配置

重新加载配置

curl -X POST http://localhost:9090/-/reload

3. pushgateway

启动命令

nohup /opt/apps/pushgateway/pushgateway \
--web.listen-address="0.0.0.0:9091" \
> /opt/apps/pushgateway/start.log 2>&1 &

4. alertmanager

4.1 配置alertmanager.yml

route:group_by: ['alertname']group_wait: 10sgroup_interval: 1mrepeat_interval: 5mreceiver: 'web.hook'
receivers:
- name: 'web.hook'webhook_configs:- url: 'http://mecury-ca01:9825/api/alarm/send'send_resolved: true
inhibit_rules:- source_match:alertname: 'ApplicationDown'severity: 'critical'target_match:severity: 'warning'equal: ['alertname', 'job', "target", 'instance']

配置报警地址,报警参数参考

{"version": "4","groupKey": "alertname:ApplicationDown","status": "firing","receiver": "web.hook","groupLabels": {"alertname": "ApplicationDown"},"commonLabels": {"alertname": "ApplicationDown","severity": "critical","instance": "10.0.0.1:8080","job": "web","target": "10.0.0.1"},"commonAnnotations": {"summary": "Web application is down","description": "The web application at instance 10.0.0.1:8080 is not responding."},"externalURL": "http://alertmanager:9093","alerts": [{"status": "firing","labels": {"alertname": "ApplicationDown","severity": "critical","instance": "10.0.0.1:8080","job": "web","target": "10.0.0.1"},"annotations": {"summary": "Web application is down","description": "The web application at instance 10.0.0.1:8080 is not responding."},"startsAt": "2025-06-19T04:30:00Z","endsAt": "0001-01-01T00:00:00Z","generatorURL": "http://prometheus:9090/graph?g0.expr=up%7Bjob%3D%22web%22%7D+%3D%3D+0","fingerprint": "1234567890abcdef"}]
}

4.2 启动

启动脚本 start.sh

#!/bin/bashnohup /opt/apps/alertmanager/alertmanager \
--config.file=/opt/apps/alertmanager/alertmanager.yml \
> /opt/apps/alertmanager/start.log 2>&1 &

5.grafana

5.1 安装

启动命令

nohup /opt/apps/grafana/bin/grafana-server web > /opt/apps/grafana/grafana.log 2>&1 &

默认用户名和密码:admin

5.2 常用模板

node 16098
kafka 7589
process 249

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

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

相关文章

Tomcat项目本地部署(Servlet为例)

在Windows上部署 在idea中打开项目 首先我们需要准备一个Servlet项目&#xff0c;我之前的Servlet项目是用eclipse写的&#xff0c;这种情况下如果用idea直接打开的话会出现左侧目录无法显示的情况&#xff0c;这个时候我们就需要用别的方法打开 打开项目管理 如下图&#…

安装MySQL 5.7导入数据,修改密码,创建账号并授权

1. 准备工作 sudo yum update -y sudo yum install -y wget libaio numactl 2. 下载 MySQL 5.7 二进制包 wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz 3. 创建 MySQL 用户和组 sudo groupadd mysql sudo useradd -r -g m…

基础RAG实现,最佳入门选择(八)

RAG重排序 RAG重排序技术以提高RAG系统中的检索质量。重新排序充当初始检索后的第二个过滤步骤&#xff0c;以确保最相关的内容用于响应生成。 重排序的关键概念 1.初始检索&#xff1a;使用基本相似度搜索的第一遍&#xff08;准确度较低但速度更快&#xff09; 2.文档评分…

Spring Boot 常用注解整理

Spring & Spring Boot 常用注解整理 现代的 Spring 与 Spring Boot 应用大量使用注解来简化配置、管理组件和实现各种框架功能。本文系统整理了常用的 Spring/Spring Boot 注解&#xff0c;按照功能分类进行介绍。每个注解都会涵盖其含义、提供来源、应用场景以及代码示例…

深入理解 Cross-Entropy 损失函数:从原理到实践

在深度学习中&#xff0c;损失函数是衡量模型性能的关键指标之一。对于多分类问题&#xff0c;Cross-Entropy 损失函数 是最常用的选择之一。它不仅能够有效衡量模型输出与真实标签之间的差异&#xff0c;还能通过梯度下降法指导模型的优化。本文将深入探讨 Cross-Entropy 损失…

Vim-vimrc保存文件自动移除行末尾空格

Vim-vimrc保存文件自动移除行末尾空格 这段代码通过设置 autocmd 和自定义函数&#xff0c;确保每次保存文件时都自动删除文件中的行尾空格&#xff0c;同时不会影响光标和视图的位置。它适用于所有文件类型&#xff0c;并且删除操作不会引入错误&#xff0c;即使没有行尾空格的…

Occt几何内核快速入门

本文简单介绍 Open Cascade Technology&#xff08;OCCT&#xff09;&#xff0c;提供了下载地址和文档地址。通过OCCT的测试工具Draw&#xff0c;展示了OCCT的一些功能特性。介绍了OCCT集成开发的演示代码&#xff0c;提供了源代码下载地址和编译过程文件。 一、简介 Open C…

【Docker 08】Compose - 容器编排

&#x1f308; 一、Docker Compose 介绍 ⭐ 1. Docker Compose 是什么 Docker Compose 是由 Docker 官方提供的一个用于定义和运行多容器应用的工具&#xff0c;它让用户可以通过一个 YAML 文件&#xff08;通常是 docker-compose.yml&#xff09;来配置应用所需要的服务&…

CentOS Stream 9平台部署安装MySQL8.4.1

1、在线下载安装包 [rootlocalhost ~]# wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.4.1-1.el9.x86_64.rpm-bundle.tar 2、新建解压文件夹 [rootlocalhost ~]#mkdir /root/sql 3、离线解压安装包安装配置MySQL8 上传安装包到home下 [rootlocalhost ~]#c…

phpstorm无缝切换vscode

要将 PhpStorm 的开发体验无缝迁移到 VS Code&#xff0c;需重点配置插件、快捷键和操作习惯。以下是详细方案&#xff1a; 一、必备插件清单 安装以下插件&#xff08;VS Code 搜索安装&#xff09;&#xff1a; PHP Intelephense&#xff1a;核心插件&#xff08;代码补全、…

雨声_锦程_时年

1 炎凉 飘零于三界。 子铭师傅看了几卷笔记&#xff0c;以为我文笔很好&#xff0c;于是我留在石铭公社。 我每日在公社会议厅&#xff0c;高地吹风&#xff0c;悠然笔记。 我喜欢四处旅行。 穿着鞘翅飞翔&#xff0c;风划过耳边。 我渴求所饮的每一滴水&#xff0c;追忆木履留…

微信小程序使用rsa 加解密

jsencrypt.min.js !function(t,e){"object"typeof exports&&"undefined"!typeof module?e(exports):"function"typeof define&&define.amd?define(["exports"],e):e(t.JSEncrypt{})}(this,function(t){"use s…

2025北邮软件工程复习

文章目录 废话知识点总结Part1 软件工程概述Part2 软件需求分析需求介绍需求描述方法 Part3 软件设计方法软件设计的概念与原则软件设计的方法 Part4 程序实现方法Part5 软件测试方法白盒测试黑盒测试 练习题北邮2021~2022期末考北邮2018期末考 考后总结 废话 update on 4.24&…

《Whisper模型版本及下载链接》

Whisper模型版本及下载链接 Whisper是OpenAI开发的语音识别模型&#xff0c;以下按模型规模从小到大排列&#xff0c;包含不同语言版本及通用版本&#xff1a; 1. Tiny系列&#xff08;轻量级&#xff09; tiny.en.pt&#xff08;英文专用&#xff09;&#xff1a; https://…

AWS-SAA 第二部份:安全性和权限管理

我们来深入讲解第二部分&#xff1a;安全性和权限管理&#xff0c;依然用通俗易懂的语言解释。 核心服务 1&#xff1a;IAM&#xff08;Identity and Access Management&#xff09; 1. IAM 的核心概念 作用&#xff1a; IAM 是 AWS 的“门卫系统”&#xff0c;用来管理谁可以…

Linux 多种方式实现行转列

目录 一. 前提二. xargs 实现行转列三. paste 实现行转列四. sed 实现行转列 一. 前提 ⏹之前在这下面篇文章中使用sed命令实现了行专列&#xff0c;本篇文章再介绍几种更加简单的方式。 Linux sed案例 &#x1f449; 20231126-2.log 110120 SPLREQUEST 内容1 AAA memberID1…

Hadoop HDFS存储机制与块大小选择权衡

一、HDFS块存储机制核心原理 1.1 逻辑块 vs 物理存储 HDFS中的 块大小(block size) 是一个逻辑概念&#xff0c;而非物理预分配&#xff1a; #mermaid-svg-GzNjegjSgYrnlcme {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mer…

Unity Addressable使用之AddressableAssetSettings

AddressableAssetSettings 是 Unity Addressable Assets System 的核心配置文件 配置 Manage Groups 用来打开Addressables Groups窗口 Profiles配置 Profile In Use&#xff1a;可以在这选择使用的是哪一套配置文件Manage Profiles&#xff1a;点击它会打开Addressables Gr…

从“询”到“单”的智能跃迁:工业品电商复杂交易流程引擎的架构之道

当传统企业客户在“询盘-报价-议价-审批-合同-下单-履约”的复杂迷宫中艰难穿行&#xff0c;反复沟通、层层审批、定制条款、手工录入……每一步都暗藏延迟与差错的风险&#xff0c;工业品电商平台也承受着转化率低、运营成本高、客户满意度下滑的阵痛。流程冗长、定制化依赖人…

【软考高级系统架构论文】论模型驱动架构设计方法及其应用

论文真题 模型驱动架构设计是一种用于应用系统开发的软件设计方法,以模型构造、模型转换和精化为核心,提供了一套软件设计的指导规范。在模型驱动架构环境下,通过创建出机器可读和高度抽象的模型实现对不同问题域的描述,这些模型独立于实现技术,以标准化的方式储存,利用…