diff --git a/Cargo.lock b/Cargo.lock index 8a359b91..8c1be20f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,6 +46,19 @@ dependencies = [ "futures-core", ] +[[package]] +name = "async-compression" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "942c7cd7ae39e91bde4820d74132e9862e62c2f386c3aa90ccf55949f5bad63a" +dependencies = [ + "flate2", + "futures-core", + "memchr", + "pin-project-lite", + "tokio", +] + [[package]] name = "atty" version = "0.2.14" @@ -69,6 +82,12 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" +[[package]] +name = "base64" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" + [[package]] name = "base64" version = "0.13.0" @@ -172,6 +191,16 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "076a6803b0dacd6a88cfe64deba628b01533ff5ef265687e6938280c1afd0a28" +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.3" @@ -262,6 +291,41 @@ dependencies = [ "winapi", ] +[[package]] +name = "darling" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.10.0", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +dependencies = [ + "darling_core", + "quote", + "syn", +] + [[package]] name = "dirs" version = "3.0.2" @@ -319,12 +383,38 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" +[[package]] +name = "dyn-clone" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" + [[package]] name = "either" version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +[[package]] +name = "elasticsearch" +version = "8.5.0-alpha.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40d9bd57d914cc66ce878f098f63ed7b5d5b64c30644a5adb950b008f874a6c6" +dependencies = [ + "base64 0.11.0", + "bytes", + "dyn-clone", + "lazy_static", + "percent-encoding", + "reqwest", + "rustc_version", + "serde", + "serde_json", + "serde_with", + "url", + "void", +] + [[package]] name = "encoding_rs" version = "0.8.28" @@ -476,9 +566,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.4" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f3675cfef6a30c8031cf9e6493ebdc3bb3272a3fea3923c4210d1830e6a472" +checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" dependencies = [ "bytes", "fnv", @@ -533,7 +623,7 @@ checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" dependencies = [ "bytes", "fnv", - "itoa", + "itoa 0.4.7", ] [[package]] @@ -549,9 +639,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.5.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" @@ -561,9 +651,9 @@ checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" [[package]] name = "hyper" -version = "0.14.13" +version = "0.14.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15d1cfb9e4f68655fa04c01f59edb405b6074a0f7118ea881e5026e4a1cd8593" +checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" dependencies = [ "bytes", "futures-channel", @@ -574,7 +664,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa", + "itoa 1.0.4", "pin-project-lite", "socket2", "tokio", @@ -583,6 +673,25 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.2.2" @@ -613,6 +722,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "ipnet" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f88c5561171189e69df9d98bcf18fd5f9558300f7ea7b801eb8a0fd748bd8745" + [[package]] name = "isahc" version = "1.5.0" @@ -647,6 +762,12 @@ version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +[[package]] +name = "itoa" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" + [[package]] name = "js-sys" version = "0.3.49" @@ -662,7 +783,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "748acc444200aa3528dc131a8048e131a9e75a611a52d152e276e99199313d1a" dependencies = [ - "base64", + "base64 0.13.0", "bytes", "chrono", "http", @@ -679,7 +800,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d3c2f8f5cb2611742f8ceb73f23451690ff0d930149eac45fcb63ca86fbd443" dependencies = [ - "base64", + "base64 0.13.0", "chrono", "dirs", "http", @@ -700,9 +821,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.112" +version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" [[package]] name = "libnghttp2-sys" @@ -734,9 +855,9 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" [[package]] name = "lock_api" -version = "0.4.2" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" +checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" dependencies = [ "scopeguard", ] @@ -806,24 +927,32 @@ dependencies = [ [[package]] name = "mio" -version = "0.7.13" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" +checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" dependencies = [ "libc", "log", - "miow", - "ntapi", - "winapi", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.42.0", ] [[package]] -name = "miow" -version = "0.3.7" +name = "native-tls" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" dependencies = [ - "winapi", + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", ] [[package]] @@ -920,27 +1049,25 @@ checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" [[package]] name = "parking_lot" -version = "0.11.1" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ - "instant", "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" dependencies = [ "cfg-if", - "instant", "libc", "redox_syscall", "smallvec", - "winapi", + "windows-sys 0.42.0", ] [[package]] @@ -1014,11 +1141,11 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] @@ -1159,9 +1286,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.5" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] @@ -1202,6 +1329,45 @@ dependencies = [ "winapi", ] +[[package]] +name = "reqwest" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc" +dependencies = [ + "async-compression", + "base64 0.13.0", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "tokio-util", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + [[package]] name = "riemann_client" version = "0.9.0" @@ -1248,7 +1414,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "064fd21ff87c6e87ed4506e68beb42459caa4a0e2eb144932e6776768556980b" dependencies = [ - "base64", + "base64 0.13.0", "log", "ring", "sct", @@ -1261,7 +1427,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09700171bbcc799d113f2c675314d6005c3dc035f3e7307cf3e7fd459ccbe246" dependencies = [ - "base64", + "base64 0.13.0", ] [[package]] @@ -1278,6 +1444,7 @@ dependencies = [ "clap", "colored", "docker-sync", + "elasticsearch", "hostname", "hyper", "k8s-sync", @@ -1294,6 +1461,8 @@ dependencies = [ "sysinfo", "time 0.2.26", "tokio", + "url", + "uuid", "warp10", "windows", ] @@ -1324,6 +1493,29 @@ dependencies = [ "untrusted", ] +[[package]] +name = "security-framework" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "0.9.0" @@ -1375,11 +1567,45 @@ version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" dependencies = [ - "itoa", + "itoa 0.4.7", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa 1.0.4", "ryu", "serde", ] +[[package]] +name = "serde_with" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" +dependencies = [ + "serde", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "serde_yaml" version = "0.8.21" @@ -1432,9 +1658,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "socket2" -version = "0.4.2" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" dependencies = [ "libc", "winapi", @@ -1518,13 +1744,13 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.65" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a1d708c221c5a612956ef9f75b37e454e88d1f7b899fbd3a18d4252012d663" +checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -1631,11 +1857,10 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.11.0" +version = "1.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4efe6fc2395938c8155973d7be49fe8d03a843726e285e100a8a383cc0154ce" +checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439" dependencies = [ - "autocfg", "bytes", "libc", "memchr", @@ -1645,33 +1870,44 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", + "socket2", "tokio-macros", "winapi", ] [[package]] name = "tokio-macros" -version = "1.3.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54473be61f4ebe4efd09cec9bd5d16fa51d70ea0192213d754d2d500457db110" +checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-util" -version = "0.6.8" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d3725d3efa29485e87311c5b699de63cde14b00ed4d256b8318aa30ca452cd" +checksum = "cc463cd8deddc3770d20f9852143d50bf6094e640b485cb2e189a2099085ff45" dependencies = [ "bytes", "futures-core", "futures-sink", - "log", "pin-project-lite", "tokio", + "tracing", ] [[package]] @@ -1738,6 +1974,12 @@ dependencies = [ "matches", ] +[[package]] +name = "unicode-ident" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" + [[package]] name = "unicode-normalization" version = "0.1.17" @@ -1753,12 +1995,6 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" -[[package]] -name = "unicode-xid" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" - [[package]] name = "untrusted" version = "0.7.1" @@ -1775,6 +2011,16 @@ dependencies = [ "idna", "matches", "percent-encoding", + "serde", +] + +[[package]] +name = "uuid" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" +dependencies = [ + "getrandom 0.2.3", ] [[package]] @@ -1795,6 +2041,12 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + [[package]] name = "waker-fn" version = "1.1.0" @@ -1835,6 +2087,12 @@ version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" version = "0.2.72" @@ -1860,6 +2118,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73157efb9af26fb564bb59a009afd1c7c334a44db171d280690d0c3faaec3468" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.72" @@ -1955,7 +2225,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebbc80318ebf919219a113c41deae34aa90198e4a15e93c810a9ea1aaa4c1a78" dependencies = [ - "windows-sys", + "windows-sys 0.27.0", ] [[package]] @@ -1964,43 +2234,109 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cae116ee11e4bce7c0a0425f2b0c866a91d86d209624b7707a7deea52da786" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "windows_aarch64_msvc 0.27.0", + "windows_i686_gnu 0.27.0", + "windows_i686_msvc 0.27.0", + "windows_x86_64_gnu 0.27.0", + "windows_x86_64_msvc 0.27.0", +] + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.0", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + [[package]] name = "windows_aarch64_msvc" version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec7d1649bbab232cde71148c6ef7bbe647f214d2154dd66347fada60de40cda7" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + [[package]] name = "windows_i686_gnu" version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4eb20b59b93fc302839f3b0df3e61de7e9606b44cb54cbeb68d71cf137309fa" +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + [[package]] name = "windows_i686_msvc" version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40331d8ef3e4dcdc8982eb7de16e1f09b86f5384626a56b3a99c2a51b88ff98e" +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + [[package]] name = "windows_x86_64_gnu" version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5937d290e39c3308147d9b877c5fa741c50f4121ea78d2d20c4a138ad365464a" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + [[package]] name = "windows_x86_64_msvc" version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dee1b76aec4e2bead4758a181b663c37af0de7ec56fe6837c10215b8d6a1635f" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + [[package]] name = "yaml-rust" version = "0.4.5" diff --git a/Cargo.toml b/Cargo.toml index a06ace0a..b1b596c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,8 +29,11 @@ colored = "2.0.0" chrono = "0.4.19" docker-sync = { version = "0.1.2", optional = true } k8s-sync = { version = "0.2.3", optional = true } -hyper = { version = "0.14", features = ["full"], optional = true } +hyper = { version = "0.14.23", features = ["full"], optional = true } tokio = { version = "1", features = ["full"], optional = true} +elasticsearch = "8.5.0-alpha.1" +url = { version = "2", features = ["serde"] } +uuid = { version = "1.2.1", features = ["v4"] } [target.'cfg(target_os="linux")'.dependencies] procfs = { version = "0.12.0" } diff --git a/src/exporters/elastic.rs b/src/exporters/elastic.rs new file mode 100644 index 00000000..554b04b3 --- /dev/null +++ b/src/exporters/elastic.rs @@ -0,0 +1,277 @@ +//! # ElasticExporter +//! +//! `ElasticExporter` implementation, exposes metrics to +//! an [ElasticSearch](https://www.elastic.co/fr/elasticsearch/) server. + +use super::get_scaphandre_version; +use crate::sensors::Sensor; +use crate::{exporters::Exporter, sensors::Topology}; +use clap::{Arg, ArgMatches}; +use elasticsearch::{ + auth::Credentials, + http::transport::{SingleNodeConnectionPool, Transport, TransportBuilder}, + CreateParts, Elasticsearch, Error, +}; +use hyper::StatusCode; +use serde::{Deserialize, Serialize}; +use std::thread; +use std::time::Duration; +use url::Url; +use uuid::Uuid; + +/// 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 { + topology: Topology, +} + +impl Exporter for ElasticExporter { + fn run(&mut self, parameters: ArgMatches) { + let client = match new_client( + parameters.value_of("scheme").unwrap(), + parameters.value_of("host").unwrap(), + parameters.value_of("port").unwrap(), + parameters.value_of("cloud_id"), + parameters.value_of("username"), + parameters.value_of("password"), + ) { + Ok(client) => client, + Err(e) => panic!("{}", e), + }; + + if let Err(e) = self.runner(client) { + error!("{}", e) + } + } + + fn get_options() -> Vec> { + 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, + ] + } +} + +const ES_INDEX_NAME: &str = "scaphandre"; + +#[derive(Debug, Serialize, Deserialize, PartialEq)] +pub struct ScaphandreData { + pub scaphandre_version: String, + pub scaphandre_topo_stats_nb: i32, + pub scaphandre_topo_records_nb: i32, + pub scaphandre_topo_procs_nb: i32, + pub scaphandre_cpu_usage_percentage: Option, + pub scaphandre_mem_total_program_size: Option, + pub scaphrandre_mem_resident_set_size: Option, + pub scaphandre_mem_shared_resident_size: Option, +} + +impl ElasticExporter { + /// Instantiates and returns a new ElasticExporter + pub fn new(mut sensor: Box) -> ElasticExporter { + ElasticExporter { + topology: sensor + .get_topology() + .expect("Could'nt generate the Topology."), + } + } + + #[tokio::main] + pub async fn runner(&mut self, client: Elasticsearch) -> Result<(), Error> { + self.ensure_index(&client).await?; + + loop { + self.topology.refresh(); + + match client + .create(CreateParts::IndexId( + ES_INDEX_NAME, + // Looks like rust ES Library do not support autogenerated ids + // for both insert and bulk insert + // https://github.com/elastic/elasticsearch-rs/issues/174 + // forced to create an ID on our side + &Uuid::new_v4().to_string(), + )) + .body(ScaphandreData { + scaphandre_version: get_scaphandre_version(), + scaphandre_topo_stats_nb: self.topology.stat_buffer.len() as i32, + scaphandre_topo_records_nb: self.topology.record_buffer.len() as i32, + scaphandre_topo_procs_nb: self.topology.proc_tracker.procs.len() as i32, + scaphandre_cpu_usage_percentage: self.get_scaphandre_cpu_usage_percentage(), + scaphandre_mem_total_program_size: self.get_scaphandre_mem_total_program_size(), + scaphrandre_mem_resident_set_size: self.get_scaphandre_mem_resident_set_size(), + scaphandre_mem_shared_resident_size: self + .get_scaphandre_mem_shared_resident_size(), + }) + .send() + .await + { + Ok(resp) => println!("create test resp {}", resp.status_code()), + Err(e) => println!("Error: {}", e), + } + + println!("loop tick"); + + // TODO @papey: add custom duration + thread::sleep(Duration::new(2, 0)); + } + } + + fn get_scaphandre_cpu_usage_percentage(&self) -> Option { + self.topology + .get_process_cpu_consumption_percentage(procfs::process::Process::myself().ok()?.pid())? + .value + .parse::() + .ok() + } + + fn get_scaphandre_mem_total_program_size(&self) -> Option { + let statm_value = procfs::process::Process::myself().ok()?.statm().ok()?; + let page_size = procfs::page_size().ok()?; + + Some(statm_value.size * page_size as u64) + } + + fn get_scaphandre_mem_resident_set_size(&self) -> Option { + let statm_value = procfs::process::Process::myself().ok()?.statm().ok()?; + let page_size = procfs::page_size().ok()?; + + Some(statm_value.resident * page_size as u64) + } + + fn get_scaphandre_mem_shared_resident_size(&self) -> Option { + let statm_value = procfs::process::Process::myself().ok()?.statm().ok()?; + let page_size = procfs::page_size().ok()?; + + Some(statm_value.shared * page_size as u64) + } + + async fn ensure_index(&self, client: &Elasticsearch) -> Result<(), Error> { + let index_exist_resp = client + .indices() + .exists(elasticsearch::indices::IndicesExistsParts::Index(&[ + ES_INDEX_NAME, + ])) + .send() + .await?; + + if index_exist_resp.status_code() == StatusCode::OK { + return Ok(()); + } + + let index_create_resp = client + .indices() + .create(elasticsearch::indices::IndicesCreateParts::Index( + ES_INDEX_NAME, + )) + .send() + .await?; + + // WIP + if !index_create_resp.status_code().is_success() { + println!( + "Error while creating index: status_code {}", + index_create_resp.status_code() + ) + } + + Ok(()) + } +} + +/// Inits a new elastic client +fn new_client( + scheme: &str, + host: &str, + port: &str, + cloud_id: Option<&str>, + username: Option<&str>, + password: Option<&str>, +) -> Result { + let credentials = match (username, password) { + (Some(u), Some(p)) => Some(Credentials::Basic(u.to_string(), p.to_string())), + _ => None, + }; + + let transport = match (credentials, cloud_id) { + (Some(credentials), Some(cloud_id)) => Transport::cloud(cloud_id, credentials)?, + (Some(credentials), None) => { + let url = Url::parse(&format_url(scheme, host, port))?; + let conn = SingleNodeConnectionPool::new(url); + TransportBuilder::new(conn).auth(credentials).build()? + } + (None, None) => Transport::single_node(&format_url(scheme, host, port))?, + _ => unreachable!(), + }; + + Ok(Elasticsearch::new(transport)) +} + +/// Format an url to an elastic endpoint +fn format_url<'a>(scheme: &'a str, host: &'a str, port: &'a str) -> String { + format!("{scheme}://{host}:{port}") +} diff --git a/src/exporters/mod.rs b/src/exporters/mod.rs index 8241a645..91d93cc5 100644 --- a/src/exporters/mod.rs +++ b/src/exporters/mod.rs @@ -2,6 +2,7 @@ //! //! `Exporter` is the root for all exporters. It defines the [Exporter] trait //! needed to implement an exporter. +pub mod elastic; pub mod json; #[cfg(feature = "prometheus")] pub mod prometheus; diff --git a/src/lib.rs b/src/lib.rs index b9631b19..94e29377 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,7 @@ pub mod exporters; pub mod sensors; use clap::ArgMatches; use colored::*; +use exporters::elastic::ElasticExporter; #[cfg(feature = "json")] use exporters::json::JSONExporter; #[cfg(feature = "prometheus")] @@ -108,6 +109,13 @@ pub fn run(matches: ArgMatches) { exporter_parameters = prometheus_exporter_parameters.clone(); let mut exporter = PrometheusExporter::new(sensor_boxed); exporter.run(exporter_parameters); + } else if let Some(elastic_exporter_parameters) = matches.subcommand_matches("elastic") { + if header { + scaphandre_header("elastic") + } + exporter_parameters = elastic_exporter_parameters.clone(); + let mut exporter = ElasticExporter::new(sensor_boxed); + exporter.run(exporter_parameters); } else { #[cfg(target_os = "linux")] { @@ -172,6 +180,10 @@ pub fn get_exporters_options() -> HashMap "Riemann exporter sends power consumption metrics to a Riemann server", "qemu" => "Qemu exporter watches all Qemu/KVM virtual machines running on the host and exposes metrics of each of them in a dedicated folder", "warp10" => "Warp10 exporter sends data to a Warp10 host, through HTTP", + "elastic" => "Elastic exporter sends data to an ElasticSearch host", _ => "Unknown exporter", } );