Skip to content

Commit

Permalink
Scaffold options for elastic search cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
papey committed Nov 10, 2022
1 parent b0666ec commit 895360f
Showing 1 changed file with 70 additions and 2 deletions.
72 changes: 70 additions & 2 deletions src/exporters/elastic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@

use crate::exporters::Exporter;
use crate::sensors::Sensor;
use clap::ArgMatches;
use clap::{Arg, ArgMatches};

/// Default url for Elastic endpoint
const DEFAULT_HOST: &str = "localhost";
/// Default port for Elastic endpoint
const DEFAULT_PORT: &str = "9200";
/// Default scheme for Elastic endpoint
const DEFAULT_SCHEME: &str = "http";

/// Exporter that pushes metrics to an ElasticSearch endpoint
pub struct ElasticExporter {
Expand All @@ -20,6 +27,67 @@ impl Exporter for ElasticExporter {
}

fn get_options() -> Vec<clap::Arg<'static, 'static>> {
Vec::new()
let host = Arg::with_name("host")
.default_value(DEFAULT_HOST)
.help("FDQN used to join Elastic host")
.long("host")
.short("h")
.required(false)
.takes_value(true);

let port = Arg::with_name("port")
.default_value(DEFAULT_PORT)
.help("TCP port used to join Elastic host")
.long("port")
.short("p")
.required(false)
.takes_value(true);

let scheme = Arg::with_name("scheme")
.default_value(DEFAULT_SCHEME)
.help("URL scheme used to join Elastic host")
.long("scheme")
.short("s")
.required(false)
.takes_value(true);

let cloud_id = Arg::with_name("cloud_id")
.help("cloud id for Elasticsearch deployment in Elastic Cloud")
.long("cloudid")
.short("c")
.required(false)
.takes_value(true);

let username = Arg::with_name("username")
.help("basic auth username")
.long("username")
.short("U")
.required(false)
.takes_value(true);

let password = Arg::with_name("password")
.help("basic auth password")
.long("password")
.short("P")
.required(false)
.takes_value(true);

let qemu = Arg::with_name("qemu")
.help("Tells scaphandre it is running on a Qemu hypervisor.")
.long("qemu")
.short("q")
.required(false)
.takes_value(false);

let containers = Arg::with_name("containers")
.help("Monitor and apply labels for processes running as containers")
.long("containers")
.short("C")
.required(false)
.takes_value(false);

vec![
host, port, scheme, cloud_id, username, password, qemu, containers,
]
}
}

0 comments on commit 895360f

Please sign in to comment.