55
66use crate :: exporters:: Exporter ;
77use crate :: sensors:: Sensor ;
8- use clap:: ArgMatches ;
8+ use clap:: { Arg , ArgMatches } ;
9+
10+ /// Default url for Elastic endpoint
11+ const DEFAULT_HOST : & str = "localhost" ;
12+ /// Default port for Elastic endpoint
13+ const DEFAULT_PORT : & str = "9200" ;
14+ /// Default scheme for Elastic endpoint
15+ const DEFAULT_SCHEME : & str = "http" ;
916
1017/// Exporter that pushes metrics to an ElasticSearch endpoint
1118pub struct ElasticExporter {
@@ -20,6 +27,67 @@ impl Exporter for ElasticExporter {
2027 }
2128
2229 fn get_options ( ) -> Vec < clap:: Arg < ' static , ' static > > {
23- Vec :: new ( )
30+ let host = Arg :: with_name ( "host" )
31+ . default_value ( DEFAULT_HOST )
32+ . help ( "FDQN used to join Elastic host" )
33+ . long ( "host" )
34+ . short ( "h" )
35+ . required ( false )
36+ . takes_value ( true ) ;
37+
38+ let port = Arg :: with_name ( "port" )
39+ . default_value ( DEFAULT_PORT )
40+ . help ( "TCP port used to join Elastic host" )
41+ . long ( "port" )
42+ . short ( "p" )
43+ . required ( false )
44+ . takes_value ( true ) ;
45+
46+ let scheme = Arg :: with_name ( "scheme" )
47+ . default_value ( DEFAULT_SCHEME )
48+ . help ( "URL scheme used to join Elastic host" )
49+ . long ( "scheme" )
50+ . short ( "s" )
51+ . required ( false )
52+ . takes_value ( true ) ;
53+
54+ let cloud_id = Arg :: with_name ( "cloud_id" )
55+ . help ( "Cloud id for Elasticsearch deployment in Elastic Cloud" )
56+ . long ( "cloudid" )
57+ . short ( "c" )
58+ . required ( false )
59+ . takes_value ( true ) ;
60+
61+ let username = Arg :: with_name ( "username" )
62+ . help ( "Basic auth username" )
63+ . long ( "username" )
64+ . short ( "U" )
65+ . required ( false )
66+ . takes_value ( true ) ;
67+
68+ let password = Arg :: with_name ( "password" )
69+ . help ( "Basic auth password" )
70+ . long ( "password" )
71+ . short ( "P" )
72+ . required ( false )
73+ . takes_value ( true ) ;
74+
75+ let qemu = Arg :: with_name ( "qemu" )
76+ . help ( "Tells scaphandre it is running on a Qemu hypervisor." )
77+ . long ( "qemu" )
78+ . short ( "q" )
79+ . required ( false )
80+ . takes_value ( false ) ;
81+
82+ let containers = Arg :: with_name ( "containers" )
83+ . help ( "Monitor and apply labels for processes running as containers" )
84+ . long ( "containers" )
85+ . short ( "C" )
86+ . required ( false )
87+ . takes_value ( false ) ;
88+
89+ vec ! [
90+ host, port, scheme, cloud_id, username, password, qemu, containers,
91+ ]
2492 }
2593}
0 commit comments