From 42b572252fe9f4dfe159effcaadfb61080c0d500 Mon Sep 17 00:00:00 2001 From: John T Skarbek Date: Thu, 5 Nov 2026 15:50:27 -0500 Subject: [PATCH 1/3] feat: let the collector write to a Prometheus outside the release Add global.telemetry.metrics.remoteWriteURL. When set, Alloy writes there instead of the bundled Prometheus, and the chart renders with prometheus.enabled: false. Default output is unchanged. Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 1 + README.md | 5 +++-- coder-observability/templates/_collector-config.tpl | 4 ++++ coder-observability/values.yaml | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index efcfb9a..480c615 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,3 +40,4 @@ ## v0.0.1 - Initial release +- New `global.telemetry.metrics.remoteWriteURL` points the collector at a Prometheus outside this release. It can then be combined with `prometheus.enabled: false`, which previously failed to render. Empty by default, which keeps writing to the bundled Prometheus. diff --git a/README.md b/README.md index 4c801e5..9097f9e 100644 --- a/README.md +++ b/README.md @@ -371,10 +371,11 @@ values which are defined [here](https://github.com/grafana/helm-charts/tree/main | global.externalZone | string | `"svc.cluster.local"` | | | global.postgres | object | `{"alerts":{"groups":{"Basic":{"delay":"1m","enabled":true},"Connections":{"delay":"5m","enabled":true,"thresholds":{"critical":0.9,"notify":0.5,"warning":0.8}},"Notifications":{"delay":"15m","enabled":true,"thresholds":{"critical":0.9,"notify":0.5,"warning":0.8}}}},"database":"coder","exporter":{"enabled":true,"image":"quay.io/prometheuscommunity/postgres-exporter"},"hostname":"localhost","mountSecret":"secret-postgres","password":null,"port":5432,"sslmode":"disable","sslrootcert":null,"username":"coder","volumeMounts":[],"volumes":[]}` | postgres connection information NOTE: these settings are global so we can parameterise some values which get rendered by subcharts | | global.postgres.alerts | object | `{"groups":{"Basic":{"delay":"1m","enabled":true},"Connections":{"delay":"5m","enabled":true,"thresholds":{"critical":0.9,"notify":0.5,"warning":0.8}},"Notifications":{"delay":"15m","enabled":true,"thresholds":{"critical":0.9,"notify":0.5,"warning":0.8}}}}` | alerts for postgres | -| global.telemetry | object | `{"metrics":{"externalLabels":{},"native_histograms":false,"scrape_interval":"15s","scrape_timeout":"12s"},"profiling":{"scrape_interval":"60s","scrape_timeout":"70s"}}` | control telemetry collection | -| global.telemetry.metrics | object | `{"externalLabels":{},"native_histograms":false,"scrape_interval":"15s","scrape_timeout":"12s"}` | control metric collection | +| global.telemetry | object | `{"metrics":{"externalLabels":{},"native_histograms":false,"remoteWriteURL":"","scrape_interval":"15s","scrape_timeout":"12s"},"profiling":{"scrape_interval":"60s","scrape_timeout":"70s"}}` | control telemetry collection | +| global.telemetry.metrics | object | `{"externalLabels":{},"native_histograms":false,"remoteWriteURL":"","scrape_interval":"15s","scrape_timeout":"12s"}` | control metric collection | | global.telemetry.metrics.externalLabels | object | `{}` | labels added to every series the collector writes, e.g. `cluster: my-cluster` | | global.telemetry.metrics.native_histograms | bool | `false` | enable Prometheus native histograms or default to classic histograms | +| global.telemetry.metrics.remoteWriteURL | string | `""` | Prometheus remote-write endpoint the collector sends to, e.g. `http://prometheus.example.com/api/v1/write`. Empty means the bundled Prometheus. Set it, and `prometheus.enabled: false`, to collect in this cluster but store elsewhere. | | global.telemetry.metrics.scrape_interval | string | `"15s"` | how often the collector will scrape discovered pods | | global.telemetry.metrics.scrape_timeout | string | `"12s"` | how long a request will be allowed to wait before being canceled | | global.telemetry.profiling.scrape_interval | string | `"60s"` | how often the collector will scrape pprof endpoints | diff --git a/coder-observability/templates/_collector-config.tpl b/coder-observability/templates/_collector-config.tpl index b703f45..0840fcc 100644 --- a/coder-observability/templates/_collector-config.tpl +++ b/coder-observability/templates/_collector-config.tpl @@ -436,7 +436,11 @@ prometheus.remote_write "default" { {{ end }} endpoint { send_native_histograms = {{ .Values.global.telemetry.metrics.native_histograms | default false }} +{{- if .Values.global.telemetry.metrics.remoteWriteURL }} + url = {{ .Values.global.telemetry.metrics.remoteWriteURL | quote }} +{{- else }} url ="http://{{ include "prometheus.server.fullname" .Subcharts.prometheus }}.{{ .Release.Namespace }}.{{ .Values.global.zone }}/api/v1/write" +{{- end }} // drop instance label which unnecessarily adds new series when pods are restarted, since pod IPs are dynamically assigned // NOTE: "__address__" is mapped to "instance", so will contain : diff --git a/coder-observability/values.yaml b/coder-observability/values.yaml index 83f7916..00f5813 100644 --- a/coder-observability/values.yaml +++ b/coder-observability/values.yaml @@ -117,6 +117,8 @@ global: native_histograms: false # global.telemetry.metrics.externalLabels -- labels added to every series the collector writes, e.g. `cluster: my-cluster` externalLabels: {} + # global.telemetry.metrics.remoteWriteURL -- Prometheus remote-write endpoint the collector sends to, e.g. `http://prometheus.example.com/api/v1/write`. Empty means the bundled Prometheus. Set it, and `prometheus.enabled: false`, to collect in this cluster but store elsewhere. + remoteWriteURL: "" profiling: # global.telemetry.profiling.scrape_interval -- how often the collector will scrape pprof endpoints scrape_interval: 60s From efcdb68fab3a81ca07c37903b3544e846be7c212 Mon Sep 17 00:00:00 2001 From: John T Skarbek Date: Thu, 5 Nov 2026 22:15:49 -0500 Subject: [PATCH 2/3] fix: trim and require remoteWriteURL, document remote-write caveats, fix CHANGELOG placement Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 2 +- README.md | 2 +- coder-observability/templates/_collector-config.tpl | 7 +++++-- coder-observability/values.yaml | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 480c615..1f1f279 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - New `alloy.kubeletTLS` configures TLS for the cAdvisor and kubelet scrapes. The defaults (`insecure_skip_verify: true`) match the previous behaviour; set `insecure_skip_verify: false` and `ca_file` to verify the kubelet certificate. - Alloy `ClusterRole` is narrowed to `pods`, `nodes` and `nodes/metrics`. It no longer grants read access to `secrets` and `configmaps`. If you add components through `alloy.extraBlocks` that need more access, override `alloy.rbac.rules` and `alloy.rbac.clusterRules`. - `node_uname_info` carries the Kubernetes node name in its `nodename` label instead of the OS hostname, so dashboards that match it against `kube_node_info`'s `node` work when nodes are named by instance ID. +- New `global.telemetry.metrics.remoteWriteURL` points the collector at a Prometheus outside this release. It can then be combined with `prometheus.enabled: false`, which previously failed to render. Empty by default, which keeps writing to the bundled Prometheus. With the bundled Prometheus disabled, the Loki ruler's remote-write URL and Grafana's `metrics` datasource still point at it, so also disable Loki and Grafana (or override those URLs), and note that the release's own alert rules are not evaluated. The receiving Prometheus needs `--web.enable-remote-write-receiver` (and `--enable-feature=native-histograms` if `global.telemetry.metrics.native_histograms` is on), and each writing cluster needs a distinct `global.telemetry.metrics.externalLabels` (for example `cluster`), or series from different clusters collide. Only the URL is configurable: there is no authentication, TLS or header option, so restrict access at the network level. ## v0.3.0 @@ -40,4 +41,3 @@ ## v0.0.1 - Initial release -- New `global.telemetry.metrics.remoteWriteURL` points the collector at a Prometheus outside this release. It can then be combined with `prometheus.enabled: false`, which previously failed to render. Empty by default, which keeps writing to the bundled Prometheus. diff --git a/README.md b/README.md index 9097f9e..e5a9c46 100644 --- a/README.md +++ b/README.md @@ -375,7 +375,7 @@ values which are defined [here](https://github.com/grafana/helm-charts/tree/main | global.telemetry.metrics | object | `{"externalLabels":{},"native_histograms":false,"remoteWriteURL":"","scrape_interval":"15s","scrape_timeout":"12s"}` | control metric collection | | global.telemetry.metrics.externalLabels | object | `{}` | labels added to every series the collector writes, e.g. `cluster: my-cluster` | | global.telemetry.metrics.native_histograms | bool | `false` | enable Prometheus native histograms or default to classic histograms | -| global.telemetry.metrics.remoteWriteURL | string | `""` | Prometheus remote-write endpoint the collector sends to, e.g. `http://prometheus.example.com/api/v1/write`. Empty means the bundled Prometheus. Set it, and `prometheus.enabled: false`, to collect in this cluster but store elsewhere. | +| global.telemetry.metrics.remoteWriteURL | string | `""` | Prometheus remote-write endpoint the collector sends to, e.g. `http://prometheus.example.com/api/v1/write`. Empty means the bundled Prometheus. Set it, and `prometheus.enabled: false`, to collect in this cluster but store elsewhere. Loki's ruler and Grafana's datasource still target the bundled Prometheus, so disable them too. The receiver needs `--web.enable-remote-write-receiver` (and `--enable-feature=native-histograms` if `native_histograms` is on), each cluster needs its own `externalLabels`, and there is no auth or TLS option. | | global.telemetry.metrics.scrape_interval | string | `"15s"` | how often the collector will scrape discovered pods | | global.telemetry.metrics.scrape_timeout | string | `"12s"` | how long a request will be allowed to wait before being canceled | | global.telemetry.profiling.scrape_interval | string | `"60s"` | how often the collector will scrape pprof endpoints | diff --git a/coder-observability/templates/_collector-config.tpl b/coder-observability/templates/_collector-config.tpl index 0840fcc..6d8b528 100644 --- a/coder-observability/templates/_collector-config.tpl +++ b/coder-observability/templates/_collector-config.tpl @@ -436,8 +436,11 @@ prometheus.remote_write "default" { {{ end }} endpoint { send_native_histograms = {{ .Values.global.telemetry.metrics.native_histograms | default false }} -{{- if .Values.global.telemetry.metrics.remoteWriteURL }} - url = {{ .Values.global.telemetry.metrics.remoteWriteURL | quote }} +{{- $remoteWriteURL := .Values.global.telemetry.metrics.remoteWriteURL | default "" | toString | trim }} +{{- if $remoteWriteURL }} + url = {{ $remoteWriteURL | quote }} +{{- else if not .Values.prometheus.enabled }} +{{- fail "global.telemetry.metrics.remoteWriteURL is required when prometheus.enabled is false" }} {{- else }} url ="http://{{ include "prometheus.server.fullname" .Subcharts.prometheus }}.{{ .Release.Namespace }}.{{ .Values.global.zone }}/api/v1/write" {{- end }} diff --git a/coder-observability/values.yaml b/coder-observability/values.yaml index 00f5813..46c0d8c 100644 --- a/coder-observability/values.yaml +++ b/coder-observability/values.yaml @@ -117,7 +117,7 @@ global: native_histograms: false # global.telemetry.metrics.externalLabels -- labels added to every series the collector writes, e.g. `cluster: my-cluster` externalLabels: {} - # global.telemetry.metrics.remoteWriteURL -- Prometheus remote-write endpoint the collector sends to, e.g. `http://prometheus.example.com/api/v1/write`. Empty means the bundled Prometheus. Set it, and `prometheus.enabled: false`, to collect in this cluster but store elsewhere. + # global.telemetry.metrics.remoteWriteURL -- Prometheus remote-write endpoint the collector sends to, e.g. `http://prometheus.example.com/api/v1/write`. Empty means the bundled Prometheus. Set it, and `prometheus.enabled: false`, to collect in this cluster but store elsewhere. Loki's ruler and Grafana's datasource still target the bundled Prometheus, so disable them too. The receiver needs `--web.enable-remote-write-receiver` (and `--enable-feature=native-histograms` if `native_histograms` is on), each cluster needs its own `externalLabels`, and there is no auth or TLS option. remoteWriteURL: "" profiling: # global.telemetry.profiling.scrape_interval -- how often the collector will scrape pprof endpoints From b52a0e90b9a73b913700cd4910cbb3c2fce27d3a Mon Sep 17 00:00:00 2001 From: John T Skarbek Date: Mon, 23 Nov 2026 11:59:17 -0500 Subject: [PATCH 3/3] feat: allow extra remote_write endpoint configuration (auth, TLS, headers) Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 2 +- README.md | 7 ++++--- coder-observability/templates/_collector-config.tpl | 3 +++ coder-observability/values.yaml | 4 +++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2823134..87c40a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ - Alloy `ClusterRole` is narrowed to `pods`, `nodes` and `nodes/metrics`. It no longer grants read access to `secrets` and `configmaps`. If you add components through `alloy.extraBlocks` that need more access, override `alloy.rbac.rules` and `alloy.rbac.clusterRules`. - `node_uname_info` carries the Kubernetes node name in its `nodename` label instead of the OS hostname, so dashboards that match it against `kube_node_info`'s `node` work when nodes are named by instance ID. - BREAKING: `kube-state-metrics` and `prometheus-node-exporter` are now top-level subcharts instead of dependencies of the `prometheus` subchart, so they can run without the Prometheus server. Move any overrides from `prometheus.kube-state-metrics:` and `prometheus.prometheus-node-exporter:` to top-level `kube-state-metrics:` and `prometheus-node-exporter:`. With default values the rendered manifests are unchanged. The chart now fails to render if an old-style override is still set under `prometheus.`, instead of silently ignoring it. `prometheus-node-exporter` is pinned to 4.56.1 and no longer follows the `prometheus` chart's version; bump it by hand. -- New `global.telemetry.metrics.remoteWriteURL` points the collector at a Prometheus outside this release. It can then be combined with `prometheus.enabled: false`, which previously failed to render. Empty by default, which keeps writing to the bundled Prometheus. With the bundled Prometheus disabled, the Loki ruler's remote-write URL and Grafana's `metrics` datasource still point at it, so also disable Loki and Grafana (or override those URLs), and note that the release's own alert rules are not evaluated. The receiving Prometheus needs `--web.enable-remote-write-receiver` (and `--enable-feature=native-histograms` if `global.telemetry.metrics.native_histograms` is on), and each writing cluster needs a distinct `global.telemetry.metrics.externalLabels` (for example `cluster`), or series from different clusters collide. Only the URL is configurable: there is no authentication, TLS or header option, so restrict access at the network level. +- New `global.telemetry.metrics.remoteWriteURL` points the collector at a Prometheus outside this release. It can then be combined with `prometheus.enabled: false`, which previously failed to render. Empty by default, which keeps writing to the bundled Prometheus. With the bundled Prometheus disabled, the Loki ruler's remote-write URL and Grafana's `metrics` datasource still point at it, so also disable Loki and Grafana (or override those URLs), and note that the release's own alert rules are not evaluated. The receiving Prometheus needs `--web.enable-remote-write-receiver` (and `--enable-feature=native-histograms` if `global.telemetry.metrics.native_histograms` is on), and each writing cluster needs a distinct `global.telemetry.metrics.externalLabels` (for example `cluster`), or series from different clusters collide. For authentication, TLS, headers or queue tuning, set `global.telemetry.metrics.remoteWriteExtraConfig` to extra Alloy configuration for the `endpoint` block (read secrets with `sys.env("NAME")`); the chart's own relabelling and `externalLabels` stay in place. ## v0.3.0 diff --git a/README.md b/README.md index 2bc6aee..6fcad01 100644 --- a/README.md +++ b/README.md @@ -373,11 +373,12 @@ values which are defined [here](https://github.com/grafana/helm-charts/tree/main | global.externalZone | string | `"svc.cluster.local"` | | | global.postgres | object | `{"alerts":{"groups":{"Basic":{"delay":"1m","enabled":true},"Connections":{"delay":"5m","enabled":true,"thresholds":{"critical":0.9,"notify":0.5,"warning":0.8}},"Notifications":{"delay":"15m","enabled":true,"thresholds":{"critical":0.9,"notify":0.5,"warning":0.8}}}},"database":"coder","exporter":{"enabled":true,"image":"quay.io/prometheuscommunity/postgres-exporter"},"hostname":"localhost","mountSecret":"secret-postgres","password":null,"port":5432,"sslmode":"disable","sslrootcert":null,"username":"coder","volumeMounts":[],"volumes":[]}` | postgres connection information NOTE: these settings are global so we can parameterise some values which get rendered by subcharts | | global.postgres.alerts | object | `{"groups":{"Basic":{"delay":"1m","enabled":true},"Connections":{"delay":"5m","enabled":true,"thresholds":{"critical":0.9,"notify":0.5,"warning":0.8}},"Notifications":{"delay":"15m","enabled":true,"thresholds":{"critical":0.9,"notify":0.5,"warning":0.8}}}}` | alerts for postgres | -| global.telemetry | object | `{"metrics":{"externalLabels":{},"native_histograms":false,"remoteWriteURL":"","scrape_interval":"15s","scrape_timeout":"12s"},"profiling":{"scrape_interval":"60s","scrape_timeout":"70s"}}` | control telemetry collection | -| global.telemetry.metrics | object | `{"externalLabels":{},"native_histograms":false,"remoteWriteURL":"","scrape_interval":"15s","scrape_timeout":"12s"}` | control metric collection | +| global.telemetry | object | `{"metrics":{"externalLabels":{},"native_histograms":false,"remoteWriteExtraConfig":"","remoteWriteURL":"","scrape_interval":"15s","scrape_timeout":"12s"},"profiling":{"scrape_interval":"60s","scrape_timeout":"70s"}}` | control telemetry collection | +| global.telemetry.metrics | object | `{"externalLabels":{},"native_histograms":false,"remoteWriteExtraConfig":"","remoteWriteURL":"","scrape_interval":"15s","scrape_timeout":"12s"}` | control metric collection | | global.telemetry.metrics.externalLabels | object | `{}` | labels added to every series the collector writes, e.g. `cluster: my-cluster` | | global.telemetry.metrics.native_histograms | bool | `false` | enable Prometheus native histograms or default to classic histograms | -| global.telemetry.metrics.remoteWriteURL | string | `""` | Prometheus remote-write endpoint the collector sends to, e.g. `http://prometheus.example.com/api/v1/write`. Empty means the bundled Prometheus. Set it, and `prometheus.enabled: false`, to collect in this cluster but store elsewhere. Loki's ruler and Grafana's datasource still target the bundled Prometheus, so disable them too. The receiver needs `--web.enable-remote-write-receiver` (and `--enable-feature=native-histograms` if `native_histograms` is on), each cluster needs its own `externalLabels`, and there is no auth or TLS option. | +| global.telemetry.metrics.remoteWriteExtraConfig | string | `""` | extra Alloy configuration placed inside the `endpoint` block of `prometheus.remote_write`, e.g. `basic_auth`, `bearer_token`, `tls_config`, `headers` or `queue_config` (see https://grafana.com/docs/alloy/latest/reference/components/prometheus/prometheus.remote_write/#endpoint-block). Rendered with `tpl`, so it can use Helm values; read secrets with `sys.env("NAME")` (supply the variable via the collector's environment) rather than putting them here. Do not set `url` here, use `remoteWriteURL`. The chart's own `write_relabel_config` rules and `externalLabels` stay in place. | +| global.telemetry.metrics.remoteWriteURL | string | `""` | Prometheus remote-write endpoint the collector sends to, e.g. `http://prometheus.example.com/api/v1/write`. Empty means the bundled Prometheus. Set it, and `prometheus.enabled: false`, to collect in this cluster but store elsewhere. Loki's ruler and Grafana's datasource still target the bundled Prometheus, so disable them too. The receiver needs `--web.enable-remote-write-receiver` (and `--enable-feature=native-histograms` if `native_histograms` is on), and each cluster needs its own `externalLabels`. For authentication, TLS or queue tuning, use `remoteWriteExtraConfig`. | | global.telemetry.metrics.scrape_interval | string | `"15s"` | how often the collector will scrape discovered pods | | global.telemetry.metrics.scrape_timeout | string | `"12s"` | how long a request will be allowed to wait before being canceled | | global.telemetry.profiling.scrape_interval | string | `"60s"` | how often the collector will scrape pprof endpoints | diff --git a/coder-observability/templates/_collector-config.tpl b/coder-observability/templates/_collector-config.tpl index 6d8b528..d5fa127 100644 --- a/coder-observability/templates/_collector-config.tpl +++ b/coder-observability/templates/_collector-config.tpl @@ -443,6 +443,9 @@ prometheus.remote_write "default" { {{- fail "global.telemetry.metrics.remoteWriteURL is required when prometheus.enabled is false" }} {{- else }} url ="http://{{ include "prometheus.server.fullname" .Subcharts.prometheus }}.{{ .Release.Namespace }}.{{ .Values.global.zone }}/api/v1/write" +{{- end }} +{{- with .Values.global.telemetry.metrics.remoteWriteExtraConfig }} +{{ tpl . $ | indent 4 }} {{- end }} // drop instance label which unnecessarily adds new series when pods are restarted, since pod IPs are dynamically assigned diff --git a/coder-observability/values.yaml b/coder-observability/values.yaml index 585fa1e..adf821d 100644 --- a/coder-observability/values.yaml +++ b/coder-observability/values.yaml @@ -117,8 +117,10 @@ global: native_histograms: false # global.telemetry.metrics.externalLabels -- labels added to every series the collector writes, e.g. `cluster: my-cluster` externalLabels: {} - # global.telemetry.metrics.remoteWriteURL -- Prometheus remote-write endpoint the collector sends to, e.g. `http://prometheus.example.com/api/v1/write`. Empty means the bundled Prometheus. Set it, and `prometheus.enabled: false`, to collect in this cluster but store elsewhere. Loki's ruler and Grafana's datasource still target the bundled Prometheus, so disable them too. The receiver needs `--web.enable-remote-write-receiver` (and `--enable-feature=native-histograms` if `native_histograms` is on), each cluster needs its own `externalLabels`, and there is no auth or TLS option. + # global.telemetry.metrics.remoteWriteURL -- Prometheus remote-write endpoint the collector sends to, e.g. `http://prometheus.example.com/api/v1/write`. Empty means the bundled Prometheus. Set it, and `prometheus.enabled: false`, to collect in this cluster but store elsewhere. Loki's ruler and Grafana's datasource still target the bundled Prometheus, so disable them too. The receiver needs `--web.enable-remote-write-receiver` (and `--enable-feature=native-histograms` if `native_histograms` is on), and each cluster needs its own `externalLabels`. For authentication, TLS or queue tuning, use `remoteWriteExtraConfig`. remoteWriteURL: "" + # global.telemetry.metrics.remoteWriteExtraConfig -- extra Alloy configuration placed inside the `endpoint` block of `prometheus.remote_write`, e.g. `basic_auth`, `bearer_token`, `tls_config`, `headers` or `queue_config` (see https://grafana.com/docs/alloy/latest/reference/components/prometheus/prometheus.remote_write/#endpoint-block). Rendered with `tpl`, so it can use Helm values; read secrets with `sys.env("NAME")` (supply the variable via the collector's environment) rather than putting them here. Do not set `url` here, use `remoteWriteURL`. The chart's own `write_relabel_config` rules and `externalLabels` stay in place. + remoteWriteExtraConfig: "" profiling: # global.telemetry.profiling.scrape_interval -- how often the collector will scrape pprof endpoints scrape_interval: 60s