Repository navigation
Commit 4e6ce46
authored
feat(dashboard): add logs and metrics views to the console (#5218)
## What this PR does
Adds logs and resource-consumption views to the console, backed by the
observability proxy from the design proposals [Tenant application
logs](cozystack/community#95) and [Tenant
resource-consumption
metrics](cozystack/community#94).
This PR is useful only together with #5214, which adds the console nginx
route to the proxy. The application tabs need #5219 and the
per-application roots from its follow-up PR. Until those are installed,
each view shows a quiet "not available on this cluster" state instead of
an error, so the order of merging does not break the console.
What is added:
- A "Logs" page at the namespace level, under a new "Observability"
sidebar group, reading the namespace logs root. It lives at
`/console/-/observability/logs`: every one- or two-segment console path
is an application list or detail page, and `-` cannot start an
application plural or name, so the page never shadows an application's
own pages.
- "Logs" and "Metrics" tabs on application pages (every application kind
except VMDisk, which runs no containers), reading the per-application
roots.
- Logs view:
- time range, a LogsQL filter, and pod and container pickers that turn
into a stream filter;
- "Follow" opens a live tail. The status shows "Live" as soon as the
stream is open, even before the first line; on a dropped stream or a
load refusal (`429`) it reconnects from the newest line seen, with
backoff; it stops on `400`/`401`/`403`/`404`;
- the reader can scroll up while lines stream; the newest 1000 lines are
kept;
- while a new range or filter loads, the previous lines stay on screen
with a note saying so, or the view says it is loading; it never reports
"no lines" for a query it has not read yet.
- Metrics view: per-pod CPU and memory charts and application-wide
network charts, refreshed every minute, with ranges from 1 hour to 7
days. The `rate` window is at least 5 minutes and four steps, so queries
routed to the long-term store (coarser deduplication) still return data.
No query names a namespace or kind; the proxy adds the scope.
- Error handling by proxy status: scope-wide answers (`401`/`403`/`404`)
replace the whole view with one notice; limit answers keep the proxy's
own advice. A Kubernetes `Status` body on a proxy path means the request
reached kube-apiserver instead of the proxy and is shown as "not
available".
- Shared UI pieces: an accessible `Select` and a text `Input` matching
the console's controls, and an `EmptyState`.
- `K8sClient.raw()` for untyped requests over the same credential path
as `/apis`; the client now keeps caller headers given in any form.
- Charts use uPlot, loaded in a separate lazy chunk, so the main bundle
does not grow.
#### How it was tested
- `pnpm typecheck`, `pnpm test`, `pnpm lint` and `pnpm build` pass.
- Screenshots of the views were taken against a mock API and on a test
cluster.
- Verified on a test cluster through the full browser chain (OIDC login,
gatekeeper, gateway, console nginx, proxy), as a user with the `view`
role in one tenant: the Logs page works; Follow keeps a single tail open
for more than two minutes without reconnecting; Follow on a quiet filter
shows "Live"; the Metrics tab of a Redis instance draws its charts;
requests from the same session to another tenant's roots answer `403`.
- Not verified: a screen reader (roles and names are asserted in tests
only) and viewports narrower than 1440px.
#### Known limitation
The first lines a newly started pod writes can be missing from an
already open tail, although a history query shows them. This comes from
the log store's live-tail window relative to log collection delay, not
from the console.
### Screenshots
<img width="1440" height="900" alt="cluster-follow-live"
src="https://github.com/user-attachments/assets/6efd9bfb-f05b-4498-bd20-0af4e5cda01f"
/>
<img width="1440" height="900" alt="cluster-logs-empty"
src="https://github.com/user-attachments/assets/673d8295-cd3d-409d-b871-290705d0a6a2"
/>
<img width="1440" height="900" alt="cluster-logs"
src="https://github.com/user-attachments/assets/621c2312-8427-4353-b199-44bdd12b78f7"
/>
<img width="1440" height="900" alt="cluster-pod-select"
src="https://github.com/user-attachments/assets/92ea9c72-4a3c-4562-9c3a-2170730ab085"
/>
<img width="1400" height="1000" alt="cluster-redis-metrics"
src="https://github.com/user-attachments/assets/3533d069-01b9-41de-bba9-70b940d05c6e"
/>
<img width="1440" height="900" alt="follow-waiting"
src="https://github.com/user-attachments/assets/eb318d13-5188-4632-842a-43c0bbbcff5a"
/>
<img width="1440" height="900" alt="logs-empty"
src="https://github.com/user-attachments/assets/c3d89e81-7249-444d-a3fa-9ab44c1ca86e"
/>
<img width="1440" height="900" alt="logs"
src="https://github.com/user-attachments/assets/ec6caa9c-5eda-4361-99ea-359e5d002f04"
/>
<img width="1440" height="900" alt="metrics-empty"
src="https://github.com/user-attachments/assets/db16da15-a618-4dbe-a531-593bc9b916dc"
/>
### Downstream repositories
- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:
Downstream: no trigger matched. Candidate: none affected, because the
whole diff is inside the vendored console
(`packages/system/dashboard/images/console`), which per the trigger map
belongs to this repository and has no downstream copy. A user guide page
for the new console views on the website would be useful but is not
required by the trigger map.
### Release note
```release-note
feat(dashboard): the console gains a namespace Logs page and Logs and Metrics tabs on application pages, with live log following, per-pod CPU and memory charts, and application-wide network charts. The views need the observability proxy; without it they show "not available on this cluster".
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **New Features**
* Added Metrics and Logs tabs to supported application details, plus a
tenant-wide Logs page in the sidebar.
* View CPU, memory, and network charts over selectable time ranges, with
optional sample tables and automatic refresh.
* Search logs using pod and container filters, choose a history range,
and follow live updates with connection status.
* Added distinct loading, empty, and error messages for observability
views, including guidance for unavailable services and query limits.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->45 files changed
Lines changed: 3184 additions & 7 deletions
File tree
- packages/system/dashboard/images/console
- apps/console
- src
- __tests__/k8s-client
- components
- observability
- ui
- lib/observability
- routes
- detail
- packages/k8s-client/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| 84 | + | |
82 | 85 | | |
83 | 86 | | |
84 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
0 commit comments