From 895360f6f481c1e3b0d602b29c6a573c3269987d Mon Sep 17 00:00:00 2001 From: Wilfried OLLIVIER Date: Thu, 10 Nov 2022 09:07:56 +0100 Subject: [PATCH] Scaffold options for elastic search cmd --- src/exporters/elastic.rs | 72 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/src/exporters/elastic.rs b/src/exporters/elastic.rs index 4351eea3..671dd09f 100644 --- a/src/exporters/elastic.rs +++ b/src/exporters/elastic.rs @@ -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 { @@ -20,6 +27,67 @@ impl Exporter for ElasticExporter { } fn get_options() -> Vec> { - 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, + ] } }