diff --git a/config/frontend.example.toml b/config/frontend.example.toml index fc0f7a14f760..d8589fed9033 100644 --- a/config/frontend.example.toml +++ b/config/frontend.example.toml @@ -53,10 +53,6 @@ enable = true [prom_store_options] enable = true -# Prometheus protocol options, see `standalone.example.toml`. -[prometheus_options] -addr = "127.0.0.1:4004" - # Metasrv client options, see `datanode.example.toml`. [meta_client_options] metasrv_addrs = ["127.0.0.1:3002"] diff --git a/config/standalone.example.toml b/config/standalone.example.toml index ed2b4645b907..0976e1fe80a9 100644 --- a/config/standalone.example.toml +++ b/config/standalone.example.toml @@ -76,11 +76,6 @@ enable = true # Whether to enable Prometheus remote write and read in HTTP API, true by default. enable = true -# Prometheus protocol options -[prometheus_options] -# Prometheus API server address, "127.0.0.1:4004" by default. -addr = "127.0.0.1:4004" - # WAL options. [wal] # WAL data directory diff --git a/src/cmd/src/frontend.rs b/src/cmd/src/frontend.rs index c121640e159a..b43c6ab8aef7 100644 --- a/src/cmd/src/frontend.rs +++ b/src/cmd/src/frontend.rs @@ -20,7 +20,7 @@ use common_base::Plugins; use common_telemetry::logging; use frontend::frontend::FrontendOptions; use frontend::instance::{FrontendInstance, Instance as FeInstance}; -use frontend::service_config::{InfluxdbOptions, PrometheusOptions}; +use frontend::service_config::InfluxdbOptions; use meta_client::MetaClientOptions; use servers::tls::{TlsMode, TlsOption}; use servers::Mode; @@ -99,8 +99,6 @@ pub struct StartCommand { #[clap(long)] mysql_addr: Option, #[clap(long)] - prom_addr: Option, - #[clap(long)] postgres_addr: Option, #[clap(long)] opentsdb_addr: Option, @@ -171,10 +169,6 @@ impl StartCommand { } } - if let Some(addr) = &self.prom_addr { - opts.prometheus_options = Some(PrometheusOptions { addr: addr.clone() }); - } - if let Some(addr) = &self.postgres_addr { if let Some(postgres_opts) = &mut opts.postgres_options { postgres_opts.addr = addr.clone(); @@ -248,7 +242,6 @@ mod tests { fn test_try_from_start_command() { let command = StartCommand { http_addr: Some("127.0.0.1:1234".to_string()), - prom_addr: Some("127.0.0.1:4444".to_string()), mysql_addr: Some("127.0.0.1:5678".to_string()), postgres_addr: Some("127.0.0.1:5432".to_string()), opentsdb_addr: Some("127.0.0.1:4321".to_string()), @@ -276,10 +269,6 @@ mod tests { opts.opentsdb_options.as_ref().unwrap().addr, "127.0.0.1:4321" ); - assert_eq!( - opts.prometheus_options.as_ref().unwrap().addr, - "127.0.0.1:4444" - ); let default_opts = FrontendOptions::default(); assert_eq!( diff --git a/src/cmd/src/standalone.rs b/src/cmd/src/standalone.rs index 10788c2d2e61..22f03e3bc5b0 100644 --- a/src/cmd/src/standalone.rs +++ b/src/cmd/src/standalone.rs @@ -24,7 +24,6 @@ use frontend::frontend::FrontendOptions; use frontend::instance::{FrontendInstance, Instance as FeInstance}; use frontend::service_config::{ GrpcOptions, InfluxdbOptions, MysqlOptions, OpentsdbOptions, PostgresOptions, PromStoreOptions, - PrometheusOptions, }; use serde::{Deserialize, Serialize}; use servers::http::HttpOptions; @@ -91,7 +90,6 @@ pub struct StandaloneOptions { pub opentsdb_options: Option, pub influxdb_options: Option, pub prom_store_options: Option, - pub prometheus_options: Option, pub wal: WalConfig, pub storage: StorageConfig, pub procedure: ProcedureConfig, @@ -111,7 +109,6 @@ impl Default for StandaloneOptions { opentsdb_options: Some(OpentsdbOptions::default()), influxdb_options: Some(InfluxdbOptions::default()), prom_store_options: Some(PromStoreOptions::default()), - prometheus_options: Some(PrometheusOptions::default()), wal: WalConfig::default(), storage: StorageConfig::default(), procedure: ProcedureConfig::default(), @@ -131,7 +128,6 @@ impl StandaloneOptions { opentsdb_options: self.opentsdb_options, influxdb_options: self.influxdb_options, prom_store_options: self.prom_store_options, - prometheus_options: self.prometheus_options, meta_client_options: None, logging: self.logging, ..Default::default() @@ -193,8 +189,6 @@ struct StartCommand { #[clap(long)] mysql_addr: Option, #[clap(long)] - prom_addr: Option, - #[clap(long)] postgres_addr: Option, #[clap(long)] opentsdb_addr: Option, @@ -271,10 +265,6 @@ impl StartCommand { } } - if let Some(addr) = &self.prom_addr { - opts.prometheus_options = Some(PrometheusOptions { addr: addr.clone() }) - } - if let Some(addr) = &self.postgres_addr { if let Some(postgres_opts) = &mut opts.postgres_options { postgres_opts.addr = addr.clone(); diff --git a/src/frontend/src/frontend.rs b/src/frontend/src/frontend.rs index a0c10c6f64de..593073aad7b9 100644 --- a/src/frontend/src/frontend.rs +++ b/src/frontend/src/frontend.rs @@ -21,7 +21,7 @@ use servers::Mode; use crate::service_config::{ DatanodeOptions, GrpcOptions, InfluxdbOptions, MysqlOptions, OpentsdbOptions, OtlpOptions, - PostgresOptions, PromStoreOptions, PrometheusOptions, + PostgresOptions, PromStoreOptions, }; #[derive(Clone, Debug, Serialize, Deserialize)] @@ -37,7 +37,6 @@ pub struct FrontendOptions { pub opentsdb_options: Option, pub influxdb_options: Option, pub prom_store_options: Option, - pub prometheus_options: Option, pub otlp_options: Option, pub meta_client_options: Option, pub logging: LoggingOptions, @@ -57,7 +56,6 @@ impl Default for FrontendOptions { opentsdb_options: Some(OpentsdbOptions::default()), influxdb_options: Some(InfluxdbOptions::default()), prom_store_options: Some(PromStoreOptions::default()), - prometheus_options: Some(PrometheusOptions::default()), otlp_options: Some(OtlpOptions::default()), meta_client_options: None, logging: LoggingOptions::default(), diff --git a/src/frontend/src/server.rs b/src/frontend/src/server.rs index 2810436468de..15b4d52534dd 100644 --- a/src/frontend/src/server.rs +++ b/src/frontend/src/server.rs @@ -174,7 +174,9 @@ impl Services { opts.prom_store_options, Some(PromStoreOptions { enable: true }) ) { - let _ = http_server_builder.with_prom_handler(instance.clone()); + let _ = http_server_builder + .with_prom_handler(instance.clone()) + .with_prometheus_handler(instance.clone()); } if matches!(opts.otlp_options, Some(OtlpOptions { enable: true })) { diff --git a/src/frontend/src/service_config.rs b/src/frontend/src/service_config.rs index c23edbc159db..870a6092e794 100644 --- a/src/frontend/src/service_config.rs +++ b/src/frontend/src/service_config.rs @@ -20,7 +20,6 @@ pub mod opentsdb; pub mod otlp; pub mod postgres; pub mod prom_store; -pub mod prometheus; pub use grpc::GrpcOptions; pub use influxdb::InfluxdbOptions; @@ -29,6 +28,5 @@ pub use opentsdb::OpentsdbOptions; pub use otlp::OtlpOptions; pub use postgres::PostgresOptions; pub use prom_store::PromStoreOptions; -pub use prometheus::PrometheusOptions; pub use self::datanode::DatanodeOptions; diff --git a/src/frontend/src/service_config/prometheus.rs b/src/frontend/src/service_config/prometheus.rs deleted file mode 100644 index 7ae477abf2bf..000000000000 --- a/src/frontend/src/service_config/prometheus.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2023 Greptime Team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct PrometheusOptions { - pub addr: String, -} - -impl Default for PrometheusOptions { - fn default() -> Self { - Self { - addr: "127.0.0.1:4004".to_string(), - } - } -} - -#[cfg(test)] -mod tests { - use super::PrometheusOptions; - - #[test] - fn test_prometheus_options() { - let default = PrometheusOptions::default(); - assert_eq!(default.addr, "127.0.0.1:4004".to_string()); - } -} diff --git a/src/servers/src/http.rs b/src/servers/src/http.rs index a2773b77bcc9..ece3dda6c610 100644 --- a/src/servers/src/http.rs +++ b/src/servers/src/http.rs @@ -550,7 +550,7 @@ impl HttpServer { if let Some(prometheus_handler) = self.prometheus_handler.clone() { router = router.nest( - &format!("/{HTTP_API_VERSION}/prometheus"), + &format!("/{HTTP_API_VERSION}/prometheus/api/v1"), self.route_prometheus(prometheus_handler), ); } diff --git a/tests-integration/tests/http.rs b/tests-integration/tests/http.rs index 207b1d29940d..39fd8e22ac19 100644 --- a/tests-integration/tests/http.rs +++ b/tests-integration/tests/http.rs @@ -344,12 +344,12 @@ pub async fn test_prom_http_api(store_type: StorageType) { // instant query let res = client - .get("/v1/prometheus/query?query=up&time=1") + .get("/v1/prometheus/api/v1/query?query=up&time=1") .send() .await; assert_eq!(res.status(), StatusCode::OK); let res = client - .post("/v1/prometheus/query?query=up&time=1") + .post("/v1/prometheus/api/v1/query?query=up&time=1") .header("Content-Type", "application/x-www-form-urlencoded") .send() .await; @@ -357,12 +357,12 @@ pub async fn test_prom_http_api(store_type: StorageType) { // range query let res = client - .get("/v1/prometheus/query_range?query=up&start=1&end=100&step=5") + .get("/v1/prometheus/api/v1/query_range?query=up&start=1&end=100&step=5") .send() .await; assert_eq!(res.status(), StatusCode::OK); let res = client - .post("/v1/prometheus/query_range?query=up&start=1&end=100&step=5") + .post("/v1/prometheus/api/v1/query_range?query=up&start=1&end=100&step=5") .header("Content-Type", "application/x-www-form-urlencoded") .send() .await; @@ -370,18 +370,18 @@ pub async fn test_prom_http_api(store_type: StorageType) { // labels let res = client - .get("/v1/prometheus/labels?match[]=demo") + .get("/v1/prometheus/api/v1/labels?match[]=demo") .send() .await; assert_eq!(res.status(), StatusCode::OK); let res = client - .post("/v1/prometheus/labels?match[]=up") + .post("/v1/prometheus/api/v1/labels?match[]=up") .header("Content-Type", "application/x-www-form-urlencoded") .send() .await; assert_eq!(res.status(), StatusCode::OK); let res = client - .get("/v1/prometheus/labels?match[]=demo&start=0") + .get("/v1/prometheus/api/v1/labels?match[]=demo&start=0") .send() .await; assert_eq!(res.status(), StatusCode::OK); @@ -396,17 +396,17 @@ pub async fn test_prom_http_api(store_type: StorageType) { ); // labels without match[] param - let res = client.get("/v1/prometheus/labels").send().await; + let res = client.get("/v1/prometheus/api/v1/labels").send().await; assert_eq!(res.status(), StatusCode::OK); // labels query with multiple match[] params let res = client - .get("/v1/prometheus/labels?match[]=up&match[]=down") + .get("/v1/prometheus/api/v1/labels?match[]=up&match[]=down") .send() .await; assert_eq!(res.status(), StatusCode::OK); let res = client - .post("/v1/prometheus/labels?match[]=up&match[]=down") + .post("/v1/prometheus/api/v1/labels?match[]=up&match[]=down") .header("Content-Type", "application/x-www-form-urlencoded") .send() .await; @@ -414,7 +414,7 @@ pub async fn test_prom_http_api(store_type: StorageType) { // series let res = client - .get("/v1/prometheus/series?match[]=demo&start=0&end=0") + .get("/v1/prometheus/api/v1/series?match[]=demo&start=0&end=0") .send() .await; assert_eq!(res.status(), StatusCode::OK); @@ -438,7 +438,7 @@ pub async fn test_prom_http_api(store_type: StorageType) { assert_eq!(actual, expected); let res = client - .post("/v1/prometheus/series?match[]=up&match[]=down") + .post("/v1/prometheus/api/v1/series?match[]=up&match[]=down") .header("Content-Type", "application/x-www-form-urlencoded") .send() .await; @@ -447,7 +447,7 @@ pub async fn test_prom_http_api(store_type: StorageType) { // label values // should return error if there is no match[] let res = client - .get("/v1/prometheus/label/instance/values") + .get("/v1/prometheus/api/v1/label/instance/values") .send() .await; assert_eq!(res.status(), StatusCode::OK); @@ -458,7 +458,7 @@ pub async fn test_prom_http_api(store_type: StorageType) { // single match[] let res = client - .get("/v1/prometheus/label/host/values?match[]=demo&start=0&end=600") + .get("/v1/prometheus/api/v1/label/host/values?match[]=demo&start=0&end=600") .send() .await; assert_eq!(res.status(), StatusCode::OK); @@ -471,7 +471,7 @@ pub async fn test_prom_http_api(store_type: StorageType) { // multiple match[] let res = client - .get("/v1/prometheus/label/instance/values?match[]=up&match[]=system_metrics") + .get("/v1/prometheus/api/v1/label/instance/values?match[]=up&match[]=system_metrics") .send() .await; assert_eq!(res.status(), StatusCode::OK); @@ -482,7 +482,7 @@ pub async fn test_prom_http_api(store_type: StorageType) { // query `__name__` without match[] let res = client - .get("/v1/prometheus/label/__name__/values") + .get("/v1/prometheus/api/v1/label/__name__/values") .send() .await; assert_eq!(res.status(), StatusCode::OK);