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

* fix: resolve residual issues when removing prometheus port

* fix: remove prometheus from sample config as well
This commit is contained in:
Ning Sun
2023-08-23 09:49:11 +08:00
committed by GitHub
parent 18250c4803
commit 88247e4284
10 changed files with 22 additions and 93 deletions

View File

@@ -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"]

View File

@@ -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

View File

@@ -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<String>,
#[clap(long)]
prom_addr: Option<String>,
#[clap(long)]
postgres_addr: Option<String>,
#[clap(long)]
opentsdb_addr: Option<String>,
@@ -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!(

View File

@@ -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<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,
@@ -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<String>,
#[clap(long)]
prom_addr: Option<String>,
#[clap(long)]
postgres_addr: Option<String>,
#[clap(long)]
opentsdb_addr: Option<String>,
@@ -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();

View File

@@ -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<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,
@@ -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(),

View File

@@ -176,7 +176,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 })) {

View File

@@ -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;

View File

@@ -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());
}
}

View File

@@ -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),
);
}

View File

@@ -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);