常見Prometheus exporter部署

常見Prometheus exporter部署

  • Prometheus部署
  • Node exporter
  • Process exporter
  • Redis exporter
  • MySQL exporter
  • OracleDB exporter

Prometheus部署

本地部署:

wget https://github.com/prometheus/prometheus/releases/download/v*/prometheus-*.*-amd64.tar.gz
tar xvf prometheus-*.*-amd64.tar.gzcd prometheus-*.*
./prometheus --config.file=./prometheus.yml

容器化部署(通過Bind Mount將宿主機上的prometheus目錄掛載到容器內):

mkdir -vp /opt/prometheus/datadocker run \-p 9090:9090 \-v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \-v /opt/prometheus/data:/prometheus \prom/prometheus

Node exporter

本地部署:

wget https://github.com/prometheus/node_exporter/releases/download/v<VERSION>/node_exporter-<VERSION>.<OS>-<ARCH>.tar.gz
tar xvfz node_exporter-*.*-amd64.tar.gzcd node_exporter-*.*-amd64
./node_exportercurl http://localhost:9100/metrics

容器化部署node exporter時,必須通過Bind Mount把要監控的宿主機目錄掛載到node exporter運行的容器中。Node exporter會使用path.rootfs作為前綴來訪問宿主機文件系統。

docker run -d \--net="host" \--pid="host" \-v "/:/host:ro,rslave" \quay.io/prometheus/node-exporter:latest \--path.rootfs=/host --no-collector.systemd

對應的docker compose文件如下:

---
version: '3.8'services:node_exporter:image: quay.io/prometheus/node-exporter:latestcontainer_name: node_exportercommand:- '--path.rootfs=/host'- '--no-collector.systemd'network_mode: hostpid: hostrestart: unless-stoppedvolumes:- '/:/host:ro,rslave'

prometheus.yml配置:

global:scrape_interval: 15sscrape_configs:
- job_name: nodestatic_configs:- targets: ['<NODE_EXPORTER_IP>:9100']

Process exporter

以監控mysqld進程為例。

本地部署:

wget https://github.com/ncabatoff/process-exporter/releases/download/v0.7.10/process-exporter-0.7.10.linux-amd64.tar.gztar -zxvf process-exporter-0.7.10.linux-amd64.tar.gz -C /usr/local
mv process-exporter-0.7.10.linux-amd64/ process_exportercd /usr/local && ./process-exporter -procnames=mysqld

容器化部署:

#通過config.path指定配置文件
docker run -d --rm -p 9256:9256 --privileged \
-v /proc:/host/proc \
-v `pwd`:/config ncabatoff/process-exporter \
--procfs /host/proc -threads=false \
-config.path /path/to/config/filename.yml#通過procnames指定被監控的進程
docker run -d --rm -p 9256:9256 --privileged \
-v /proc:/host/proc \
-v `pwd`:/config ncabatoff/process-exporter \
--procfs /host/proc -threads=false \
-procnames=mysqld

Process exporter配置文件:

process_names:- name: "{{.Matches}}"cmdline:- 'mysqld'

prometheus.yml配置:

global:scrape_interval: 15sscrape_configs:
- job_name: Processstatic_configs:- targets: ['<PROCESS_EXPORTER_IP>:9256']

Redis exporter

支持版本:Redis 2.x, 3.x, 4.x, 5.x, 6.x, 7.x

編譯:

git clone https://github.com/oliver006/redis_exporter.git
cd redis_exporter
go build .

本地部署:

./redis_exporter --version

容器化部署:

docker run -d --name redis_exporter -p 9121:9121 oliver006/redis_exporter
docker run -d --name redis_exporter --network host oliver006/redis_exporter  #僅主機模式curl -X GET http://localhost:9121/metrics

prometheus.ym配置:

scrape_configs:- job_name: redis_exporterstatic_configs:- targets: ['<REDIS-EXPORTER-HOSTNAME>:9121']

MySQL exporter

支持的版本:MySQL >= 5.6, MariaDB >= 10.3

需要權限:

CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'XXXXXXXX' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';

編譯:

make build

本地部署:

./mysqld_exporter --web.listen-address=:9104 \
--no-collect.info_schema.query_response_time \
--no-collect.info_schema.innodb_cmp \
--no-collect.info_schema.innodb_cmpmem \
--collect.info_schema.processlist --collect.binlog_size

