8000 feat: Define Prometheus port in the pod spec by mtojek · Pull Request #5213 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: Define Prometheus port in the pod spec #5213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/admin/prometheus.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->.

< 8000 /td>
```shell
Expand All @@ -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 -->
Expand Down
3 changes: 3 additions & 0 deletions helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ coder:
- name: CODER_AUTO_IMPORT_TEMPLATES
value: "kubernetes"

# This env enables the Prometheus metrics endpoint.
- name: CODER_PROMETHEUS_ADDRESS
< 8000 /td> value: "0.0.0.0:2112"
tls:
secretNames:
- my-tls-secret-name
Expand Down
13 changes: 13 additions & 0 deletions helm/templates/coder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
0