Skip to content

Commit 916ed28

Browse files
authored
feat: Define Prometheus port in the pod spec (#5213)
* WIP * portSpec * Done * Docs * Fix: env
1 parent 9557d45 commit 916ed28

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

docs/admin/prometheus.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ Coder server exports metrics via the HTTP endpoint, which can be enabled using e
1010

1111
The Prometheus endpoint address is `http://localhost:2112/` by default. You can use either the environment variable `CODER_PROMETHEUS_ADDRESS` or the flag ` --prometheus-address <network-interface>:<port>` to select a different listen address.
1212

13-
__Notice__: Prometheus endpoint is not supported by the official Coder Helm chart yet.
14-
1513
If `coder server --prometheus-enable` is started locally, you can preview the metrics endpoint in your browser or by using curl: <!-- markdown-link-check-disable -->http://localhost:2112/<!-- markdown-link-check-enable -->.
1614

1715
```shell
@@ -22,6 +20,11 @@ coderd_api_active_users_duration_hour 0
2220
...
2321
```
2422

23+
### Kubernetes deployment
24+
25+
The Prometheus endpoint can be enabled in the [Helm chart's](https://github.com/coder/coder/tree/main/helm) `values.yml` by setting the environment variable `CODER_PROMETHEUS_ADDRESS` to `0.0.0.0:2112`.
26+
The environment variable `CODER_PROMETHEUS_ENABLE` will be enabled automatically.
27+
2528
## Available metrics
2629

2730
<!-- Code generated by 'make docs/admin/prometheus.md'. DO NOT EDIT -->

helm/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ coder:
5050
- name: CODER_AUTO_IMPORT_TEMPLATES
5151
value: "kubernetes"
5252

53+
# This env enables the Prometheus metrics endpoint.
54+
- name: CODER_PROMETHEUS_ADDRESS
55+
value: "0.0.0.0:2112"
5356
tls:
5457
secretNames:
5558
- my-tls-secret-name

helm/templates/coder.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,23 @@ spec:
7777
{{- with .Values.coder.env -}}
7878
{{ toYaml . | nindent 12 }}
7979
{{- end }}
80+
{{- range .Values.coder.env }}
81+
{{- if eq .name "CODER_PROMETHEUS_ADDRESS" }}
82+
- name: CODER_PROMETHEUS_ENABLE
83+
value: "true"
84+
{{- end }}
85+
{{- end }}
8086
ports:
8187
- name: {{ include "coder.portName" . | quote }}
8288
containerPort: {{ include "coder.port" . }}
8389
protocol: TCP
90+
{{- range .Values.coder.env }}
91+
{{- if eq .name "CODER_PROMETHEUS_ADDRESS" }}
92+
- name: "prometheus-http"
93+
containerPort: {{ (splitList ":" .value) | last }}
94+
protocol: TCP
95+
{{- end }}
96+
{{- end }}
8497
readinessProbe:
8598
httpGet:
8699
path: /api/v2/buildinfo

helm/values.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ coder:
4949
# - CODER_TLS_ENABLE: set if tls.secretName is not empty.
5050
# - CODER_TLS_CERT_FILE: set if tls.secretName is not empty.
5151
# - CODER_TLS_KEY_FILE: set if tls.secretName is not empty.
52+
# - CODER_PROMETHEUS_ENABLE: set if CODER_PROMETHEUS_ADDRESS is not empty.
5253
env: []
5354

5455
# coder.tls -- The TLS configuration for Coder.

0 commit comments

Comments
 (0)