常见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.mzph.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) 写出设计过…