-
Notifications
You must be signed in to change notification settings - Fork 500
Add /metrics-viz page for browsing Prometheus metrics #34968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a6f44c7
feat: add /metrics-viz page for browsing Prometheus metrics
antiguru 4137498
fix: use internal HTTP port and improve metrics-viz test robustness
antiguru c508be5
refactor: extract shared utilities and address metrics-viz review fee…
antiguru 9286a45
fix: address remaining metrics-viz review feedback
antiguru eaa086a
refactor: add JSDoc types and declarative utilities to metrics-viz
antiguru 9d084cf
ci: add tsc --checkJs type checking for metrics-viz JS files
antiguru 863b9e9
fix: warn when npm is not installed in JS typedef lint check
antiguru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Copyright Materialize, Inc. and contributors. All rights reserved. | ||
| # | ||
| # Use of this software is governed by the Business Source License | ||
| # included in the LICENSE file at the root of this repository. | ||
| # | ||
| # As of the Change Date specified in that file, in accordance with | ||
| # the Business Source License, use of this software will be governed | ||
| # by the Apache License, Version 2.0. | ||
| # | ||
| # check-js-typedefs.sh — type-check JS files with JSDoc annotations. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| cd "$(dirname "$0")/../../../.." | ||
|
|
||
| . misc/shlib/shlib.bash | ||
|
|
||
| if ! command -v npm &>/dev/null; then | ||
| echo "lint: npm is not installed" | ||
| echo "hint: install Node.js from https://nodejs.org/ or via your package manager" | ||
| fi | ||
|
|
||
| try npm install --prefix test/dataflow-visualizer --silent | ||
| try npx --prefix test/dataflow-visualizer tsc -p test/dataflow-visualizer/tsconfig.typecheck.json | ||
|
|
||
| try_status_report | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,6 +90,7 @@ mod cluster; | |
| mod console; | ||
| mod memory; | ||
| mod metrics; | ||
| mod metrics_viz; | ||
| mod probe; | ||
| mod prometheus; | ||
| mod root; | ||
|
|
@@ -210,6 +211,10 @@ impl HttpServer { | |
| "/hierarchical-memory", | ||
| routing::get(memory::handle_hierarchical_memory), | ||
| ) | ||
| .route( | ||
| "/metrics-viz", | ||
| routing::get(metrics_viz::handle_metrics_viz), | ||
| ) | ||
|
Comment on lines
+214
to
+217
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Realizing that these interactive JS pages are going to not work if password authentication is enabled. This was already an issue, but might be worth documenting this somewhere |
||
| .route("/static/{*path}", routing::get(root::handle_static)); | ||
|
|
||
| let mut ws_router = Router::new() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Copyright Materialize, Inc. and contributors. All rights reserved. | ||
| // | ||
| // Use of this software is governed by the Business Source License | ||
| // included in the LICENSE file. | ||
| // | ||
| // As of the Change Date specified in that file, in accordance with | ||
| // the Business Source License, use of this software will be governed | ||
| // by the Apache License, Version 2.0. | ||
|
|
||
| use askama::Template; | ||
| use axum::response::IntoResponse; | ||
|
|
||
| use crate::BUILD_INFO; | ||
|
|
||
| #[derive(Template)] | ||
| #[template(path = "metrics-viz.html")] | ||
| struct MetricsVizTemplate<'a> { | ||
| version: &'a str, | ||
| } | ||
|
|
||
| pub async fn handle_metrics_viz() -> impl IntoResponse { | ||
| mz_http_util::template_response(MetricsVizTemplate { | ||
| version: BUILD_INFO.version, | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright Materialize, Inc. and contributors. All rights reserved. | ||
| // | ||
| // Use of this software is governed by the Business Source License | ||
| // included in the LICENSE file. | ||
| // | ||
| // As of the Change Date specified in that file, in accordance with | ||
| // the Business Source License, use of this software will be governed | ||
| // by the Apache License, Version 2.0. | ||
|
|
||
| 'use strict'; | ||
|
|
||
| /** | ||
| * Execute a SQL query against the /api/sql endpoint. | ||
| * | ||
| * @param {string} sql - SQL query string | ||
| * @returns {Promise<Object>} - The parsed JSON response | ||
| */ | ||
| async function query(sql) { | ||
| const response = await fetch('/api/sql', { | ||
| method: 'POST', | ||
| body: JSON.stringify({ query: sql }), | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| }); | ||
| if (!response.ok) { | ||
| const text = await response.text(); | ||
| throw `request failed: ${response.status} ${response.statusText}: ${text}`; | ||
| } | ||
| const data = await response.json(); | ||
| for (const result of data.results) { | ||
| if (result.error) { | ||
| throw `SQL error: ${result.error.message}`; | ||
| } | ||
| } | ||
| return data; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could check that npm exists and if not print a note for how to install it