Skip to content

Commit 66f439a

Browse files
committed
Add organization to influxdb configuration
1 parent 1e891c4 commit 66f439a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/main.rs

+10
Original file line numberDiff line numberDiff line change
@@ -4497,6 +4497,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
44974497
.required(true)
44984498
.help("Access Token"),
44994499
)
4500+
.arg(
4501+
Arg::with_name("org")
4502+
.value_name("ORG")
4503+
.takes_value(true)
4504+
.required(true)
4505+
.help("Organization"),
4506+
)
45004507
.arg(
45014508
Arg::with_name("bucket")
45024509
.value_name("BUCKET")
@@ -6000,17 +6007,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
60006007
Some(MetricsConfig {
60016008
url,
60026009
token: _,
6010+
org,
60036011
bucket,
60046012
}) => {
60056013
println!("Url: {url}");
60066014
println!("Token: ********");
6015+
println!("Organization: {org}");
60076016
println!("Bucket: {bucket}");
60086017
}
60096018
},
60106019
("set", Some(arg_matches)) => {
60116020
db.set_metrics_config(MetricsConfig {
60126021
url: value_t_or_exit!(arg_matches, "url", String),
60136022
token: value_t_or_exit!(arg_matches, "token", String),
6023+
org: value_t_or_exit!(arg_matches, "org", String),
60146024
bucket: value_t_or_exit!(arg_matches, "bucket", String),
60156025
})?;
60166026
println!("InfluxDb configuration set");

src/metrics.rs

+3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ lazy_static::lazy_static! {
1515
pub struct MetricsConfig {
1616
pub url: String,
1717
pub token: String,
18+
pub org: String,
1819
pub bucket: String,
1920
}
2021

2122
pub fn env_config() -> Option<MetricsConfig> {
2223
Some(MetricsConfig {
2324
url: env::var("INFLUX_URL").ok()?,
2425
token: env::var("INFLUX_API_TOKEN").ok()?,
26+
org: env::var("INFLUX_ORG").ok()?,
2527
bucket: env::var("INFLUX_BUCKET")
2628
.ok()
2729
.unwrap_or_else(|| "sys".into()),
@@ -35,6 +37,7 @@ pub async fn push(point: Point) {
3537
pub async fn send(config: Option<MetricsConfig>) {
3638
if let Some(config) = config {
3739
let client = Client::new(config.url, config.token)
40+
.with_org(config.org)
3841
.with_bucket(config.bucket)
3942
.with_precision(Precision::MS);
4043
//let client = client.insert_to_stdout();

0 commit comments

Comments
 (0)