容器化部署:

docker network create my-mysql-network
docker pull prom/mysqld-exporterdocker run -d \-p 9104:9104 \--network my-mysql-network  \prom/mysqld-exporter--config.my-cnf=<path_to_cnf>#僅主機網絡模式部署
docker run -d \--network host \prom/mysqld-exporter--config.my-cnf=<path_to_cnf>

prometheus.ym配置:

scrape_configs:- job_name: mysqld_exporterstatic_configs:- targets: ['<MYSQLD-EXPORTER-HOSTNAME>:9104']        

OracleDB exporter

本地部署(如果本地沒有部署Oracle軟件,需要安裝Oracle Instant Client Basic):

mkdir /etc/oracledb_exporter
chown root:oracledb_exporter /etc/oracledb_exporter  
chmod 775 /etc/oracledb_exporter  
Put config files to **/etc/oracledb_exporter**  
Put binary to **/usr/local/bin**cat > /etc/systemd/system/oracledb_exporter.service << EOF
[Unit]
Description=Service for oracle telemetry client
After=network.target
[Service]
Type=oneshot
#!!! Set your values and uncomment
#User=oracledb_exporter
#Environment="CUSTOM_METRICS=/etc/oracledb_exporter/custom-metrics.toml"
ExecStart=/usr/local/bin/oracledb_exporter  \--default.metrics "/etc/oracledb_exporter/default-metrics.toml"  \--log.level error --web.listen-address 0.0.0.0:9161
[Install]
WantedBy=multi-user.target
EOFsystemctl daemon-reload
systemctl start oracledb_exporter

容器化部署:

docker pull ghcr.io/iamseth/oracledb_exporter:0.5.0docker run -it --rm -p 9161:9161 ghcr.io/iamseth/oracledb_exporter:0.5.0 \
--default.metrics "/etc/oracledb_exporter/default-metrics.toml"  \
--custom.metrics "/etc/oracledb_exporter/custom-metrics.toml"  \
--log.level error

運行oracledb exporter之前需要配置DATA_SOURCE_NAME環境變量:

# export Oracle location:
export DATA_SOURCE_NAME=oracle://system:password@oracle-sid
# or using a complete url:
export DATA_SOURCE_NAME=oracle://user:password@myhost:1521/service# 19c client for primary/standby configuration
export DATA_SOURCE_NAME=oracle://user:password@primaryhost:1521,standbyhost:1521/service
# 19c client for primary/standby configuration with options
export DATA_SOURCE_NAME=oracle://user:password@primaryhost:1521,standbyhost:1521/service?connect_timeout=5&transport_connect_timeout=3&retry_count=3# 19c client for ASM instance connection (requires SYSDBA)
export DATA_SOURCE_NAME=oracle://user:password@primaryhost:1521,standbyhost:1521/+ASM?as=sysdba# Then run the exporter
/path/to/binary/oracledb_exporter --log.level error --web.listen-address 0.0.0.0:9161

OracleDB exporter連接到數據庫的用戶必須對以下數據字典具有查詢權限:

dba_tablespace_usage_metrics
dba_tablespaces
v$system_wait_class
v$asm_diskgroup_stat
v$datafile
v$sysstat
v$process
v$waitclassmetric
v$session
v$resource_limit

通過custom.metrics指定TOML文件可以為oracledb exporter自定義metrics。

