diff --git a/quickwit/Cargo.lock b/quickwit/Cargo.lock index b93a8822826..7cb15733f04 100644 --- a/quickwit/Cargo.lock +++ b/quickwit/Cargo.lock @@ -4951,7 +4951,6 @@ dependencies = [ name = "quickwit-aws" version = "0.6.3" dependencies = [ - "anyhow", "async-trait", "aws-config", "aws-sdk-kinesis", @@ -4965,7 +4964,6 @@ dependencies = [ "once_cell", "quickwit-actors", "rand 0.8.5", - "thiserror", "tokio", "tower", "tracing", @@ -5127,8 +5125,6 @@ dependencies = [ "tonic 0.9.2", "tower", "tracing", - "utoipa", - "warp", ] [[package]] @@ -5196,7 +5192,6 @@ dependencies = [ "tonic 0.9.2", "tower", "tracing", - "utoipa", ] [[package]] @@ -5688,7 +5683,6 @@ dependencies = [ "postcard", "proptest", "prost", - "quickwit-cluster", "quickwit-common", "quickwit-config", "quickwit-directories", diff --git a/quickwit/quickwit-aws/Cargo.toml b/quickwit/quickwit-aws/Cargo.toml index 132837094d5..2c7672089e6 100644 --- a/quickwit/quickwit-aws/Cargo.toml +++ b/quickwit/quickwit-aws/Cargo.toml @@ -17,14 +17,12 @@ aws-smithy-async = { workspace = true } aws-smithy-client = { workspace = true } aws-types = { workspace = true } -anyhow = { workspace = true } async-trait = { workspace = true } futures = { workspace = true } hyper = { workspace = true } hyper-rustls = { workspace = true } once_cell = { workspace = true } rand = { workspace = true } -thiserror = { workspace = true } tokio = { workspace = true } tower = { workspace = true } tracing = { workspace = true } diff --git a/quickwit/quickwit-common/Cargo.toml b/quickwit/quickwit-common/Cargo.toml index dba7b0bf244..a3666468711 100644 --- a/quickwit/quickwit-common/Cargo.toml +++ b/quickwit/quickwit-common/Cargo.toml @@ -38,8 +38,6 @@ tokio-stream = { workspace = true } tonic = { workspace = true } tower = { workspace = true } tracing = { workspace = true } -utoipa = { workspace = true } -warp = { workspace = true } [features] testsuite = [] diff --git a/quickwit/quickwit-common/src/metrics.rs b/quickwit/quickwit-common/src/metrics.rs index 47ad2f1fbd2..327f599a19d 100644 --- a/quickwit/quickwit-common/src/metrics.rs +++ b/quickwit/quickwit-common/src/metrics.rs @@ -156,27 +156,7 @@ impl Drop for GaugeGuard { } } -#[derive(utoipa::OpenApi)] -#[openapi(paths(metrics_handler))] -/// Endpoints which are weirdly tied to another crate with no -/// other bits of information attached. -/// -/// If a crate plans to encompass different schemas, handlers, etc... -/// Then it should have it's own specific API group. -pub struct MetricsApi; - -#[utoipa::path( - get, - tag = "Get Metrics", - path = "/", - responses( - (status = 200, description = "Successfully fetched metrics.", body = String), - ), -)] -/// Get Node Metrics -/// -/// These are in the form of prometheus metrics. -pub fn metrics_handler() -> impl warp::Reply { +pub fn metrics_text_payload() -> String { let metric_families = prometheus::gather(); let mut buffer = Vec::new(); let encoder = TextEncoder::new(); diff --git a/quickwit/quickwit-control-plane/Cargo.toml b/quickwit/quickwit-control-plane/Cargo.toml index 54ceac4d8c4..94edaa36160 100644 --- a/quickwit/quickwit-control-plane/Cargo.toml +++ b/quickwit/quickwit-control-plane/Cargo.toml @@ -12,7 +12,6 @@ documentation = "https://quickwit.io/docs/" [dependencies] anyhow = { workspace = true } async-trait = { workspace = true } -chitchat = { workspace = true } dyn-clone = { workspace = true } http = { workspace = true } hyper = { workspace = true } @@ -28,13 +27,10 @@ tokio-stream = { workspace = true } tonic = { workspace = true } tower = { workspace = true } tracing = { workspace = true } -utoipa = { workspace = true } quickwit-actors = { workspace = true } -quickwit-cluster = { workspace = true } quickwit-common = { workspace = true } quickwit-config = { workspace = true } -quickwit-indexing = { workspace = true } quickwit-metastore = { workspace = true } quickwit-proto = { workspace = true } @@ -46,6 +42,8 @@ rand = { workspace = true } quickwit-actors = { workspace = true, features = ["testsuite"] } quickwit-cluster = { workspace = true, features = ["testsuite"] } +chitchat = { workspace = true } +quickwit-indexing = { workspace = true } quickwit-common = { workspace = true, features = ["testsuite"] } quickwit-config = { workspace = true, features = ["testsuite"] } quickwit-metastore = { workspace = true, features = ["testsuite"] } diff --git a/quickwit/quickwit-search/Cargo.toml b/quickwit/quickwit-search/Cargo.toml index af2ebe8d27e..8f26418c4b2 100644 --- a/quickwit/quickwit-search/Cargo.toml +++ b/quickwit/quickwit-search/Cargo.toml @@ -41,7 +41,6 @@ opentelemetry = { workspace = true } ulid = { workspace = true } utoipa = { workspace = true } -quickwit-cluster = { workspace = true } quickwit-common = { workspace = true } quickwit-config = { workspace = true } quickwit-directories = { workspace = true } diff --git a/quickwit/quickwit-serve/src/lib.rs b/quickwit/quickwit-serve/src/lib.rs index e8727ae0dfb..391543a8464 100644 --- a/quickwit/quickwit-serve/src/lib.rs +++ b/quickwit/quickwit-serve/src/lib.rs @@ -35,6 +35,7 @@ mod index_api; mod indexing_api; mod ingest_api; mod json_api_response; +mod metrics_api; mod node_info_handler; mod openapi; mod search_api; diff --git a/quickwit/quickwit-serve/src/metrics_api.rs b/quickwit/quickwit-serve/src/metrics_api.rs new file mode 100644 index 00000000000..8f8428bafc7 --- /dev/null +++ b/quickwit/quickwit-serve/src/metrics_api.rs @@ -0,0 +1,42 @@ +// Copyright (C) 2023 Quickwit, Inc. +// +// Quickwit is offered under the AGPL v3.0 and as commercial software. +// For commercial licensing, contact us at hello@quickwit.io. +// +// AGPL: +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#[derive(utoipa::OpenApi)] +#[openapi(paths(metrics_handler))] +/// Endpoints which are weirdly tied to another crate with no +/// other bits of information attached. +/// +/// If a crate plans to encompass different schemas, handlers, etc... +/// Then it should have it's own specific API group. +pub struct MetricsApi; + +#[utoipa::path( + get, + tag = "Get Metrics", + path = "/", + responses( + (status = 200, description = "Successfully fetched metrics.", body = String), + ), +)] +/// Get Node Metrics +/// +/// These are in the form of prometheus metrics. +pub fn metrics_handler() -> impl warp::Reply { + quickwit_common::metrics::metrics_text_payload() +} diff --git a/quickwit/quickwit-serve/src/openapi.rs b/quickwit/quickwit-serve/src/openapi.rs index 182ad842e46..856ea644828 100644 --- a/quickwit/quickwit-serve/src/openapi.rs +++ b/quickwit/quickwit-serve/src/openapi.rs @@ -19,7 +19,6 @@ use std::mem; -use quickwit_common::metrics::MetricsApi; use quickwit_config::ConfigApiSchemas; use quickwit_doc_mapper::DocMapperApiSchemas; use quickwit_indexing::IndexingApiSchemas; @@ -35,6 +34,7 @@ use crate::health_check_api::HealthCheckApi; use crate::index_api::IndexApi; use crate::indexing_api::IndexingApi; use crate::ingest_api::{IngestApi, IngestApiSchemas}; +use crate::metrics_api::MetricsApi; use crate::node_info_handler::NodeInfoApi; use crate::search_api::SearchApi; diff --git a/quickwit/quickwit-serve/src/rest.rs b/quickwit/quickwit-serve/src/rest.rs index 1c995d873c7..60eb4ba5e0e 100644 --- a/quickwit/quickwit-serve/src/rest.rs +++ b/quickwit/quickwit-serve/src/rest.rs @@ -22,7 +22,6 @@ use std::sync::Arc; use hyper::http::HeaderValue; use hyper::{http, Method}; -use quickwit_common::metrics; use quickwit_common::tower::BoxFutureInfaillible; use quickwit_proto::ServiceErrorCode; use tower::make::Shared; @@ -41,6 +40,7 @@ use crate::index_api::index_management_handlers; use crate::indexing_api::indexing_get_handler; use crate::ingest_api::ingest_api_handlers; use crate::json_api_response::{ApiError, JsonApiResponse}; +use crate::metrics_api::metrics_handler; use crate::node_info_handler::node_info_handler; use crate::search_api::{search_get_handler, search_post_handler, search_stream_handler}; use crate::ui_handler::ui_handler; @@ -83,9 +83,7 @@ pub(crate) async fn start_rest_server( ); // `/metrics` route. - let metrics_routes = warp::path("metrics") - .and(warp::get()) - .map(metrics::metrics_handler); + let metrics_routes = warp::path("metrics").and(warp::get()).map(metrics_handler); let ingest_service = quickwit_services.ingest_service.clone();