Skip to content

Commit ddc6772

Browse files
dmakarovmvines
authored andcommitted
Add organization to influxdb configuration
1 parent e9ccb2b commit ddc6772

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
@@ -4313,6 +4313,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
43134313
.required(true)
43144314
.help("Access Token"),
43154315
)
4316+
.arg(
4317+
Arg::with_name("org")
4318+
.value_name("ORG")
4319+
.takes_value(true)
4320+
.required(true)
4321+
.help("Organization"),
4322+
)
43164323
.arg(
43174324
Arg::with_name("bucket")
43184325
.value_name("BUCKET")
@@ -5786,17 +5793,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
57865793
Some(MetricsConfig {
57875794
url,
57885795
token: _,
5796+
org,
57895797
bucket,
57905798
}) => {
57915799
println!("Url: {url}");
57925800
println!("Token: ********");
5801+
println!("Organization: {org}");
57935802
println!("Bucket: {bucket}");
57945803
}
57955804
},
57965805
("set", Some(arg_matches)) => {
57975806
db.set_metrics_config(MetricsConfig {
57985807
url: value_t_or_exit!(arg_matches, "url", String),
57995808
token: value_t_or_exit!(arg_matches, "token", String),
5809+
org: value_t_or_exit!(arg_matches, "org", String),
58005810
bucket: value_t_or_exit!(arg_matches, "bucket", String),
58015811
})?;
58025812
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)