Skip to content

Commit a85f3b3

Browse files
kenafosterkcpeveyviniciusdc
authored
Loki doc updates (#491)
* Update Grafana images and associated text * Add some query tips in Loki doc section * Downsize Grafana screenshots * Separate Loki section from monitoring config * Fix broken link * Add Additional Loki links * add details on how logging with loki works * fix spelling and run yarn linter * Apply suggestions from code review Co-authored-by: Kim Pevey <[email protected]> Co-authored-by: Vinicius D. Cerutti <[email protected]> * fix link * Add permissions note and typo fix --------- Co-authored-by: Kim Pevey <[email protected]> Co-authored-by: Vinicius D. Cerutti <[email protected]>
1 parent 7a27e1f commit a85f3b3

10 files changed

+108
-32
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
title: Access system logs (Loki) via Grafana
3+
description: Access common system logs on Nebari
4+
---
5+
6+
# How to access system logs (Loki) via Grafana
7+
8+
Below is a step-by-step walkthrough of how to view JupyterHub pod logs in Grafana [Loki](https://grafana.com/docs/loki/latest/). As similar approach can be used to find other commonly accessed logs (summarized at the end of this document).
9+
10+
To view the Loki logs via Grafana in Nebari, you'll need to have [set up monitoring](/docs/how-tos/setup-monitoring) on your deployment.
11+
12+
## Getting Started
13+
14+
Access the Monitoring UI for your Nebari installation at https://{your-nebari-domain}/monitoring/.
15+
16+
:::note
17+
The **Explore** functionality shown below is only available to users who have `grafana_admin` permissions. In Nebari's default configuration, only the users in the `admin` Keycloak user group will have this role. `grafana_admin` is a client role in Keycloak which can be assigned to other groups or users. See [Configure Keycloak](/docs/how-tos/configuring-keycloak#in-depth-look-at-roles-and-groups) for more information.
18+
:::
19+
20+
First, click "Explore".
21+
22+
![Grafana Explore Page](/img/how-tos/1_grafana-explore.png)
23+
24+
Select Loki as the data source at the top:
25+
26+
![Grafana Select Loki](/img/how-tos/2_grafana-select-loki.png)
27+
28+
Select a Label to search. For this example, we will select `pod`:
29+
30+
![Grafana Select Loki](/img/how-tos/3_grafana-log-browser-pod.png)
31+
32+
Begin typing the name of the desired pod. In this case we are looking
33+
for a JupyterHub pod. The exact name will vary on each deployment but it will begin with `hub-` followed by a unique identifier.
34+
35+
![Grafana Select Loki](/img/how-tos/4_grafana-log-search-pod.png)
36+
37+
Select the pod from the list of pods and then click on "Run Query":
38+
39+
![Grafana Select Loki](/img/how-tos/5_grafana-log-select-pod.png)
40+
41+
After clicking on "Run Query", you should be able to see logs for JupyterHub pod as shown below:
42+
43+
![Grafana Select Loki](/img/how-tos/6_grafana-view-pod-logs.png)
44+
45+
You can also filter by time by clicking on the time filter on top right (next to "Run query").
46+
47+
## Common Queries
48+
49+
The approach above can be used to access a wide variety of logs on Nebari. Below are some common queries.
50+
51+
### JupyterLab Server Logs
52+
53+
Each user will have their own JupyterLab instance (which may or may not be running at any given time) which will contain its own set of logs. To view the logs for a JupyterLab server, use `pod` label and begin typing the username of interest. The pod name will be `jupyter-{username}`.
54+
55+
### Conda-Store Logs
56+
57+
Conda-store runs multiple pods on the backend. The conda-store server runs continuously while conda-store-workers are only started when an environment is being built. Therefore, worker pods may not always exist. Generally, user requests and access logs will be in the server pod, while logs related to environment builds will be in a worker pod. In the list of conda-store pods shown below, you'll also see pods for `minio`, `postgresql`, and `redis`. These are used internally by conda-store are not likely to have any logs of interest.
58+
59+
- `nebari-conda-store-server-[id]`
60+
- `nebari-conda-store-worker-[id]`
61+
- `nebari-conda-store-minio-[id]`
62+
- `nebari-conda-store-postgresql-postgresql-0`
63+
- `nebari-conda-store-redis-master-0`
64+
65+
### Deployed app logs (via jhub-apps)
66+
67+
If you have `jhub-apps` enabled on your deployment, you can view the logs to debug deployed apps.
68+
69+
To see the logs from **all deployed apps**, use the label filter `container` = `notebook`. The main container in each deployed app pod is named `notebook`.
70+
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+
73+
## Additional Information
74+
75+
- [Understand Log Query Structure](https://grafana.com/docs/loki/latest/query/log_queries/)
76+
- [Use the Query Editor](https://grafana.com/docs/grafana/latest/datasources/loki/query-editor/#choose-a-query-editing-mode)

β€Ždocs/docs/how-tos/monitoring.md renamed to β€Ždocs/docs/how-tos/setup-monitoring.md

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Monitoring
1+
# How to Set Up Monitoring on Nebari
22

33
In Nebari, we've integrated Grafana, Prometheus, and Loki to provide robust monitoring capabilities for
44
your data science platform. This integration allows you to visualize metrics, monitor system health, and
@@ -28,37 +28,9 @@ metrics from configured targets, stores them efficiently, and allows querying th
2828
2929
[Loki](https://grafana.com/docs/loki/latest/) is a horizontally-scalable, highly available, multi-tenant log
3030
aggregation system inspired by Prometheus. It is designed to be very cost-effective and easy to operate, as it
31-
does not index the contents of the logs, but rather a set of labels for each log stream. Below is a step-by-step
32-
walkthrough of how to view JupyterHub pod logs in Grafana Loki:
31+
does not index the contents of the logs, but rather a set of labels for each log stream.
3332
34-
Go to explore section of monitoring of your Nebari installation at:
35-
36-
https://{your-nebari-domain}/monitoring/
37-
38-
![Grafana Explore Page](/img/how-tos/1_grafana-explore.png)
39-
40-
Select Loki Data source at the top:
41-
42-
![Grafana Select Loki](/img/how-tos/2_grafana-select-loki.png)
43-
44-
Click on the Log browser and select labels to search in, in this case we have selected pod:
45-
46-
![Grafana Select Loki](/img/how-tos/3_grafana-log-browser-pod.png)
47-
48-
Type the pod name initials for the pod you're looking to search logs for, in this case we are looking
49-
for hub pod:
50-
51-
![Grafana Select Loki](/img/how-tos/4_grafana-log-search-pod.png)
52-
53-
Select the pod from the list of pods and then click on "Show logs":
54-
55-
![Grafana Select Loki](/img/how-tos/5_grafana-log-select-pod.png)
56-
57-
After clicking on "Show logs", you should be able to see logs for JupyterHub pod as shown below:
58-
59-
![Grafana Select Loki](/img/how-tos/6_grafana-view-pod-logs.png)
60-
61-
You can also filter by time, by clicking on the time filter on top right, next to "Run query".
33+
See [How to access system logs (Loki) via Grafana][access-logs-loki] for more information on using Loki in Nebari.
6234
6335
## Terraform Overrides
6436
@@ -147,3 +119,30 @@ monitoring:
147119
compactor:
148120
retention_enabled: false
149121
```
122+
123+
## Logging architecture
124+
125+
The architecture diagram below shows a simplified, high level explanation of the logging components on Nebari.
126+
127+
![Grafana](/img/how-tos/grafana-loki-promtail-architecture.png)
128+
129+
`Grafana` is the dashboarding user interface which allows us to use `Loki` as the data source for our logs. `Loki` connects to [`promtail`](https://grafana.com/docs/loki/latest/send-data/promtail/) as it's source.
130+
131+
The `promtail` component scrapes logs from various pods on the kubernetes nodes. The `kube api server` provides the API endpoints which `promtail` uses for for discovering and scraping its targeted resources
132+
133+
End users viewing the logs in `Grafana` will create queries using `Loki` as the data source, typically querying based on `labels`. However, it's important to note that Grafana labels differ from Kubernetes labels, as their main goal is to act as an aggregation layer of logs from multiple matching resources into a single "stream," allowing users to easily access a collection of logs from various Kubernetes resources with just a single logical label.
134+
135+
:::note
136+
Loki's "labels" are used to filter collections of logs from the available [kubernetes_sd](https://grafana.com/docs/loki/latest/send-data/promtail/configuration/#kubernetes_sd_config) API endpoints, in a similar way as to how Prometheus handles metrics. These labels are configured through Promtail, which is the agent responsible for collecting and shipping logs to Loki, based on the defined [targets](https://grafana.com/docs/loki/latest/send-data/promtail/configuration/#scrape_configs) and scraping configurations.
137+
:::
138+
139+
For details on how to view specific logs in Loki, check out the document ["How to access system logs (Loki) via Grafana"](access-logs-loki)
140+
141+
## References
142+
143+
[More information on promtail configurations](https://grafana.com/docs/loki/latest/send-data/promtail/configuration/)
144+
[Understanding labels in Loki](https://grafana.com/docs/loki/latest/get-started/labels/#understand-labels)
145+
146+
<!-- Internal links -->
147+
148+
[access-logs-loki]: /how-tos/access-logs-loki.md

β€Ždocs/sidebars.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ module.exports = {
7878
"how-tos/idle-culling",
7979
"how-tos/nebari-extension-system",
8080
"how-tos/telemetry",
81-
"how-tos/monitoring",
81+
"how-tos/setup-monitoring",
82+
"how-tos/access-logs-loki",
8283
"how-tos/use-gpus",
8384
"how-tos/fine-grained-permissions",
8485
],
17.3 KB
Loading
-5.21 KB
Loading
-167 KB
Loading
-105 KB
Loading
-200 KB
Loading
-670 KB
Loading
66.4 KB
Loading

0 commit comments

Comments
Β (0)