Skip to content

feat: configurable Prometheus discovery via plugin settings - #97

Open
repo-trashmaster wants to merge 1 commit into
privilegedescalation:mainfrom
repo-trashmaster:fix/lab-226-configurable-prometheus-discovery
Open

feat: configurable Prometheus discovery via plugin settings#97
repo-trashmaster wants to merge 1 commit into
privilegedescalation:mainfrom
repo-trashmaster:fix/lab-226-configurable-prometheus-discovery

Conversation

@repo-trashmaster

Copy link
Copy Markdown

Summary

Replaces hardcoded Prometheus service discovery with configurable plugin
settings. Users can now specify the Prometheus namespace, service, and port
through Headlamp's settings UI, with backward-compatible fallback to the
original default candidates.

Changes

  • ConfigStore<PrometheusConfig> — uses Headlamp's real ConfigStore<T>
    API to persist user-configured namespace, service, and port
  • registerPluginSettings — registers the settings schema so the
    UI renders a settings panel for the plugin
  • Runtime candidate resolution — a fully configured custom candidate is
    tried first; if it fails, falls back to the original defaults:
    • monitoring/kube-prometheus-stack-prometheus:9090
    • monitoring/prometheus-operated:9090
    • monitoring/prometheus:9090
  • Settings UI — added a settings panel component for configuring the
    Prometheus connection
  • Tests — added metrics and settings tests (136/136 pass)

Backward compatibility

If no settings are configured, discovery behavior is identical to before —
the same three fallback candidates are tried in the same order. Existing
installations require no configuration changes.

Test plan

  • TypeScript compile passes
  • ESLint passes
  • Vitest: 136/136 tests pass
  • Plugin builds and packages successfully
  • Runtime read-only Prometheus API query verified via Kubernetes API proxy
  • Default fallback candidates preserved (no settings = original behavior)

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

Previously, Prometheus service discovery was hardcoded to the monitoring
namespace with three fixed service name candidates. Deployments using a
different namespace or service name (e.g. observability /
monitoring-kube-prometheus-prometheus:9090) could not use the Metrics
page without a fragile selector-less Service shim.

This change introduces configurable Prometheus namespace, service name,
and port via Headlamp idiomatic plugin settings contract:

- New src/api/pluginConfig.ts: ConfigStore-based configuration with
  PrometheusConfig interface, default service candidates, and
  getPrometheusServiceCandidates() helper that prepends user-configured
  service and falls back to built-in defaults
- Modified src/api/metrics.ts: findPrometheusPath() now uses
  getPrometheusServiceCandidates() instead of hardcoded array
- New src/components/SettingsPage.tsx: Plugin settings UI registered
  via registerPluginSettings() with three input fields
- Modified src/index.tsx: registers SettingsPage via
  registerPluginSettings(intel-gpu, SettingsPage, true)
- Modified src/components/MetricsPage.tsx: error message now shows
  dynamically checked services instead of hardcoded list
- New tests: metrics.test.ts (16 tests), SettingsPage.test.tsx (11 tests)
- Updated README.md, SECURITY.md, CLAUDE.md with configuration docs

Backward compatibility: when all three fields are left blank (the
default), the plugin uses the exact same candidate list as v1.1.0.

Lab verification: read-only kubectl proxy query to the lab service at
observability/monitoring-kube-prometheus-prometheus:9090 returns
status=success. All three default candidates return 404.

Tests: 136/136 pass (27 new). tsc, lint, build, package all clean.

Refs: LAB-226
@repo-trashmaster
repo-trashmaster force-pushed the fix/lab-226-configurable-prometheus-discovery branch from a89061a to 0b2b618 Compare August 17, 2026 16:51

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

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