From aabed69f2c82421c974d79d47d3d57a10fdd194e Mon Sep 17 00:00:00 2001 From: yufansong Date: Mon, 26 Feb 2024 14:38:49 -0800 Subject: [PATCH] refactor --- dashboard/mock-server.js | 4 ++-- dashboard/mock/fetch.sh | 2 +- dashboard/pages/api/metric.ts | 4 ++-- src/meta/src/dashboard/mod.rs | 11 +++++++---- src/meta/src/dashboard/prometheus.rs | 8 ++++---- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/dashboard/mock-server.js b/dashboard/mock-server.js index 31d67bd87b772..2db52df788e22 100644 --- a/dashboard/mock-server.js +++ b/dashboard/mock-server.js @@ -73,8 +73,8 @@ app.get("/metrics/cluster", (req, res, next) => { res.json(require("./mock/metrics_cluster.json")) }) -app.get("/metrics/actor/back_pressures", (req, res, next) => { - res.json(require("./mock/actor_back_pressures.json")) +app.get("/metrics/fragment/prometheus_back_pressures", (req, res, next) => { + res.json(require("./mock/fragment_prometheus_back_pressures.json")) }) app.get("/monitor/await_tree/1", (req, res, next) => { diff --git a/dashboard/mock/fetch.sh b/dashboard/mock/fetch.sh index 5cc278e01d0c5..ae209fdcf9303 100755 --- a/dashboard/mock/fetch.sh +++ b/dashboard/mock/fetch.sh @@ -17,5 +17,5 @@ curl http://localhost:5691/api/internal_tables > internal_tables.json curl http://localhost:5691/api/sinks > sinks.json curl http://localhost:5691/api/sources > sources.json curl http://localhost:5691/api/metrics/cluster > metrics_cluster.json -curl http://localhost:5691/api/metrics/actor/back_pressures > actor_back_pressures.json +curl http://localhost:5691/api/metrics/fragment/prometheus_back_pressures > fragment_prometheus_back_pressures.json curl http://localhost:5691/api/monitor/await_tree/1 > await_tree_1.json diff --git a/dashboard/pages/api/metric.ts b/dashboard/pages/api/metric.ts index 0eae481624b13..382ce8b25251f 100644 --- a/dashboard/pages/api/metric.ts +++ b/dashboard/pages/api/metric.ts @@ -25,7 +25,7 @@ export interface BackPressuresMetrics { // Get back pressure from meta node -> prometheus export async function getActorBackPressures() { const res: BackPressuresMetrics = await api.get( - "/metrics/actor/back_pressures" + "/metrics/fragment/prometheus_back_pressures" ) return res } @@ -150,7 +150,7 @@ export const BackPressureInfo = { // Get back pressure from meta node -> compute node export async function getBackPressureWithoutPrometheus() { - const response = await api.get("/metrics/back_pressures") + const response = await api.get("/metrics/embedded_back_pressures") let backPressureInfos: BackPressureInfo[] = response.backPressureInfos.map( BackPressureInfo.fromJSON ) diff --git a/src/meta/src/dashboard/mod.rs b/src/meta/src/dashboard/mod.rs index b4ae8e2c04b36..1894845af5186 100644 --- a/src/meta/src/dashboard/mod.rs +++ b/src/meta/src/dashboard/mod.rs @@ -358,7 +358,7 @@ pub(super) mod handlers { Ok(srv.diagnose_command.report().await) } - pub async fn get_back_pressure( + pub async fn get_embedded_back_pressures( Extension(srv): Extension, ) -> Result> { let worker_nodes = srv @@ -416,10 +416,13 @@ impl DashboardService { .route("/sinks", get(list_sinks)) .route("/metrics/cluster", get(prometheus::list_prometheus_cluster)) .route( - "/metrics/actor/back_pressures", - get(prometheus::list_prometheus_actor_back_pressure), + "/metrics/fragment/prometheus_back_pressures", + get(prometheus::list_prometheus_fragment_back_pressure), + ) + .route( + "/metrics/embedded_back_pressures", + get(get_embedded_back_pressures), ) - .route("/metrics/back_pressures", get(get_back_pressure)) .route("/monitor/await_tree/:worker_id", get(dump_await_tree)) .route("/monitor/await_tree/", get(dump_await_tree_all)) .route("/monitor/dump_heap_profile/:worker_id", get(heap_profile)) diff --git a/src/meta/src/dashboard/prometheus.rs b/src/meta/src/dashboard/prometheus.rs index d0e96fa87bfc0..7baade4969749 100644 --- a/src/meta/src/dashboard/prometheus.rs +++ b/src/meta/src/dashboard/prometheus.rs @@ -127,12 +127,12 @@ pub async fn list_prometheus_cluster( #[derive(Serialize, Debug)] #[serde(rename_all = "camelCase")] -pub struct ActorBackPressure { +pub struct FragmentBackPressure { output_buffer_blocking_duration: Vec, } -pub async fn list_prometheus_actor_back_pressure( +pub async fn list_prometheus_fragment_back_pressure( Extension(srv): Extension, -) -> Result> { +) -> Result> { if let Some(ref client) = srv.prometheus_client { let now = SystemTime::now(); let back_pressure_query = @@ -159,7 +159,7 @@ pub async fn list_prometheus_actor_back_pressure( .iter() .map(PrometheusVector::from) .collect(); - Ok(Json(ActorBackPressure { + Ok(Json(FragmentBackPressure { output_buffer_blocking_duration: back_pressure_data, })) } else {