Skip to content

feat: add Prometheus resource trends - #100

Open
WuShang-d wants to merge 2 commits into
casosorg:masterfrom
WuShang-d:feat/monitor-resource-trends
Open

feat: add Prometheus resource trends#100
WuShang-d wants to merge 2 commits into
casosorg:masterfrom
WuShang-d:feat/monitor-resource-trends

Conversation

@WuShang-d

Copy link
Copy Markdown
Contributor

Summary

  • add an optional, configurable Prometheus HTTP API client with instant and range queries, bounded response handling, explicit timeouts, and clear error categories
  • add GET /api/get-monitor-metrics with validated cluster, Node, Pod, and PVC metric queries and centralized PromQL definitions
  • add Monitor Center resource trend charts for CPU, memory, network receive/transmit, Node disk, and PVC storage
  • add 1-hour, 6-hour, 24-hour, 7-day, and custom ranges with manual/automatic refresh
  • keep chart axes fixed to the requested time window, adapt labels to the visible duration, and show exact local timestamps in tooltips
  • document Prometheus configuration, exporter requirements, supported metrics, API usage, and current limitations

Why

The Monitor Center currently exposes Kubernetes state snapshots, health checks, Events, issues, and diagnosis, but it cannot show how resource usage changes over time. This adds historical trends through Prometheus without making CasOS collect or persist metrics itself.

User impact

Users can inspect cluster CPU, memory, and network history together with per-Node disk and per-PVC storage trends over selectable time ranges. Prometheus remains optional: when it is unconfigured, unreachable, or missing a metric family, the existing health, Event, issue, and diagnosis functionality continues to operate and the trend area reports an explicit state.

Validation

  • go test -tags skipCi ./...
  • go build ./...
  • yarn eslint src/MonitorPage.js src/MonitorMetricChart.js src/backend/MonitorBackend.js src/monitorMetrics.js src/monitorMetrics.test.js
  • CI=true yarn craco test --watchAll=false --runTestsByPath src/monitorMetrics.test.js
  • yarn build
  • git diff --check upstream/master...HEAD

Notes

Prometheus must already scrape node_exporter, kubelet/cAdvisor, and kubelet volume metrics. Authentication and custom CA configuration for Prometheus are outside this phase.

@WuShang-d
WuShang-d marked this pull request as ready for review July 17, 2026 02:47
@hsluoyz

hsluoyz commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

@WuShang-d provide a demo video to show your code work as expected, like a web UI client to consume your Prometheus API, also the new web UI of CasOS

@WuShang-d

Copy link
Copy Markdown
Contributor Author

Here is the demo video for PR #100.

It shows:

  • the Prometheus web UI and active scrape targets;
  • the new CasOS Monitor Center UI;
  • CPU, memory, network, node disk, and PVC storage trends;
  • preset and custom time ranges;
  • tooltips, manual refresh, and automatic refresh.

The CasOS frontend consumes the new /api/get-monitor-metrics API to display Prometheus metrics.

casos-pr-100-demo.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants