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

feat: Support export metric in remote write format #2928

Merged
merged 4 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
Taylor-lagrange marked this conversation as resolved.
Show resolved Hide resolved
# 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.
Taylor-lagrange marked this conversation as resolved.
Show resolved Hide resolved
# [system_metric]
killme2008 marked this conversation as resolved.
Show resolved Hide resolved
# whether enable export system_metric, default is false
Taylor-lagrange marked this conversation as resolved.
Show resolved Hide resolved
# enable = false
# The url of metric export endpoint, default is `greptimedb` default frontend endpoint
Taylor-lagrange marked this conversation as resolved.
Show resolved Hide resolved
# endpoint = "127.0.0.1:4000"
# The database name of exported metrics stores, user needs to specify a valid database
# db = ""
killme2008 marked this conversation as resolved.
Show resolved Hide resolved
# 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
Taylor-lagrange marked this conversation as resolved.
Show resolved Hide resolved
# 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.
Taylor-lagrange marked this conversation as resolved.
Show resolved Hide resolved
# [system_metric]
# whether enable export system_metric, default is false
# enable = false
# The url of metric export endpoint, default is `greptimedb` default frontend endpoint
Taylor-lagrange marked this conversation as resolved.
Show resolved Hide resolved
# 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
Taylor-lagrange marked this conversation as resolved.
Show resolved Hide resolved
# 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/standalone.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,17 @@ parallel_scan_channel_size = 32
# otlp_endpoint = "localhost:4317"
# 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 export the metrics generated by itself
Taylor-lagrange marked this conversation as resolved.
Show resolved Hide resolved
# 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"
4 changes: 4 additions & 0 deletions src/cmd/src/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ impl StartCommand {
.await
.context(StartFrontendSnafu)?;

instance
.build_system_metric_task(&opts.system_metric)
Taylor-lagrange marked this conversation as resolved.
Show resolved Hide resolved
.context(StartFrontendSnafu)?;

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

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

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

frontend
.build_servers(opts)
.await
Expand Down
1 change: 1 addition & 0 deletions src/common/telemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ deadlock_detection = ["parking_lot/deadlock_detection"]
backtrace = "0.3"
common-error.workspace = true
console-subscriber = { version = "0.1", optional = true }
greptime-proto.workspace = true
lazy_static.workspace = true
once_cell.workspace = true
opentelemetry = { version = "0.21.0", default-features = false, features = [
Expand Down
Loading
Loading