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 2 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.

12 changes: 12 additions & 0 deletions config/standalone.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,15 @@ 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/frontend/datanode/metasrv export the metrics generated by itself
# send metrics to Prometheus remote-write compatible receiver (e.g. `greptimedb`)
Taylor-lagrange marked this conversation as resolved.
Show resolved Hide resolved
# [remote_write]
waynexia marked this conversation as resolved.
Show resolved Hide resolved
# whether enable export remote_write, 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"
waynexia marked this conversation as resolved.
Show resolved Hide resolved
# 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_remote_write_metric_task(&opts.remote_write)
.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::remote_writer::RemoteWriteOptions;
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 remote_write: RemoteWriteOptions,
}

impl Default for StandaloneOptions {
Expand All @@ -131,6 +133,7 @@ impl Default for StandaloneOptions {
metadata_store: KvBackendConfig::default(),
procedure: ProcedureConfig::default(),
logging: LoggingOptions::default(),
remote_write: RemoteWriteOptions::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 remote write metric task run by standalone to frontend for execution
remote_write: self.remote_write,
..Default::default()
}
}
Expand Down Expand Up @@ -399,6 +404,10 @@ impl StartCommand {
.await
.context(StartFrontendSnafu)?;

frontend
.build_remote_write_metric_task(&opts.frontend.remote_write)
.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