Skip to content

feat: add Mimir (External Endpoint) Prometheus provider#1929

Open
ni-mi wants to merge 1 commit into
freelensapp:mainfrom
ni-mi:feat/mimir-prometheus-provider
Open

feat: add Mimir (External Endpoint) Prometheus provider#1929
ni-mi wants to merge 1 commit into
freelensapp:mainfrom
ni-mi:feat/mimir-prometheus-provider

Conversation

@ni-mi

@ni-mi ni-mi commented Jun 7, 2026

Copy link
Copy Markdown

Summary

Adds support for Grafana Mimir as a Prometheus metrics provider. Mimir is a Prometheus-compatible remote metrics backend that typically runs outside the cluster, so it cannot be accessed through the Kubernetes API service proxy like traditional in-cluster Prometheus deployments.

  • New "Mimir (External Endpoint)" provider — queries metrics directly from an external Mimir URL, bypassing the K8s API service proxy
  • Custom HTTP headers — supports X-Scope-OrgID (required by multi-tenant Mimir) and arbitrary key-value headers on every metrics request
  • Dedicated settings UI — endpoint URL field, "Anonymous tenant" checkbox, and a dynamic header editor; hides irrelevant service-address/HTTPS fields

Motivation

Organizations using Mimir as a centralized metrics backend don't have a Prometheus service running inside each cluster. The existing Freelens Prometheus integration mandates a <namespace>/<service>:<port> address that gets proxied through the Kubernetes API. This PR adds a first-class option for reaching Mimir (or any external Prometheus-compatible API) directly.

Changes

File What changed
packages/technical-features/prometheus/src/mimir-provider.injectable.ts New provider using Helm-compatible PromQL queries with a synthetic (empty) service address
packages/technical-features/prometheus/src/register-injectables.ts Register the new provider in DI
packages/core/src/common/cluster-types.ts Add customHeaders field to ClusterPrometheusPreferences
packages/core/src/main/get-metrics.injectable.ts Apply custom headers on directUrl requests; improve error messages with response body
packages/core/src/main/cluster/prometheus-handler/prometheus-handler.ts Clarifying comment for directUrl-only providers
packages/core/src/renderer/components/cluster-settings/prometheus-setting.tsx Mimir UI section (URL, anonymous tenant, additional headers); trim whitespace in path prefix

Test plan

  • Select "Mimir (External Endpoint)" as Prometheus provider in cluster settings
  • Configure endpoint URL and /prometheus custom path prefix
  • Enable "Anonymous tenant" checkbox → verify X-Scope-OrgID: anonymous header is sent
  • Add custom headers → verify they appear in outgoing requests
  • Confirm metrics load successfully on Cluster Overview and Pod detail views
  • Verify existing providers (Helm, Operator, OpenShift, etc.) are unaffected
  • Verify settings persist after closing and reopening cluster settings

@ni-mi

ni-mi commented Jun 7, 2026

Copy link
Copy Markdown
Author

@robertobandini - I am not sure what is the process to get this PR approved or reviewed - I'd appreciate your help with it.
Thanks!

@ni-mi ni-mi force-pushed the feat/mimir-prometheus-provider branch from e552a39 to 9a718b9 Compare June 8, 2026 09:28
Add support for querying metrics from Grafana Mimir, a
Prometheus-compatible remote metrics backend that does not run as an
in-cluster Kubernetes service.

Changes:
- New "Mimir (External Endpoint)" Prometheus provider that uses directUrl
  to bypass the K8s API service proxy
- Support for custom HTTP headers on direct metrics requests, enabling
  X-Scope-OrgID and other Mimir-specific headers
- Dedicated UI section when Mimir is selected: endpoint URL, anonymous
  tenant checkbox, and arbitrary key-value header editor
- Hide irrelevant "service address" and "HTTPS requests" fields for Mimir
- Trim whitespace in custom path prefix to prevent malformed URLs
- Improved error messages for failed direct metrics requests
@ni-mi ni-mi force-pushed the feat/mimir-prometheus-provider branch from 9a718b9 to 2402586 Compare June 8, 2026 09:36
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