16.大數據監控

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;工業品電商平臺也承受著轉化率低、運營成本高、客戶滿意度下滑的陣痛。流程冗長、定制化依賴人…

【軟考高級系統架構論文】論模型驅動架構設計方法及其應用

論文真題 模型驅動架構設計是一種用于應用系統開發的軟件設計方法,以模型構造、模型轉換和精化為核心,提供了一套軟件設計的指導規范。在模型驅動架構環境下,通過創建出機器可讀和高度抽象的模型實現對不同問題域的描述,這些模型獨立于實現技術,以標準化的方式儲存,利用…