[[metric]]
context = "slow_queries"
metricsdesc = { p95_time_usecs= "Gauge metric with percentile 95 of elapsed time.", p99_time_usecs= "Gauge metric with percentile 99 of elapsed time." }
request = "select  percentile_disc(0.95)  within group (order by elapsed_time) as p95_time_usecs, percentile_disc(0.99)  within group (order by elapsed_time) as p99_time_usecs from v$sql where last_active_time >= sysdate - 5/(24*60)"[[metric]]
context = "big_queries"
metricsdesc = { p95_rows= "Gauge metric with percentile 95 of returned rows.", p99_rows= "Gauge metric with percentile 99 of returned rows." }
request = "select  percentile_disc(0.95)  within group (order by rownum) as p95_rows, percentile_disc(0.99)  within group (order by rownum) as p99_rows from v$sql where last_active_time >= sysdate - 5/(24*60)"[[metric]]
context = "size_user_segments_top100"
metricsdesc = {table_bytes="Gauge metric with the size of the tables in user segments."}
labels = ["segment_name"]
request = "select * from (select segment_name,sum(bytes) as table_bytes from user_segments where segment_type='TABLE' group by segment_name) order by table_bytes DESC FETCH NEXT 100 ROWS ONLY"[[metric]]
context = "size_user_segments_top100"
metricsdesc = {table_partition_bytes="Gauge metric with the size of the table partition in user segments."}
labels = ["segment_name"]
request = "select * from (select segment_name,sum(bytes) as table_partition_bytes from user_segments where segment_type='TABLE PARTITION' group by segment_name) order by table_partition_bytes DESC FETCH NEXT 100 ROWS ONLY"[[metric]]
context = "size_user_segments_top100"
metricsdesc = {cluster_bytes="Gauge metric with the size of the cluster in user segments."}
labels = ["segment_name"]
request = "select * from (select segment_name,sum(bytes) as cluster_bytes from user_segments where segment_type='CLUSTER' group by segment_name) order by cluster_bytes DESC FETCH NEXT 100 ROWS ONLY"[[metric]]
context = "size_dba_segments_top100"
metricsdesc = {table_bytes="Gauge metric with the size of the tables in user segments."}
labels = ["segment_name"]
request = "select * from (select segment_name,sum(bytes) as table_bytes from dba_segments where segment_type='TABLE' group by segment_name) order by table_bytes DESC FETCH NEXT 100 ROWS ONLY"[[metric]]
context = "size_dba_segments_top100"
metricsdesc = {table_partition_bytes="Gauge metric with the size of the table partition in user segments."}
labels = ["segment_name"]
request = "select * from (select segment_name,sum(bytes) as table_partition_bytes from dba_segments where segment_type='TABLE PARTITION' group by segment_name) order by table_partition_bytes DESC FETCH NEXT 100 ROWS ONLY"[[metric]]
context = "size_dba_segments_top100"
metricsdesc = {cluster_bytes="Gauge metric with the size of the cluster in user segments."}
labels = ["segment_name"]
request = "select * from (select segment_name,sum(bytes) as cluster_bytes from dba_segments where segment_type='CLUSTER' group by segment_name) order by cluster_bytes DESC FETCH NEXT 100 ROWS ONLY"[[metric]]
context = "cache_hit_ratio"
metricsdesc = {percentage="Gauge metric with the cache hit ratio."}
request = "select Round(((Sum(Decode(a.name, 'consistent gets', a.value, 0)) + Sum(Decode(a.name, 'db block gets', a.value, 0)) - Sum(Decode(a.name, 'physical reads', a.value, 0))  )/ (Sum(Decode(a.name, 'consistent gets', a.value, 0)) + Sum(Decode(a.name, 'db block gets', a.value, 0)))) *100,2) as percentage FROM v$sysstat a"[[metric]]
context = "startup"
metricsdesc = {time_seconds="Database startup time in seconds."}
request = "SELECT (SYSDATE - STARTUP_TIME) * 24 * 60 * 60 AS time_seconds FROM V$INSTANCE"

prometheus.yml配置:

- job_name: oracledb_exporterscrape_interval: 50sscrape_timeout: 50sstatic_configs:- targets: ['<ORACLEDB_EXPORTER_IP>:9161']

References
【1】https://prometheus.io/docs/instrumenting/exporters/
【2】https://prometheus.io/docs/guides/node-exporter/
【3】https://github.com/prometheus/node_exporter
【4】https://github.com/ncabatoff/process-exporter
【5】https://github.com/prometheus/mysqld_exporter
【6】https://github.com/oliver006/redis_exporter
【7】https://github.com/iamseth/oracledb_exporter
【8】https://github.com/iamseth/oracledb_exporter/blob/master/custom-metrics-example/custom-metrics.toml
【9】https://github.com/burningalchemist/sql_exporter

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

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

相關文章

java的jar打包docker鏡像,啟動加載

測試環境&#xff0c;打包鏡像 1,把jar包復制/data/liu/mssda.jar, cd到這個目錄下 2&#xff0c;創建Dockerfile文件&#xff0c;jdk17版本&#xff0c;內容如下 jdk8版本 FROM openjdk:8-jre-alpine WORKDIR /app COPY . /app CMD ["java", "-jar",…

