新闻详情

新闻详情

首页 / 资讯中心 / 详情

Metabase 如何接入 Prometheus 导出系统指标?

发布时间:2026/9/11 5:55:14来源:尧图网络
Metabase 如何接入 Prometheus 导出系统指标?
Metabase 如何接入 Prometheus 导出系统指标【免费下载链接】metabaseThe easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:项目地址: https://gitcode.com/GitHub_Trending/me/metabaseMetabase 可以把自身的运行指标以 Prometheus 格式导出启动时通过MB_PROMETHEUS_SERVER_PORT环境变量指定一个端口Metabase 就会在该端口上提供指标端点再把这个端点加入 Prometheus 的抓取配置就能在 Prometheus 中查询和绘制 JVM 线程、内存、Jetty 请求、数据库连接池等指标。本文按官方文档 Observability with Prometheus 走一遍完整接入流程覆盖「以 JAR 方式运行 Metabase 本机部署 Prometheus」这一场景。准备工作接入前需要准备可运行的 Metabase JAR 文件下载入口见官方文档开头部分Prometheus 安装包解压后得到./prometheus可执行文件后续会把配置文件放在这个目录Java 运行环境Metabase 通过java -jar启动一个空闲端口用于导出指标本文沿用文档示例的9191。第一步用 MB_PROMETHEUS_SERVER_PORT 启动 Metabase在 Metabase JAR 所在目录带环境变量启动MB_PROMETHEUS_SERVER_PORT9191 java --add-opens java.base/java.nioALL-UNNAMED -jar metabase.jarMB_PROMETHEUS_SERVER_PORT在环境变量文档中的定义为 integer 类型默认值为null只有设置它之后Prometheus collectors 才会注册并从localhost:port/metrics提供指标。这次接入涉及三个端口注意区分端口用途3000Metabase 应用自身的 Web 端口可用MB_JETTY_PORT改为其他值例如MB_JETTY_PORT30019191MB_PROMETHEUS_SERVER_PORT指定的端口Prometheus 从这里抓取 Metabase 指标9090Prometheus 应用自身的 Web 端口启动后可以确认两件事Metabase 日志中出现指标收集器和指标 Web 服务的启动记录以下为文档给出的日志示例(truncated logs) 2022-09-01 17:47:38,808 INFO metabase.util :: Database setup took 3.4 s 2022-09-01 17:47:38,826 INFO metabase.core :: Setting up prometheus metrics 2022-09-01 17:47:38,827 INFO metabase.prometheus :: Starting prometheus metrics collector 2022-09-01 17:47:38,839 INFO metabase.prometheus :: Starting prometheus metrics web-server on port 9,191 (truncated logs)http://localhost:3000可以打开本地运行的 Metabase。第二步配置 Prometheus 抓取 Metabase在 Prometheus 目录中放入配置文件prometheus.yml内容为官方文档给出的示例global: scrape_interval: 15s # By default, scrape targets every 15 seconds. # Attach these labels to any time series or alerts when communicating with # external systems (federation, remote storage, Alertmanager). external_labels: monitor: codelab-monitor # A scrape configuration containing exactly one endpoint to scrape: # Here its Prometheus itself. scrape_configs: # The job name is added as a label jobjob_name to any timeseries scraped from this config. - job_name: prometheus # Override the global default and scrape targets from this job every 5 seconds. scrape_interval: 5s # use whatever port here that you set for MB_PROMETHEUS_SERVER_PORT static_configs: - targets: [localhost:9191]其中targets里的9191必须与MB_PROMETHEUS_SERVER_PORT一致target需要指向 Metabase 所在的位置。文档示例中 Metabase 与 Prometheus 在同一台主机上因此写localhost如果你的 Metabase 运行在别处需要把它改为 Metabase 实际所在的地址。第三步启动 Prometheus 并验证指标在 Prometheus 目录另开一个终端运行./prometheus --config.fileprometheus.yml然后打开http://localhost:9090应能看到 Prometheus 界面并可以搜索到 Metabase 导出的各项指标。如果想绕过 Prometheus 直接核对指标内容可以访问指标端点http://localhost:9191/metrics端口换成你实际设置的值返回内容为 Prometheus 文本格式。文档给出的一段示例输出如下其中的数值仅为示例不代表固定预期# HELP jvm_threads_current Current thread count of a JVM # TYPE jvm_threads_current gauge jvm_threads_current 81.0 # HELP jvm_threads_daemon Daemon thread count of a JVM # TYPE jvm_threads_daemon gauge jvm_threads_daemon 36.0 # HELP jvm_threads_peak Peak thread count of a JVM # TYPE jvm_threads_peak gauge jvm_threads_peak 81.0 # HELP jvm_threads_started_total Started thread count of a JVM # TYPE jvm_threads_started_total counter jvm_threads_started_total 104.0 # HELP jvm_threads_deadlocked Cycles of JVM-threads that are in deadlock waiting to acquire object monitors or ownable synchronizers # TYPE jvm_threads_deadlocked gauge jvm_threads_deadlocked 0.0Metabase 导出的指标范围官方文档列出的导出指标包括以下几类c3p0_*数据库连接池状态如c3p0_num_busy_connections、c3p0_num_idle_connections、c3p0_max_pool_sizejetty_*Jetty 请求处理统计如jetty_requests_total、jetty_request_time_seconds_total、jetty_responses_totaljvm_*JVM 垃圾回收、内存、内存池与线程指标如jvm_gc_collection_seconds_count、jvm_memory_bytes_used、jvm_threads_stateprocess_*进程级指标如process_cpu_seconds_total、process_open_fds、process_start_time_secondsmetabase_email_messages_total、metabase_email_message_errors_total等邮件发送指标metabase_security_center_last_sync_timestamp_seconds、metabase_security_center_vulnerable_advisories等 Security Center 指标。完整清单见 observability-with-prometheus.md 的 “Exported metrics” 一节。接入时的限制指标服务只有在设置了MB_PROMETHEUS_SERVER_PORT后才存在未设置时默认null不会注册和提供 Prometheus 指标文档给出的抓取示例基于 Prometheus 与 Metabase 同机部署target写localhost。跨机抓取时按文档说明把target改为 Metabase 所在位置即可文档中的日志和指标输出均为示例实际数值随运行状态变化不要按示例值做固定判断。下一步官方文档在 “Further reading” 中指向了 Running Metabase 与 Profiling your Metabase在接入指标后遇到启动或性能问题时可以参考MB_PROMETHEUS_SERVER_PORT的完整定义见 环境变量文档。【免费下载链接】metabaseThe easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:项目地址: https://gitcode.com/GitHub_Trending/me/metabase创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
网站建设高端定制企业官网
RELATED

