Skip to content

Commit eb6473e

Browse files
Merge pull request #3616 from gardleopard/documentation_of_metrics_pulling
docs(prometheus): Document how to set up scraping in kubernetes
2 parents 1f59292 + 72f3b6a commit eb6473e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/source/administrator/troubleshooting.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,32 @@ managing cost with JupyterHub, see {ref}`cost`.
2424
Each Helm Chart is packaged with a specific version of JupyterHub (and
2525
other software as well). See see the [Helm Chart repository](https://github.com/jupyterhub/helm-chart#release-notes)
2626
for information about the versions of relevant software packages.
27+
28+
## Metrics scraping with prometheus or vmagent
29+
30+
Network policy needs to be modified in order for prometheus or vmagent to be able to reach the metrics endpoint. The recommended way is by setting [interNamespaceAccessLabels=accept](https://z2jh.jupyter.org/en/stable/resources/reference.html#hub-networkpolicy-internamespaceaccesslabels). This makes the hub pod's associated NetworkPolicy accept ingress from pods in other namespaces that have specific access labels.
31+
32+
```yaml
33+
hub:
34+
networkPolicy:
35+
interNamespaceAccessLabels: accept
36+
```
37+
38+
And then set [`prometheus.server.podLabels`](https://github.com/prometheus-community/helm-charts/blob/0c7bf42ac2265d13845ffe0c499d16e6b8cdedea/charts/prometheus/values.yaml#L554) to be `hub.jupyter.org/network-access-hub: "true"` to enable prometheus to reach the hub.
39+
40+
Alternatively you can also set an explicit ingress rule to allow the prometheus or vmagent pod to reach the hub pod to scrape metrics.
41+
42+
```yaml
43+
hub:
44+
networkPolicy:
45+
ingress:
46+
- from:
47+
- namespaceSelector:
48+
matchLabels:
49+
# namespace where your prometheus or vmagent is running
50+
name: <namespace>
51+
- podSelector:
52+
matchLabels:
53+
# a valid selector for the pod that needs to reach jupyterhub
54+
app.kubernetes.io/instance: vmagent
55+
```

0 commit comments

Comments
 (0)