最大奇約數(c++題解)

內存限制&#xff1a; 128 MiB時間限制&#xff1a; 100 ms標準輸入輸出題目類型&#xff1a; 傳統評測方式&#xff1a; 文本比較 題目描述 定義函數f(x)表示x的最大奇約數&#xff0c;這里x表示正整數。例如&#xff0c;f(20) 5&#xff0c;因為20的約數從小到大分別有&am…

奧地利羅馬尼亞媒體宣發稿對跨境出海推廣新聞營銷的意義

【本篇由言同數字科技有限公司原創】在當今全球化的時代&#xff0c;品牌跨境海外推廣已成為企業拓展國際市場的必要途徑。而奧地利和羅馬尼亞是歐洲重要的市場之一&#xff0c;通過在當地媒體上發表文章&#xff0c;可以幫助品牌成功打入這兩個市場&#xff0c;獲得更多的機會…

【YOLO v5 v7 v8 小目標改進】ODConv:在卷積核所有維度(數量、空間、輸入、輸出)上應用注意力機制來優化傳統動態卷積

ODConv&#xff1a;在卷積核所有維度&#xff08;數量、空間、輸入、輸出&#xff09;上應用注意力機制來優化傳統的動態卷積 提出背景傳統動態卷積全維動態卷積效果 小目標漲點YOLO v5 魔改YOLO v7 魔改YOLO v8 魔改 論文&#xff1a;https://openreview.net/pdf?idDmpCfq6Mg…

leedcode刷題--day7(字符串)