相关资讯

更多精彩内容,欢迎继续阅读

较早相关资讯

最新相关资讯

V 编译器已知编译缺陷的回归跟踪机制:known_errors/testdata 目录设计与使用指南 2026/9/11 6:37:19

V 编译器已知编译缺陷的回归跟踪机制:known_errors/testdata 目录设计与使用指南

V 编译器已知编译缺陷的回归跟踪机制&#xff1a;known_errors/testdata 目录设计与使用指南 【免费下载链接】v Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automati…

阅读更多 →
G-Helper 轻量控制工具:华硕笔记本卸载 Armoury Crate 后只留一个 exe 2026/9/11 6:37:19

G-Helper 轻量控制工具:华硕笔记本卸载 Armoury Crate 后只留一个 exe

G-Helper 轻量控制工具&#xff1a;华硕笔记本卸载 Armoury Crate 后只留一个 exe 【免费下载链接】g-helper Lightweight Armoury Crate alternative for Asus laptops with nearly the same functionality. Works with ROG Zephyrus, Flow, TUF, Strix, Scar, ProArt, Vivobo…

阅读更多 →
MyBatis-Plus入门指南:提升CRUD效率的实战技巧 2026/9/11 6:37:19

MyBatis-Plus入门指南:提升CRUD效率的实战技巧

1. MyBatis-Plus入门&#xff1a;为什么选择它而不是原生MyBatis我第一次接触MyBatis-Plus是在2018年接手一个电商后台项目时。当时团队正在为要不要引入这个"增强工具"争论不休——有人担心增加学习成本&#xff0c;有人认为会带来维护风险。但实际使用后&#xff0…

阅读更多 →
Rust 任务(Tasks)系统深度解析:基于 Comprehensive Rust 掌握 Tokio 轻量级线程与 async 块并发模型 2026/9/11 6:37:19

Rust 任务(Tasks)系统深度解析:基于 Comprehensive Rust 掌握 Tokio 轻量级线程与 async 块并发模型

Rust 任务&#xff08;Tasks&#xff09;系统深度解析&#xff1a;基于 Comprehensive Rust 掌握 Tokio 轻量级线程与 async 块并发模型 【免费下载链接】comprehensive-rust This is the Rust course used by the Android team at Google. It provides you the material to qu…

阅读更多 →
Homepage 集成 Trilium 笔记服务:基于 ETAPI 的监控 Widget 配置指南 2026/9/11 6:37:19

Homepage 集成 Trilium 笔记服务:基于 ETAPI 的监控 Widget 配置指南

Homepage 集成 Trilium 笔记服务&#xff1a;基于 ETAPI 的监控 Widget 配置指南 【免费下载链接】homepage A highly customizable homepage (or startpage / application dashboard) with Docker and service API integrations. 项目地址: https://gitcode.com/GitHub_Tren…

阅读更多 →
Android数据备份全攻略:一键解决手机文件丢失难题 2026/9/11 6:34:19

Android数据备份全攻略:一键解决手机文件丢失难题

1. Android手机数据备份的必要性与挑战 作为一名经历过多次数据丢失惨案的Android老用户&#xff0c;我深刻体会到定期备份的重要性。上周刚有位同事因为手机进水&#xff0c;所有工作资料和孩子的成长照片瞬间消失——这种痛只有经历过的人才懂。Android系统的开放性带来了丰富…

阅读更多 →

今日资讯

本周资讯

本月资讯

看完文章仍有疑问?

联系尧图顾问,获取一对一建站咨询

立即免费咨询 📞 400-888-8888
📞