Skip to content

prometheus: Add per-view timespan/resolution controls to DiskMetricsChart - #1180

Open
iqraurooj111 wants to merge 20 commits into
headlamp-k8s:mainfrom
iqraurooj111:prometheus-resource-level-timerange
Open

prometheus: Add per-view timespan/resolution controls to DiskMetricsChart#1180
iqraurooj111 wants to merge 20 commits into
headlamp-k8s:mainfrom
iqraurooj111:prometheus-resource-level-timerange

Conversation

@iqraurooj111

Copy link
Copy Markdown

Related to #82

Problem

Issue #82 originally reported that the Prometheus chart time range was
hardcoded, making it too short for debugging purposes. Since that report,
a global "default timespan" setting was added to the plugin's Settings
page, and the GenericMetricsChart component (used for Pod, Deployment,
StatefulSet, DaemonSet, ReplicaSet, Job, and CronJob detail views) was
updated to include a per-view Timespan and Resolution dropdown, so users
can override the global default on each resource's page.

However, DiskMetricsChart (used for PersistentVolumeClaim detail views)
was never updated to match. It still read interval and resolution
directly from the global config store (getPrometheusInterval /
getPrometheusResolution) with no way for the user to change the range
for that specific view — the exact limitation the issue describes, just
on a different resource type.

What this PR changes

  • Adds the same Select dropdowns for Timespan and Resolution
    to DiskMetricsChart that already exist in GenericMetricsChart,
    using identical option values and labels for consistency.
  • Introduces local component state (timespan, resolution) initialized
    from the cluster's global default, so existing behavior is unchanged
    until the user actively picks a different value.
  • Passes the local state down to DiskChart instead of the raw global
    config values, so changing the dropdown immediately updates the
    rendered chart's time range and step size.
  • No changes to query logic, chart rendering, or the global Settings
    page — this is purely adding a per-view override, following the
    existing pattern rather than introducing a new one.

Why this approach

Rather than building a new UI pattern, this reuses the dropdown
component and option list already reviewed and merged for
GenericMetricsChart, so the UX stays consistent across resource types
and there's nothing new for maintainers to review from a design
standpoint — only the wiring into DiskMetricsChart.

Testing

  • Verified locally that opening a PersistentVolumeClaim's detail view
    shows the Timespan/Resolution dropdowns.
  • Confirmed changing the Timespan dropdown updates the disk usage/capacity
    chart's X-axis range and refetches data for the new range.
  • Confirmed the chart still respects the global default on first load
    when no selection has been made.

Scope / follow-up

This PR only covers DiskMetricsChart. Other resource-specific charts
(KedaChart, KarpenterChart, StrimziChart, KnativeChart,
VolcanoChart, CapiChart) still use the global-only interval/resolution
and would benefit from the same treatment. Happy to follow up with
separate PRs for those if maintainers agree with this approach — flagging
here so #82 isn't fully closed until those are addressed too.

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.

1 participant