Skip to content

Commit b7cfab8

Browse files
Emyrkjohnstcn
andauthored
feat: Add docs about workspace metric cardinality (#1177)
* feat: Add docs about workspace metric cardinality Co-authored-by: Cian Johnston <cian@coder.com> Co-authored-by: Cian Johnston <cian@coder.com>
1 parent 17ec494 commit b7cfab8

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

admin/prometheus.md

+57-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,63 @@ spec:
3232
- port: prom-coderd
3333
```
3434
35-
## Metrics
35+
## Workspace Metrics
36+
37+
Each coder workspace has an agent that connects to a single `coderd` instance.
38+
Each coderd instance will include all metrics from the workspaces it manages.
39+
The workspace metrics will all look like this:
40+
41+
```prometheus
42+
coderd_workspace_<workspace_metric_name>{user_id="<user_id>",workspace_id="<workspace_id>"}
43+
```
44+
45+
Due to the nature of workspace ids, this produces a
46+
[high cardinality of metric labels](https://prometheus.io/docs/practices/naming/#labels).
47+
This could be problematic for some configurations. If specific workspace metrics
48+
are not of interest, or are causing issues, you can configure your metric
49+
scraping service to drop these metrics.
50+
51+
Note that if a workspace connects to a new `coderd` (rebuild, network issue,
52+
coder update, etc), the metrics for that workspace will be moved to the new
53+
`coderd` metrics endpoint. The labels on the new metrics will likely have the
54+
new `coderd` pod name. So when tracking a singular workspace, you should track
55+
**only** by `workspace_id` throughout the lifetime of the workspace until it is
56+
deleted.
57+
58+
### Drop workspace metrics config
59+
60+
[Prometheus Documentation](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs)
61+
about relabelling metrics. In this case we will drop all metrics that contain the
62+
`workspace_id` label.
63+
64+
```yaml
65+
metric_relabel_configs:
66+
- source_labels: ["workspace_id"]
67+
action: drop
68+
```
69+
70+
In Prometheus Operator we can pass this config addition to our `coderd`
71+
PodMonitor spec.
72+
73+
```yaml
74+
apiVersion: monitoring.coreos.com/v1
75+
kind: PodMonitor
76+
metadata:
77+
name: master-monitor
78+
namespace: coder
79+
spec:
80+
selector:
81+
matchLabels:
82+
app.kubernetes.io/component: coderd
83+
podMetricsEndpoints:
84+
- port: prom-coderd
85+
relabelings:
86+
- action: drop
87+
sourceLabels:
88+
- workspace_id
89+
```
90+
91+
## Coderd Metrics
3692

3793
Below is a list of the various metrics emitted by Coder's Prometheus endpoint:
3894

0 commit comments

Comments
 (0)