Skip to content
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

fix!: resolve residual issues with removing prometheus port #2227

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions config/frontend.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
5 changes: 0 additions & 5 deletions config/standalone.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 1 addition & 12 deletions src/cmd/src/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -99,8 +99,6 @@ pub struct StartCommand {
#[clap(long)]
mysql_addr: Option<String>,
#[clap(long)]
prom_addr: Option<String>,
#[clap(long)]
postgres_addr: Option<String>,
#[clap(long)]
opentsdb_addr: Option<String>,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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!(
Expand Down
10 changes: 0 additions & 10 deletions src/cmd/src/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -91,7 +90,6 @@ pub struct StandaloneOptions {
pub opentsdb_options: Option<OpentsdbOptions>,
pub influxdb_options: Option<InfluxdbOptions>,
pub prom_store_options: Option<PromStoreOptions>,
pub prometheus_options: Option<PrometheusOptions>,
pub wal: WalConfig,
pub storage: StorageConfig,
pub procedure: ProcedureConfig,
Expand All @@ -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(),
Expand All @@ -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()
Expand Down Expand Up @@ -193,8 +189,6 @@ struct StartCommand {
#[clap(long)]
mysql_addr: Option<String>,
#[clap(long)]
prom_addr: Option<String>,
#[clap(long)]
postgres_addr: Option<String>,
#[clap(long)]
opentsdb_addr: Option<String>,
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/src/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -37,7 +37,6 @@ pub struct FrontendOptions {
pub opentsdb_options: Option<OpentsdbOptions>,
pub influxdb_options: Option<InfluxdbOptions>,
pub prom_store_options: Option<PromStoreOptions>,
pub prometheus_options: Option<PrometheusOptions>,
pub otlp_options: Option<OtlpOptions>,
pub meta_client_options: Option<MetaClientOptions>,
pub logging: LoggingOptions,
Expand All @@ -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(),
Expand Down
4 changes: 3 additions & 1 deletion src/frontend/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 })) {
Expand Down
2 changes: 0 additions & 2 deletions src/frontend/src/service_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
39 changes: 0 additions & 39 deletions src/frontend/src/service_config/prometheus.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/servers/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}
Expand Down
32 changes: 16 additions & 16 deletions tests-integration/tests/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,44 +344,44 @@ 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;
assert_eq!(res.status(), StatusCode::OK);

// 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;
assert_eq!(res.status(), StatusCode::OK);

// 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);
Expand All @@ -396,25 +396,25 @@ 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;
assert_eq!(res.status(), StatusCode::OK);

// 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);
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Loading