23 文章講解 力扣地址 C class Solution { public:void reverseString(vector<char>& s) {int left 0;int right s.size() - 1; // right 應該初始化為 s.size() - 1while (left < right) {swap(s[left], s[right]); // 直接交換 s[left] 和 s[right] 的值lef…

(學習日記)2024.02.29:UCOSIII第二節

寫在前面&#xff1a; 由于時間的不足與學習的碎片化&#xff0c;寫博客變得有些奢侈。 但是對于記錄學習&#xff08;忘了以后能快速復習&#xff09;的渴望一天天變得強烈。 既然如此 不如以天為單位&#xff0c;以時間為順序&#xff0c;僅僅將博客當做一個知識學習的目錄&a…

WSL2外部網絡設置

1 關閉所有WSL系統 wsl --shutdown 2 打開Hyper-V管理器 3 將“虛擬交換機管理器”-> ”WSL連接類型“設置為“外部網絡” 4 啟動WSL系統&#xff0c;手動修改WSL網絡 將WSL網絡IP修改為192.168.1.9 sudo ip addr del $(ip addr show eth0 | grep inet\b | awk {print $2} |…

FFmpeg+OpenCV開發案例匯總

桌面共享工具&#xff08;軟編版&#xff09; 桌面共享工具&#xff08;DXGI硬編版&#xff09; 智能廣告大屏&#xff08;可疊加透明廣告&#xff09; Android手機屏幕RTMP推流工具&#xff08;推麥克風版&#xff09; Android手機屏幕RTMP推流工具&#xff08;推揚聲器版…

FinalMLP:用于推薦系統的簡單但強大的雙流 MLP 模型

原文地址&#xff1a;FinalMLP: A Simple yet Powerful Two-Stream MLP Model for Recommendation Systems 了解 FinalMLP 如何轉變在線推薦&#xff1a;通過尖端 AI 研究解鎖個性化體驗 2024 年 2 月 14 日 介紹 世界正在向數字時代發展&#xff0c;在這個時代&#xff0c;…

Python并發編程:多線程-死鎖現象與遞歸鎖

一  死鎖現象 所謂死鎖&#xff1a;是指兩個或兩個以上的進程或線程在執行過程中&#xff0c;因爭奪資源而造成的一種互相等待的現象&#xff0c;若無外力作用&#xff0c;它們都將無法推進下去。此時稱系統處于死鎖狀態或系統產生了死鎖&#xff0c;這些永遠在互相等待的進程…

持安科技孫維伯:零信任在攻防演練下的最佳實踐|DISCConf 2023

近日&#xff0c;在2023數字身份安全技術大會上&#xff0c;持安科技聯合創始人孫維伯應主辦方的特別邀請&#xff0c;發表了主題為“零信任在攻防演練下的最佳實踐”的演講。 孫維伯在2023數字身份安全技術大會上發表演講 以下為本次演講實錄&#xff1a; 我是持安科技的聯合…

【c++】 STL的組件簡介與容器的使用時機

STL六大組件簡介 STL提供了六大組件&#xff0c;彼此之間可以組合套用&#xff0c;這六大組件分別是:容器、算法、迭代器、仿函數、適配器&#xff08;配接器&#xff09;、空間配置器。 容器&#xff1a;各種數據結構&#xff0c;如vector、list、deque、set、map等,用來存放…

微信云開發-- Mac安裝 wx-server-sdk依賴

第一次上傳部署云函數時&#xff0c;會提示安裝依賴wx-server-sdk 一. 判斷是否安裝wx-server-sdk依賴 先創建一個云函數&#xff0c;然后檢查云函數目錄。 如果云函數目錄下只顯示如下圖所示三個文件&#xff0c;說明未安裝依賴。 如果云函數目錄下顯示如下圖所示四個文件&a…

EdgeX Foundry 邊緣物聯網中間件平臺

文章目錄 1.EdgeX Foundry2.平臺架構3.平臺服務3.1.設備服務3.2.核心服務3.3.支持服務3.4.應用服務3.5.安全服務3.6.管理服務 EdgeX Foundry # EdgeX Foundryhttps://iothub.org.cn/docs/edgex/ https://iothub.org.cn/docs/edgex/edgex-foundry/1.EdgeX Foundry EdgeX Found…

Linux下設置網關以及網絡相關命令

在Linux下設置網關以及進行網絡相關的操作&#xff0c;通常需要使用一系列的命令。以下是一些常用的命令和步驟&#xff1a; 查看網絡接口信息 ifconfig&#xff1a;用于查看網絡接口的狀態和配置信息&#xff08;已淘汰&#xff09;。ip link&#xff1a;顯示本地的鏈路層設…

嵌入式 Linux 下的 LVGL 移植

目錄 準備創建工程修改配置修改 lv_drv_conf.h修改 lv_conf.h修改 main.c修改 Makefile 編譯運行更多內容 LVGL&#xff08;Light and Versatile Graphics Library&#xff09;是一個輕量化的、開源的、在嵌入式系統中廣泛使用的圖形庫&#xff0c;它提供了一套豐富的控件和組件…

ConfigurableBeanFactory學習

簡介 ConfigurableBeanFactory定義BeanFactory的配置。ConfigurableBeanFactory中定義了太多太多的api,比如類加載器,類型轉化,屬性編輯器,BeanPostProcessor,作用域,bean定義,處理bean依賴關系,合并其他ConfigurableBeanFactory,bean如何銷毀。ConfigurableBeanFactory同時繼…

微軟為金融界帶來革命性突破——推出Microsoft 365中的下一代AI助手:Microsoft Copilot for Finance

每周跟蹤AI熱點新聞動向和震撼發展 想要探索生成式人工智能的前沿進展嗎&#xff1f;訂閱我們的簡報&#xff0c;深入解析最新的技術突破、實際應用案例和未來的趨勢。與全球數同行一同&#xff0c;從行業內部的深度分析和實用指南中受益。不要錯過這個機會&#xff0c;成為AI領…

雷龍CS SD NAND(貼片式TF卡)測評體驗

前段時間有幸免費得到了雷龍出品的貼片式的TF卡的芯片及轉接板&#xff0c;兩片貼片式nand芯片&#xff0b;一個轉接板&#xff0c;一種一個已讓官方焊接完好&#xff1b;如下圖所示&#xff1a; 正面&#xff1a; 背面&#xff1a; 通過轉接板&#xff0c;可以將CS SD NAND(貼…

數電實驗之流水燈、序列發生器

最近又用到了數電實驗設計的一些操作和設計思想&#xff0c;遂整理之。 廣告流水燈 實驗內容 用觸發器、組合函數器件和門電路設計一個廣告流水燈&#xff0c;該流水燈由 8 個 LED 組成&#xff0c;工作時始終為 1 暗 7 亮&#xff0c;且這一個暗燈循環右移。 1) 寫出設計過…