diff --git a/src/main.rs b/src/main.rs index 2fb2624..f02ff9e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4313,6 +4313,13 @@ async fn main() -> Result<(), Box> { .required(true) .help("Access Token"), ) + .arg( + Arg::with_name("org") + .value_name("ORG") + .takes_value(true) + .required(true) + .help("Organization"), + ) .arg( Arg::with_name("bucket") .value_name("BUCKET") @@ -5786,10 +5793,12 @@ async fn main() -> Result<(), Box> { Some(MetricsConfig { url, token: _, + org, bucket, }) => { println!("Url: {url}"); println!("Token: ********"); + println!("Organization: {org}"); println!("Bucket: {bucket}"); } }, @@ -5797,6 +5806,7 @@ async fn main() -> Result<(), Box> { db.set_metrics_config(MetricsConfig { url: value_t_or_exit!(arg_matches, "url", String), token: value_t_or_exit!(arg_matches, "token", String), + org: value_t_or_exit!(arg_matches, "org", String), bucket: value_t_or_exit!(arg_matches, "bucket", String), })?; println!("InfluxDb configuration set"); diff --git a/src/metrics.rs b/src/metrics.rs index 2bb04c4..bdcadb1 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -15,6 +15,7 @@ lazy_static::lazy_static! { pub struct MetricsConfig { pub url: String, pub token: String, + pub org: String, pub bucket: String, } @@ -22,6 +23,7 @@ pub fn env_config() -> Option { Some(MetricsConfig { url: env::var("INFLUX_URL").ok()?, token: env::var("INFLUX_API_TOKEN").ok()?, + org: env::var("INFLUX_ORG").ok()?, bucket: env::var("INFLUX_BUCKET") .ok() .unwrap_or_else(|| "sys".into()), @@ -35,6 +37,7 @@ pub async fn push(point: Point) { pub async fn send(config: Option) { if let Some(config) = config { let client = Client::new(config.url, config.token) + .with_org(config.org) .with_bucket(config.bucket) .with_precision(Precision::MS); //let client = client.insert_to_stdout();