prometheus 搭建監控

prometheus

下載 prometheus-3.0.0.linux-amd64.tar.gztar -zxvf prometheus-3.0.0.linux-amd64.tar.gzmv  prometheus-3.0.0.linux-amd64  prometheus-3vim  /etc/systemd/system/prometheus.service

prometheus.service

[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target[Service]
User=ubuntu
Group=ubuntu
Type=simple
ExecStart=/home/ubuntu/jiankong/prometheus/prometheus-3/prometheus \--config.file /home/ubuntu/jiankong/prometheus/prometheus-3/prometheus.yml \--storage.tsdb.path /home/ubuntu/jiankong/prometheus/prometheus-3/data \--web.listen-address=0.0.0.0:9090[Install]
WantedBy=multi-user.target

?vim ?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:# - alertmanager:9093# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:# - "first_rules.yml"# - "second_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"]# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.  linux 服務器的監控- job_name: "node_ex"# metrics_path defaults to '/metrics'# scheme defaults to 'http'.static_configs:- targets: ["localhost:9100"]#  mysql  監控    - job_name: "mysql_ex"# metrics_path defaults to '/metrics'# scheme defaults to 'http'.static_configs:- targets: ["localhost:9104"]
啟動停止命令sudo  systemctl status prometheus
sudo  systemctl start prometheus
sudo  systemctl restart prometheus
sudo  systemctl stop prometheus

node_exporter

下載 node_exporter-1.8.2.linux-amd64.tar.gz
tar -zxvf node_exporter-1.8.2.linux-amd64.tar.gzmv node_exporter-1.8.2.linux-amd64  node_exportervim /usr/lib/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
After=network.target 
User=ubuntu
Group=ubuntu[Service]
ExecStart=/home/ubuntu/jiankong/prometheus/node_exporter/node_exporter\--web.listen-address=:9100\--collector.systemd\--collector.systemd.unit-whitelist=(sshd|nginx).service\--collector.processes\--collector.tcpstat
[Install]
WantedBy=multi-user.target
## 監聽端口 9100
##  啟動 停止命令
sudo  systemctl status node_exporter
sudo  systemctl start node_exporter
sudo  systemctl restart node_exporter
sudo  systemctl stop node_exporter

mysqld_exporter

下載  mysqld_exporter-0.16.0.linux-amd64.tar.gzvim  /usr/lib/systemd/system/mysqld_exporter.service
[Unit]
Description=mysqld_exporter
After=network.target 
#User=ubuntu
#Group=ubuntu
[Service]
ExecStart=/home/ubuntu/jiankong/prometheus/mysqld_exporter/mysqld_exporter \
--collect.info_schema.processlist \
--collect.info_schema.innodb_tablespaces \
--collect.info_schema.innodb_metrics \
--collect.perf_schema.tableiowaits \
--collect.perf_schema.indexiowaits \
--collect.perf_schema.tablelocks \
--collect.engine_innodb_status \
--collect.perf_schema.file_events \
--collect.binlog_size \
--collect.info_schema.clientstats \
--collect.perf_schema.eventswaits \
--config.my-cnf=/home/ubuntu/jiankong/prometheus/mysqld_exporter/my.cnf
[Install]
WantedBy=multi-user.target

vim my.cnf

[client]
user=root 
password=123456
默認端口 9104
sudo systemctl status mysqld_exporter
sudo systemctl restart mysqld_exporter
sudo systemctl start mysqld_exporter
sudo systemctl stop mysqld_exporter

grafana

下載 grafana-enterprise-11.3.1.linux-amd64.tar.gz tar -zxvf grafana-enterprise-11.3.1.linux-amd64.tar.gz
mv grafana-enterprise-11.3.1.linux-amd64 grafanavim  /etc/systemd/system/grafana.service
[Unit]
Description=grafana[Service]
ExecStart=/home/ubuntu/jiankong/prometheus/grafana/bin/grafana-server -homepath=/home/ubuntu/jiankong/prometheus/grafana
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
##  vim defaults.ini
##  處理跨域問題 
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana
allowed_origins = *
allow_embedding = true
默認端口 5000
sudo systemctl status grafana
sudo systemctl restart grafana
sudo systemctl start grafana
sudo systemctl stop grafana

nginx ?代理 ? 解決跨域 ?

location /grafana {root   html;index  index.html index.htm;add_header 'Access-Control-Allow-Origin' '*';add_header Access-Control-Allow-Methods GET,POST,OPTIONS,DELETE;add_header 'Access-Control-Allow-Headers' 'userId,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';proxy_pass http://127.0.0.1:5000;rewrite ^/grafana/(.*) /$1 break;proxy_set_header X-Real-IP $remote_addr;proxy_set_header   Host $host;# websocket處理proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/63497.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/63497.shtml
英文地址,請注明出處:http://en.pswp.cn/web/63497.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

游戲何如防抓包

游戲抓包是指在游戲中&#xff0c;通過抓包工具捕獲和分析游戲客戶端與服務器之間傳輸的封包數據的過程。抓包工具可實現攔截、篡改、重發、丟棄游戲的上下行數據包&#xff0c;市面上常見的抓包工具有WPE、Fiddler和Charles Proxy等。 抓包工具有兩種實現方式&#xff0c;一類…

RestTemplate實時接收Chunked編碼傳輸的HTTP Response

學習調用AI接口的時候&#xff0c;流式響應都是使用的 Transfer-Encoding: chunked&#xff0c;圖方便想用RestTemplate&#xff0c;但是平時用到的都是直接返回響應對象的類型。使用bing搜索到一種方式&#xff0c;使用下面的代碼來讀取&#xff0c;于是掉這個坑里了&#xff…

request.setAttribute()和session.setAttribute()的區別

request.setAttribute() 作用&#xff1a;request.setAttribute()是在一次請求內共享數據 解釋&#xff1a;例如將一個數據保存request域中&#xff0c;然后請求轉發至前端頁面&#xff0c;則數據轉發至前端頁面后會被自動銷毀。簡單點說就是&#xff0c;數據只能用一次就不能…

Java中的Consumer接口應該如何使用(通俗易懂圖解)

應用場景&#xff1a; 第一次程序員A寫好了個基礎的遍歷方法&#xff1a; public class Demo1 {public static void main(String[] args) {//假設main方法為程序員B寫的,此時需要去調用A寫好的一個遍歷方法//1.如果此時B突然發現想將字符串以小寫的形式打印出來&#xff0c;則…

【常微分方程講義1.1】方程的種類發展與完備

方程在數學歷史中不斷發展&#xff0c;逐步趨于完備。從最初的簡單代數方程到包含函數、算子甚至泛函的更復雜方程&#xff0c;數學家通過不斷的擴展和深化&#xff0c;逐漸建立起更為豐富和多元的方程類型體系。方程的種類之所以不斷演變&#xff0c;部分是因為解決實際問題的…

通過移除 -march=native 解決 Ubuntu 20.04 程序運行“段錯誤 (核心已轉儲)”問題的詳解

通過移除 -marchnative 解決 Ubuntu 20.04 程序運行“段錯誤 (核心已轉儲)”問題的詳解 在Ubuntu 20.04系統中&#xff0c;開發和編譯C/C程序時&#xff0c;常見的編譯選項可能會影響程序的穩定性和兼容性。特別是在使用CMake構建系統時&#xff0c;某些編譯標志可能導致程序在…

Linux下學【MySQL】表的必備操作( 配實操圖和SQL語句)

緒論? “Patience is key in life &#xff08;耐心是生活的關鍵&#xff09;”。本章是MySQL中非常重要且基礎的知識----對表的操作。再數據庫中表是存儲數據的容器&#xff0c;我們通過將數據填寫在表中&#xff0c;從而再從表中拿取出來使用&#xff0c;本章主要講到表的增…

深度學習之目標檢測篇——殘差網絡與FPN結合

特征金字塔多尺度融合特征金字塔的網絡原理 這里是基于resnet網絡與Fpn做的結合&#xff0c;主要把resnet中的特征層利用FPN的思想一起結合&#xff0c;實現resnet_fpn。增強目標檢測backone的有效性。代碼實現如下&#xff1a; import torch from torch import Tensor from c…

游戲AI實現-尋路算法(BFS)

廣度優先搜索算法&#xff08;英語&#xff1a;Breadth-first search&#xff0c;縮寫&#xff1a;BFS&#xff09;&#xff0c;又譯作寬度優先搜索&#xff0c;或橫向優先搜索&#xff0c;是一種圖形搜索算法。 尋路地圖搭建&#xff1a; 游戲AI實現-尋路地圖搭建-CSDN博客 …

CMake的INSTALL FILES和INSTALL DIRECTORY有什么區別

在 CMake 中&#xff0c;install() 命令用于安裝構建的目標文件、頭文件、庫等到指定的目標路徑。install(FILES ...) 和 install(DIRECTORY ...) 都是 install() 命令的具體用法&#xff0c;它們的功能和適用場景不同。 以下是兩者的詳細區別和用法說明&#xff1a; 1. insta…

主流網絡安全產品

目前市場上也出現了品類豐富的安全產品&#xff0c;如“防火墻、抗D、負載均衡、WAF、數據庫審計、漏掃、網頁防篡改、上網行為管理、堡壘機等”這些產品由于功能不同在網絡中部署的位置也有區別。下面來簡單聊一下每類產品的功能和部署位置。 &#xff08;1&#xff09;防火墻…

利用git上傳項目到GitHub

GitHub是基于git實現的代碼托管。git是目前最好用的版本控制系統了&#xff0c;非常受歡迎&#xff0c;比之svn更好。 GitHub可以免費使用&#xff0c;并且快速穩定。 利用GitHub&#xff0c;你可以將項目存檔&#xff0c;與其他人分享交流&#xff0c;并讓其他開發者幫助你一…

《Vue3實戰教程》13:Vue3偵聽器

如果您有疑問&#xff0c;請觀看視頻教程《Vue3實戰教程》 偵聽器? 基本示例? 計算屬性允許我們聲明性地計算衍生值。然而在有些情況下&#xff0c;我們需要在狀態變化時執行一些“副作用”&#xff1a;例如更改 DOM&#xff0c;或是根據異步操作的結果去修改另一處的狀態。…

uboot 打開log 的 方法

uboot 版本 commit f919c3a889f0ec7d63a48b5d0ed064386b0980bd (HEAD -> v2024.10, tag: v2024.10) Author: Tom Rini <trinikonsulko.com> Date: Mon Oct 7 08:54:35 2024 -0600 Prepare v2024.10 Signed-off-by: Tom Rini <trinikonsulko.com> 開啟的選項…

VSCode 搭建Python編程環境 2024新版圖文安裝教程(Python環境搭建+VSCode安裝+運行測試+背景圖設置)

名人說&#xff1a;一點浩然氣&#xff0c;千里快哉風。—— 蘇軾《水調歌頭》 創作者&#xff1a;Code_流蘇(CSDN) 目錄 一、Python環境安裝二、VScode下載及安裝三、VSCode配置Python環境四、運行測試五、背景圖設置 很高興你打開了這篇博客&#xff0c;更多詳細的安裝教程&…

Unity常用面試問題

GC針對的誰 new對象的時候&#xff0c;產生新對象 GC是發生在什么時候 主動調collect接口以及內存分配不足的時候 如何避免gc 別new對象 GC的過程&#xff0c;為什么耗時 每一次GC會經歷以下過程&#xff0c;堆上的對象越多&#xff0c;對象的引用越多&#xff0c;意味著…

在Linux上將 `.sh` 腳本、`.jar` 包或其他腳本文件添加到開機自啟動

在Linux上將 .sh 腳本、.jar 包或其他腳本文件添加到開機自啟動 在Linux環境中&#xff0c;有時需要將一些程序、腳本或應用程序設置為開機時自動啟動。這對于那些需要在系統啟動時啟動的服務或應用非常有用。本文將介紹如何將 .sh 腳本、.jar 包或其他腳本文件添加到Linux系統…

Git使用步驟

Git 是一個分布式版本控制系統&#xff0c;廣泛用于軟件開發和其他需要跟蹤文件變更的項目。以下是 Git 的基本使用方法和一些常用命令的詳細說明。 安裝 Git 在大多數操作系統上&#xff0c;你可以通過包管理器安裝 Git&#xff1a; Windows: 下載并安裝 Git for Windows。…

詳細指南:在Ubuntu 20.04上安裝和配置Orbbec SDK及USB設備權限

詳細指南&#xff1a;在Ubuntu 20.04上安裝和配置Orbbec SDK及USB設備權限 在Ubuntu 20.04上安裝和配置Orbbec SDK以及進行USB設備的權限配置和調整USBFS緩存大小&#xff0c;涉及到一系列系統配置和環境準備步驟。以下是詳細的步驟說明&#xff0c;以確保準確和高效地設置開發…

【GCC】2015: draft-alvestrand-rmcat-congestion-03 機器翻譯

騰訊云的一個分析,明顯是看了這個論文和草案的 : 最新的是應該是這個 A Google Congestion Control Algorithm for Real-Time Communication draft-ietf-rmcat-gcc-02 下面的這個應該過期了: draft-alvestrand-rmcat-congestion-03