Skip to content

Commit

Permalink
chore: change name to system metric
Browse files Browse the repository at this point in the history
  • Loading branch information
Taylor-lagrange committed Dec 21, 2023
1 parent 854b055 commit 70c2b45
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 63 deletions.
14 changes: 14 additions & 0 deletions config/datanode.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,17 @@ parallel_scan_channel_size = 32
# [logging]
# dir = "/tmp/greptimedb/logs"
# level = "info"

# datanode export the metrics generated by itself
# encoded to Prometheus remote-write format
# and send to Prometheus remote-write compatible receiver (e.g. send to `greptimedb` itself)
# This is only used for `greptimedb` to export its own metric internally. Please see `logging` option for normal export of metric.
# [system_metric]
# whether enable export system_metric, default is false
# enable = false
# The url of metric export endpoint, default is `greptimedb` default frontend endpoint
# endpoint = "127.0.0.1:4000"
# The database name of exported metrics stores, user needs to specify a valid database
# db = ""
# The interval of export metric
# write_interval = "30s"
14 changes: 14 additions & 0 deletions config/frontend.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,17 @@ tcp_nodelay = true
timeout = "10s"
connect_timeout = "10s"
tcp_nodelay = true

# frontend export the metrics generated by itself
# encoded to Prometheus remote-write format
# and send to Prometheus remote-write compatible receiver (e.g. send to `greptimedb` itself)
# This is only used for `greptimedb` to export its own metric internally. Please see `logging` option for normal export of metric.
# [system_metric]
# whether enable export system_metric, default is false
# enable = false
# The url of metric export endpoint, default is `greptimedb` default frontend endpoint
# endpoint = "127.0.0.1:4000"
# The database name of exported metrics stores, user needs to specify a valid database
# db = ""
# The interval of export metric
# write_interval = "30s"
14 changes: 14 additions & 0 deletions config/metasrv.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,17 @@ provider = "raft_engine"
# num_partitions = 1
# Expected number of replicas of each partition.
# replication_factor = 3

# metasrv export the metrics generated by itself
# encoded to Prometheus remote-write format
# and send to Prometheus remote-write compatible receiver (e.g. send to `greptimedb` itself)
# This is only used for `greptimedb` to export its own metric internally. Please see `logging` option for normal export of metric.
# [system_metric]
# whether enable export system_metric, default is false
# enable = false
# The url of metric export endpoint, default is `greptimedb` default frontend endpoint
# endpoint = "127.0.0.1:4000"
# The database name of exported metrics stores, user needs to specify a valid database
# db = ""
# The interval of export metric
# write_interval = "30s"
20 changes: 11 additions & 9 deletions config/standalone.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,16 @@ parallel_scan_channel_size = 32
# The percentage of tracing will be sampled and exported. Valid range `[0, 1]`, 1 means all traces are sampled, 0 means all traces are not sampled, the default value is 1. ratio > 1 are treated as 1. Fractions < 0 are treated as 0
# tracing_sample_ratio = 1.0

