|
32 | 32 | - port: prom-coderd
|
33 | 33 | ```
|
34 | 34 |
|
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 |
36 | 92 |
|
37 | 93 | Below is a list of the various metrics emitted by Coder's Prometheus endpoint:
|
38 | 94 |
|
|
0 commit comments