[PR #408] [CLOSED] feat(monitor): add Prometheus exporter as a metrics reporter backend #421

Closed
opened 2026-10-26 09:50:06 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/deepseek-ai/3FS/pull/408
Author: @ChaosD
Created: 4/3/2026
Status: ❌ Closed

Base: main ← Head: feature/prometheus-support


📝 Commits (4)

  • 26b39ee Feat(monitor): expose prometheus metrics
  • 33ee8e7 Delete patches/prometheus-cpp-integration.patch
  • d440efd fix: add prometheus submodules
  • 215c6e6 fix: enable prometheus-cpp submodule

📊 Changes

14 files changed (+251 additions, -13 deletions)

View changed files

📝 .github/workflows/build.yml (+3 -1)
📝 .gitmodules (+3 -0)
📝 CMakeLists.txt (+3 -0)
📝 configs/monitor_collector_main.toml (+3 -0)
📝 patches/apply.sh (+6 -0)
➕ patches/prometheus-cpp.patch (+38 -0)
📝 src/common/CMakeLists.txt (+2 -0)
📝 src/common/monitor/Monitor.cc (+23 -9)
📝 src/common/monitor/Monitor.h (+3 -1)
➕ src/common/monitor/PromExporter.cc (+128 -0)
➕ src/common/monitor/PromExporter.h (+33 -0)
📝 src/monitor_collector/service/MonitorCollectorOperator.cc (+3 -0)
📝 src/monitor_collector/service/MonitorCollectorService.h (+2 -2)
➕ third_party/prometheus-cpp (+1 -0)

📄 Description

feat(monitor): add Prometheus exporter as a metrics reporter backend

Summary:
Integrates prometheus-cpp (via git submodule) as a new metrics reporter backend, enabling 3FS services to expose metrics directly via a Prometheus HTTP endpoint.

Changes:

  • Build system (CMakeLists.txt, src/common/CMakeLists.txt): Add third_party/prometheus-cpp as a subdirectory (with push and testing disabled); link prometheus-cpp::core and prometheus-cpp::pull into both common and hf3fs_common_shared targets.

  • Patch management (patches/apply.sh): Idempotently apply prometheus-cpp.patch following the same pattern used for folly.

  • New reporter (src/common/monitor/PromExporter.h/cc): Implements the Reporter interface. On commit(), maps 3FS Sample types to Prometheus Gauge families — scalar samples as counters, distribution samples as _cnt/_mean/_sum/_min/_max/_p50/_p90/_p95/_p99 gauges. Metric/label names with . are normalized to _ for Prometheus compatibility.

  • Monitor integration (Monitor.h, Monitor.cc): Adds CONFIG_OBJ(prometheus, PromExporter::Config) to ReporterConfig. Because PromExporter binds a TCP port, it is pre-created as a single shared_ptr before the per-collector loop and shared across all collector threads (instead of one instance per collector). Reporter ownership is changed from unique_ptr → shared_ptr to support this sharing.

  • MonitorCollector service (MonitorCollectorOperator.cc, MonitorCollectorService.h): Adds prometheus as a valid reporter type in connThreadFunc. Changes the default reporter from clickhouse → prometheus and reduces conn_threads default from 32 → 1 (required since each PromExporter instance binds a port; only one thread should own it in this path).

  • Config (configs/monitor_collector_main.toml): Adds [server.monitor_collector.reporter.prometheus] section with port = '8080'.

Known limitation:
In MonitorCollectorOperator, if conn_threads is manually set to > 1 with type = "prometheus", each thread creates its own PromExporter and will conflict on the port. This is only guarded by convention (default conn_threads = 1), not enforced in code.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/deepseek-ai/3FS/pull/408 **Author:** [@ChaosD](https://github.com/ChaosD) **Created:** 4/3/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/prometheus-support` --- ### 📝 Commits (4) - [`26b39ee`](https://github.com/deepseek-ai/3FS/commit/26b39eed42bc61186f7d1c7ed5a0256f1e9f25aa) Feat(monitor): expose prometheus metrics - [`33ee8e7`](https://github.com/deepseek-ai/3FS/commit/33ee8e76bb13bd01dfae2c2dfc22f17b69e11865) Delete patches/prometheus-cpp-integration.patch - [`d440efd`](https://github.com/deepseek-ai/3FS/commit/d440efd186a292581953e234eb2217bba3e77e61) fix: add prometheus submodules - [`215c6e6`](https://github.com/deepseek-ai/3FS/commit/215c6e6c362c1af3c915092a477403259b682cc3) fix: enable prometheus-cpp submodule ### 📊 Changes **14 files changed** (+251 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/build.yml` (+3 -1) 📝 `.gitmodules` (+3 -0) 📝 `CMakeLists.txt` (+3 -0) 📝 `configs/monitor_collector_main.toml` (+3 -0) 📝 `patches/apply.sh` (+6 -0) ➕ `patches/prometheus-cpp.patch` (+38 -0) 📝 `src/common/CMakeLists.txt` (+2 -0) 📝 `src/common/monitor/Monitor.cc` (+23 -9) 📝 `src/common/monitor/Monitor.h` (+3 -1) ➕ `src/common/monitor/PromExporter.cc` (+128 -0) ➕ `src/common/monitor/PromExporter.h` (+33 -0) 📝 `src/monitor_collector/service/MonitorCollectorOperator.cc` (+3 -0) 📝 `src/monitor_collector/service/MonitorCollectorService.h` (+2 -2) ➕ `third_party/prometheus-cpp` (+1 -0) </details> ### 📄 Description ## feat(monitor): add Prometheus exporter as a metrics reporter backend **Summary:** Integrates `prometheus-cpp` (via git submodule) as a new metrics reporter backend, enabling 3FS services to expose metrics directly via a Prometheus HTTP endpoint. **Changes:** - **Build system** (`CMakeLists.txt`, `src/common/CMakeLists.txt`): Add `third_party/prometheus-cpp` as a subdirectory (with push and testing disabled); link `prometheus-cpp::core` and `prometheus-cpp::pull` into both `common` and `hf3fs_common_shared` targets. - **Patch management** (`patches/apply.sh`): Idempotently apply `prometheus-cpp.patch` following the same pattern used for `folly`. - **New reporter** (`src/common/monitor/PromExporter.h/cc`): Implements the `Reporter` interface. On `commit()`, maps 3FS `Sample` types to Prometheus `Gauge` families — scalar samples as counters, distribution samples as `_cnt/_mean/_sum/_min/_max/_p50/_p90/_p95/_p99` gauges. Metric/label names with `.` are normalized to `_` for Prometheus compatibility. - **Monitor integration** (`Monitor.h`, `Monitor.cc`): Adds `CONFIG_OBJ(prometheus, PromExporter::Config)` to `ReporterConfig`. Because `PromExporter` binds a TCP port, it is pre-created as a single `shared_ptr` before the per-collector loop and shared across all collector threads (instead of one instance per collector). Reporter ownership is changed from `unique_ptr` → `shared_ptr` to support this sharing. - **MonitorCollector service** (`MonitorCollectorOperator.cc`, `MonitorCollectorService.h`): Adds `prometheus` as a valid reporter type in `connThreadFunc`. Changes the default reporter from `clickhouse` → `prometheus` and reduces `conn_threads` default from `32` → `1` (required since each `PromExporter` instance binds a port; only one thread should own it in this path). - **Config** (`configs/monitor_collector_main.toml`): Adds `[server.monitor_collector.reporter.prometheus]` section with `port = '8080'`. **Known limitation:** In `MonitorCollectorOperator`, if `conn_threads` is manually set to `> 1` with `type = "prometheus"`, each thread creates its own `PromExporter` and will conflict on the port. This is only guarded by convention (default `conn_threads = 1`), not enforced in code. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-26 09:50:07 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/3FS#421
No description provided.