# standalone/frontend/datanode/metasrv export the metrics generated by itself
# send metrics to Prometheus remote-write compatible receiver (e.g. `greptimedb`)
# [remote_write]
# whether enable export remote_write, default is false
# standalone export the metrics generated by itself
# encoded to Prometheus remote-write format
# and send to Prometheus remote-write compatible receiver (e.g. send to `greptimedb` itself)
# This is only used for `greptimedb` to export its own metric internally. Please see `logging` option for normal export of metric.
# [system_metric]
# whether enable export system_metric, default is false
# enable = false
# The url of remote write endpoint.
# Taking greptimedb as an example, for `standalone` deployed under the default configuration.
# The user can create a database called `system` in the db and export the metric to `http://127.0.0.1:4000/v1/prometheus/write?db=system`
# endpoint = "http://127.0.0.1:4000/v1/prometheus/write?db=system"
# The interval of export metric,
# The url of metric export endpoint, default is `greptimedb` default frontend endpoint
# endpoint = "127.0.0.1:4000"
# The database name of exported metrics stores, user needs to specify a valid database
# db = ""
# The interval of export metric
# write_interval = "30s"
2 changes: 1 addition & 1 deletion src/cmd/src/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl StartCommand {
.context(StartFrontendSnafu)?;

instance
.build_remote_write_metric_task(&opts.remote_write)
.build_system_metric_task(&opts.system_metric)
.context(StartFrontendSnafu)?;

instance
Expand Down
12 changes: 6 additions & 6 deletions src/cmd/src/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use frontend::service_config::{
use mito2::config::MitoConfig;
use serde::{Deserialize, Serialize};
use servers::http::HttpOptions;
use servers::remote_writer::RemoteWriteOptions;
use servers::system_metric::SystemMetricOption;
use servers::tls::{TlsMode, TlsOption};
use servers::Mode;
use snafu::ResultExt;
Expand Down Expand Up @@ -113,7 +113,7 @@ pub struct StandaloneOptions {
pub user_provider: Option<String>,
/// Options for different store engines.
pub region_engine: Vec<RegionEngineConfig>,
pub remote_write: RemoteWriteOptions,
pub system_metric: SystemMetricOption,
}

impl Default for StandaloneOptions {
Expand All @@ -133,7 +133,7 @@ impl Default for StandaloneOptions {
metadata_store: KvBackendConfig::default(),
procedure: ProcedureConfig::default(),
logging: LoggingOptions::default(),
remote_write: RemoteWriteOptions::default(),
system_metric: SystemMetricOption::default(),
user_provider: None,
region_engine: vec![
RegionEngineConfig::Mito(MitoConfig::default()),
Expand All @@ -157,8 +157,8 @@ impl StandaloneOptions {
meta_client: None,
logging: self.logging,
user_provider: self.user_provider,
// Handle the remote write metric task run by standalone to frontend for execution
remote_write: self.remote_write,
// Handle the system metric task run by standalone to frontend for execution
system_metric: self.system_metric,
..Default::default()
}
}
Expand Down Expand Up @@ -405,7 +405,7 @@ impl StartCommand {
.context(StartFrontendSnafu)?;

frontend
.build_remote_write_metric_task(&opts.frontend.remote_write)
.build_system_metric_task(&opts.frontend.system_metric)
.context(StartFrontendSnafu)?;

frontend
Expand Down
1 change: 0 additions & 1 deletion src/common/telemetry/src/metric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

use std::sync::Arc;

// metric stuffs, inspired by databend
use greptime_proto::prometheus::remote::{Sample, TimeSeries};
use greptime_proto::prometheus::*;
use prometheus::proto::{LabelPair, MetricFamily, MetricType};
Expand Down
6 changes: 3 additions & 3 deletions src/datanode/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use secrecy::SecretString;
use serde::{Deserialize, Serialize};
use servers::heartbeat_options::HeartbeatOptions;
use servers::http::HttpOptions;
use servers::remote_writer::RemoteWriteOptions;
use servers::system_metric::SystemMetricOption;
use servers::Mode;

pub const DEFAULT_OBJECT_STORE_CACHE_SIZE: ReadableSize = ReadableSize::mb(256);
Expand Down Expand Up @@ -242,7 +242,7 @@ pub struct DatanodeOptions {
pub region_engine: Vec<RegionEngineConfig>,
pub logging: LoggingOptions,
pub enable_telemetry: bool,
pub remote_write: RemoteWriteOptions,
pub system_metric: SystemMetricOption,
}

impl Default for DatanodeOptions {
Expand All @@ -267,7 +267,7 @@ impl Default for DatanodeOptions {
logging: LoggingOptions::default(),
heartbeat: HeartbeatOptions::datanode_default(),
enable_telemetry: true,
remote_write: RemoteWriteOptions::default(),
system_metric: SystemMetricOption::default(),
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/datanode/src/datanode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ use query::QueryEngineFactory;
use servers::grpc::{GrpcServer, GrpcServerConfig};
use servers::http::HttpServerBuilder;
use servers::metrics_handler::MetricsHandler;
use servers::remote_writer::RemoteWriteMetricTask;
use servers::server::{start_server, ServerHandler, ServerHandlers};
use servers::system_metric::SystemMetricTask;
use servers::Mode;
use snafu::{OptionExt, ResultExt};
use store_api::logstore::LogStore;
Expand Down Expand Up @@ -82,7 +82,7 @@ pub struct Datanode {
greptimedb_telemetry_task: Arc<GreptimeDBTelemetryTask>,
leases_notifier: Option<Arc<Notify>>,
plugins: Plugins,
remote_write_metric_task: Option<RemoteWriteMetricTask>,
system_metric_task: Option<SystemMetricTask>,
}

impl Datanode {
Expand All @@ -94,7 +94,7 @@ impl Datanode {

self.start_telemetry();

if let Some(t) = self.remote_write_metric_task.as_ref() {
if let Some(t) = self.system_metric_task.as_ref() {
t.start()
}

Expand Down Expand Up @@ -265,8 +265,8 @@ impl DatanodeBuilder {
None
};

let remote_write_metric_task =
RemoteWriteMetricTask::try_new(&self.opts.remote_write, Some(&self.plugins))
let system_metric_task =
SystemMetricTask::try_new(&self.opts.system_metric, Some(&self.plugins))
.context(StartServerSnafu)?;

Ok(Datanode {
Expand All @@ -277,7 +277,7 @@ impl DatanodeBuilder {
region_event_receiver,
leases_notifier,
plugins: self.plugins.clone(),
remote_write_metric_task,
system_metric_task,
})
}

Expand Down
6 changes: 3 additions & 3 deletions src/frontend/src/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use meta_client::MetaClientOptions;
use serde::{Deserialize, Serialize};
use servers::heartbeat_options::HeartbeatOptions;
use servers::http::HttpOptions;
use servers::remote_writer::RemoteWriteOptions;
use servers::system_metric::SystemMetricOption;
use servers::Mode;
use snafu::prelude::*;

Expand Down Expand Up @@ -45,7 +45,7 @@ pub struct FrontendOptions {
pub logging: LoggingOptions,
pub datanode: DatanodeOptions,
pub user_provider: Option<String>,
pub remote_write: RemoteWriteOptions,
pub system_metric: SystemMetricOption,
}

impl Default for FrontendOptions {
Expand All @@ -66,7 +66,7 @@ impl Default for FrontendOptions {
logging: LoggingOptions::default(),
datanode: DatanodeOptions::default(),
user_provider: None,
remote_write: RemoteWriteOptions::default(),
system_metric: SystemMetricOption::default(),
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/frontend/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ use servers::query_handler::{
InfluxdbLineProtocolHandler, OpenTelemetryProtocolHandler, OpentsdbProtocolHandler,
PromStoreProtocolHandler, ScriptHandler,
};
use servers::remote_writer::{RemoteWriteMetricTask, RemoteWriteOptions};
use servers::server::{start_server, ServerHandlers};
use servers::system_metric::{SystemMetricOption, SystemMetricTask};
use session::context::QueryContextRef;
use snafu::prelude::*;
use sql::dialect::Dialect;
Expand Down Expand Up @@ -118,7 +118,7 @@ pub struct Instance {
heartbeat_task: Option<HeartbeatTask>,
inserter: InserterRef,
deleter: DeleterRef,
remote_write_metric_task: Option<RemoteWriteMetricTask>,
system_metric_task: Option<SystemMetricTask>,
}

impl Instance {
Expand Down Expand Up @@ -196,9 +196,9 @@ impl Instance {
Ok(())
}

pub fn build_remote_write_metric_task(&mut self, opts: &RemoteWriteOptions) -> Result<()> {
self.remote_write_metric_task =
RemoteWriteMetricTask::try_new(opts, Some(&self.plugins)).context(StartServerSnafu)?;
pub fn build_system_metric_task(&mut self, opts: &SystemMetricOption) -> Result<()> {
self.system_metric_task =
SystemMetricTask::try_new(opts, Some(&self.plugins)).context(StartServerSnafu)?;
Ok(())
}

Expand Down Expand Up @@ -231,7 +231,7 @@ impl FrontendInstance for Instance {

self.script_executor.start(self)?;

if let Some(t) = self.remote_write_metric_task.as_ref() {
if let Some(t) = self.system_metric_task.as_ref() {
t.start()
}

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/instance/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl FrontendBuilder {
heartbeat_task: self.heartbeat_task,
inserter,
deleter,
remote_write_metric_task: None,
system_metric_task: None,
})
}
}
13 changes: 6 additions & 7 deletions src/meta-srv/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use etcd_client::Client;
use servers::configurator::ConfiguratorRef;
use servers::http::{HttpServer, HttpServerBuilder};
use servers::metrics_handler::MetricsHandler;
use servers::remote_writer::RemoteWriteMetricTask;
use servers::server::Server;
use servers::system_metric::SystemMetricTask;
use snafu::ResultExt;
use tokio::net::TcpListener;
use tokio::select;
Expand Down Expand Up @@ -60,7 +60,7 @@ pub struct MetaSrvInstance {

plugins: Plugins,

remote_write_metric_task: Option<RemoteWriteMetricTask>,
system_metric_task: Option<SystemMetricTask>,
}

impl MetaSrvInstance {
Expand All @@ -77,23 +77,22 @@ impl MetaSrvInstance {
);
// put meta_srv into plugins for later use
plugins.insert::<Arc<MetaSrv>>(Arc::new(meta_srv.clone()));
let remote_write_metric_task =
RemoteWriteMetricTask::try_new(&opts.remote_write, Some(&plugins))
.context(InitRemoteWriteMetricTaskSnafu)?;
let system_metric_task = SystemMetricTask::try_new(&opts.system_metric, Some(&plugins))
.context(InitRemoteWriteMetricTaskSnafu)?;
Ok(MetaSrvInstance {
meta_srv,
http_srv,
opts,
signal_sender: None,
plugins,
remote_write_metric_task,
system_metric_task,
})
}

pub async fn start(&mut self) -> Result<()> {
self.meta_srv.try_start().await?;

if let Some(t) = self.remote_write_metric_task.as_ref() {
if let Some(t) = self.system_metric_task.as_ref() {
t.start()
}

Expand Down
6 changes: 3 additions & 3 deletions src/meta-srv/src/metasrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use common_telemetry::logging::LoggingOptions;
use common_telemetry::{error, info, warn};
use serde::{Deserialize, Serialize};
use servers::http::HttpOptions;
use servers::remote_writer::RemoteWriteOptions;
use servers::system_metric::SystemMetricOption;
use snafu::ResultExt;
use table::metadata::TableId;
use tokio::sync::broadcast::error::RecvError;
Expand Down Expand Up @@ -73,7 +73,7 @@ pub struct MetaSrvOptions {
pub enable_telemetry: bool,
pub data_home: String,
pub wal: WalConfig,
pub remote_write: RemoteWriteOptions,
pub system_metric: SystemMetricOption,
}

impl Default for MetaSrvOptions {
Expand All @@ -99,7 +99,7 @@ impl Default for MetaSrvOptions {
enable_telemetry: true,
data_home: METASRV_HOME.to_string(),
wal: WalConfig::default(),
remote_write: RemoteWriteOptions::default(),
system_metric: SystemMetricOption::default(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/servers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ pub mod postgres;
pub mod prom_store;
pub mod prometheus_handler;
pub mod query_handler;
pub mod remote_writer;
mod row_writer;
pub mod server;
mod shutdown;
pub mod system_metric;
pub mod tls;

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
Expand Down
Loading

0 comments on commit 70c2b45

Please sign in to comment.