feat: Define Prometheus port in the pod spec (#5213)

* WIP

* portSpec

* Done

* Docs

* Fix: env
This commit is contained in:
Marcin Tojek
2022-12-01 15:43:32 +00:00
committed by GitHub
parent 9557d456e8
commit 916ed284ce
4 changed files with 22 additions and 2 deletions
+5 -2
View File
@@ -10,8 +10,6 @@ Coder server exports metrics via the HTTP endpoint, which can be enabled using e
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.
__Notice__: Prometheus endpoint is not supported by the official Coder Helm chart yet.
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 -->.
```shell
@@ -22,6 +20,11 @@ coderd_api_active_users_duration_hour 0
...
```
### Kubernetes deployment
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`.
The environment variable `CODER_PROMETHEUS_ENABLE` will be enabled automatically.
## Available metrics
<!-- Code generated by 'make docs/admin/prometheus.md'. DO NOT EDIT -->
+3
View File
@@ -50,6 +50,9 @@ coder:
- name: CODER_AUTO_IMPORT_TEMPLATES
value: "kubernetes"
# This env enables the Prometheus metrics endpoint.
- name: CODER_PROMETHEUS_ADDRESS
value: "0.0.0.0:2112"
tls:
secretNames:
- my-tls-secret-name
+13
View File
@@ -77,10 +77,23 @@ spec:
{{- with .Values.coder.env -}}
{{ toYaml . | nindent 12 }}
{{- end }}
{{- range .Values.coder.env }}
{{- if eq .name "CODER_PROMETHEUS_ADDRESS" }}
- name: CODER_PROMETHEUS_ENABLE
value: "true"
{{- end }}
{{- end }}
ports:
- name: {{ include "coder.portName" . | quote }}
containerPort: {{ include "coder.port" . }}
protocol: TCP
{{- range .Values.coder.env }}
{{- if eq .name "CODER_PROMETHEUS_ADDRESS" }}
- name: "prometheus-http"
containerPort: {{ (splitList ":" .value) | last }}
protocol: TCP
{{- end }}
{{- end }}
readinessProbe:
httpGet:
path: /api/v2/buildinfo
+1
View File
@@ -49,6 +49,7 @@ coder:
# - CODER_TLS_ENABLE: set if tls.secretName is not empty.
# - CODER_TLS_CERT_FILE: set if tls.secretName is not empty.
# - CODER_TLS_KEY_FILE: set if tls.secretName is not empty.
# - CODER_PROMETHEUS_ENABLE: set if CODER_PROMETHEUS_ADDRESS is not empty.
env: []
# coder.tls -- The TLS configuration for Coder.