You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/how-tos/access-logs-loki.md
+71Lines changed: 71 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,6 +70,77 @@ To see the logs from **all deployed apps**, use the label filter `container` = `
70
70
71
71
To see **logs from a specific app**, use the `pod` label and begin typing either the name of the user running the app or the app name to find the correct pod. App pods are named with the convention `jupyter-[username]--[app_name]-[pod_id]`.
72
72
73
+
## Programmatic Access to Logs
74
+
75
+
Grafana logs can be accessed programmatically from within a Jupyter Notebook or JupyterHub App running in Nebari:
76
+
77
+
- Create a Grafana Service Account and API token by following Grafana docs: https://grafana.com/docs/grafana/latest/administration/service-accounts/
78
+
- Use example code below to retrieve logs from a specific Loki Data Source UID:
79
+
80
+
```python
81
+
import requests
82
+
from datetime import datetime, timedelta
83
+
import requests
84
+
import json
85
+
86
+
NEBARI_BASE_URL="<URL>"# Your Nebari URL e.g. https://nebari.local
87
+
GRAFANA_TOKEN="<Token>"# e.g. "glsa_4QWcA...", See Grafana Documentation
0 commit comments