From e82ed07e5bf74e59c57488fcb60f1161dea2d4d0 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Mon, 27 Feb 2023 19:24:57 +0800 Subject: [PATCH 01/34] feat: add greptimedb sink (wip) --- Cargo.lock | 1908 ++++++++++++++++++++++++++++++-- Cargo.toml | 5 + src/sinks/greptimedb/client.rs | 74 ++ src/sinks/greptimedb/mod.rs | 59 + src/sinks/mod.rs | 2 + 5 files changed, 1979 insertions(+), 69 deletions(-) create mode 100644 src/sinks/greptimedb/client.rs create mode 100644 src/sinks/greptimedb/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 2a39ea6ebd573..bd3922fd5ddbc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,6 +18,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b5ace29ee3216de37c0546865ad08edef58b0f9e76838ed8959a84a990e58c5" +[[package]] +name = "addr2line" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" @@ -59,6 +68,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf6ccdb167abbf410dcb915cabd428929d7f6a04980b54a11f26a39f1c7f7107" dependencies = [ "cfg-if", + "const-random", "getrandom 0.2.10", "once_cell", "version_check", @@ -82,6 +92,21 @@ dependencies = [ "memchr", ] +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +dependencies = [ + "alloc-no-stdlib", +] + [[package]] name = "amq-protocol" version = "7.0.1" @@ -209,6 +234,22 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "api" +version = "0.2.0" +dependencies = [ + "arrow-flight", + "common-base", + "common-error", + "common-time", + "datatypes", + "greptime-proto", + "prost", + "snafu", + "tonic", + "tonic-build", +] + [[package]] name = "approx" version = "0.5.1" @@ -255,6 +296,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + [[package]] name = "arrayvec" version = "0.5.2" @@ -267,6 +314,239 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +[[package]] +name = "arrow" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aea9fcb25bbb70f7f922f95b99ca29c1013dab47f6df61a6f24861842dd7f2e" +dependencies = [ + "ahash 0.8.2", + "arrow-arith", + "arrow-array", + "arrow-buffer", + "arrow-cast", + "arrow-csv", + "arrow-data", + "arrow-ipc", + "arrow-json", + "arrow-ord", + "arrow-row", + "arrow-schema", + "arrow-select", + "arrow-string", +] + +[[package]] +name = "arrow-arith" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d967b42f7b12c91fd78acd396b20c2973b184c8866846674abbb00c963e93ab" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "chrono", + "half 2.3.0", + "num", +] + +[[package]] +name = "arrow-array" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190f208ee7aa0f3596fa0098d42911dec5e123ca88c002a08b24877ad14c71e" +dependencies = [ + "ahash 0.8.2", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "chrono", + "chrono-tz", + "half 2.3.0", + "hashbrown 0.13.2", + "num", +] + +[[package]] +name = "arrow-buffer" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d33c733c5b6c44a0fc526f29c09546e04eb56772a7a21e48e602f368be381f6" +dependencies = [ + "half 2.3.0", + "num", +] + +[[package]] +name = "arrow-cast" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abd349520b6a1ed4924ae2afc9d23330a3044319e4ec3d5b124c09e4d440ae87" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "arrow-select", + "chrono", + "comfy-table", + "lexical-core", + "num", +] + +[[package]] +name = "arrow-csv" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c80af3c3e290a2a7e1cc518f1471dff331878cb4af9a5b088bf030b89debf649" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-cast", + "arrow-data", + "arrow-schema", + "chrono", + "csv", + "csv-core", + "lazy_static", + "lexical-core", + "regex", +] + +[[package]] +name = "arrow-data" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c8361947aaa96d331da9df3f7a08bdd8ab805a449994c97f5c4d24c4b7e2cf" +dependencies = [ + "arrow-buffer", + "arrow-schema", + "half 2.3.0", + "num", +] + +[[package]] +name = "arrow-flight" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd1fc687f3e4ffe91ccb7f2ffb06143ff97029448d427a9641006242bcbd0c24" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-cast", + "arrow-ipc", + "arrow-schema", + "base64 0.21.2", + "bytes 1.4.0", + "futures 0.3.28", + "paste", + "prost", + "tokio", + "tonic", +] + +[[package]] +name = "arrow-ipc" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a46ee000b9fbd1e8db6e8b26acb8c760838512b39d8c9f9d73892cb55351d50" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-cast", + "arrow-data", + "arrow-schema", + "flatbuffers", +] + +[[package]] +name = "arrow-json" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bf2366607be867ced681ad7f272371a5cf1fc2941328eef7b4fee14565166fb" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-cast", + "arrow-data", + "arrow-schema", + "chrono", + "half 2.3.0", + "indexmap", + "lexical-core", + "num", + "serde", + "serde_json", +] + +[[package]] +name = "arrow-ord" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "304069901c867200e21ec868ae7521165875470ef2f1f6d58f979a443d63997e" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "arrow-select", + "half 2.3.0", + "num", +] + +[[package]] +name = "arrow-row" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d57fe8ceef3392fdd493269d8a2d589de17bafce151aacbffbddac7a57f441a" +dependencies = [ + "ahash 0.8.2", + "arrow-array", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "half 2.3.0", + "hashbrown 0.13.2", +] + +[[package]] +name = "arrow-schema" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a16b88a93ac8350f0200b1cd336a1f887315925b8dd7aa145a37b8bdbd8497a4" +dependencies = [ + "serde", +] + +[[package]] +name = "arrow-select" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98e8a4d6ca37d5212439b24caad4d80743fcbb706706200dd174bb98e68fe9d8" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "num", +] + +[[package]] +name = "arrow-string" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbb594efa397eb6a546f42b1f8df3d242ea84dbfda5232e06035dc2b2e2c8459" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "arrow-select", + "regex", + "regex-syntax 0.6.29", +] + [[package]] name = "ascii" version = "0.9.3" @@ -337,11 +617,16 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "942c7cd7ae39e91bde4820d74132e9862e62c2f386c3aa90ccf55949f5bad63a" dependencies = [ + "bzip2", "flate2", "futures-core", + "futures-io", "memchr", "pin-project-lite", "tokio", + "xz2", + "zstd 0.11.2+zstd.1.5.2", + "zstd-safe 5.0.2+zstd.1.5.2", ] [[package]] @@ -1358,6 +1643,21 @@ dependencies = [ "tokio", ] +[[package]] +name = "backtrace" +version = "0.3.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide 0.6.2", + "object", + "rustc-demangle", +] + [[package]] name = "base16" version = "0.2.1" @@ -1462,6 +1762,29 @@ dependencies = [ "wyz", ] +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "blake3" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "729b71f35bd3fa1a4c86b85d32c8b9069ea7fe14f7a53cfabb65f62d4265b888" +dependencies = [ + "arrayref", + "arrayvec 0.7.2", + "cc", + "cfg-if", + "constant_time_eq", + "digest 0.10.7", +] + [[package]] name = "block-buffer" version = "0.9.0" @@ -1605,6 +1928,27 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "brotli" +version = "3.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "2.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + [[package]] name = "bson" version = "2.6.1" @@ -1723,6 +2067,27 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38fcc2979eff34a4b84e1cf9a1e3da42a7d44b3b690a40cdcb23e3d556cfb2e5" +[[package]] +name = "bzip2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" +dependencies = [ + "bzip2-sys", + "libc", +] + +[[package]] +name = "bzip2-sys" +version = "0.1.11+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + [[package]] name = "cache-padded" version = "1.2.0" @@ -1887,7 +2252,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213030a2b5a4e0c0892b6652260cf6ccac84827b83a85a534e178e3906c4cf1b" dependencies = [ "ciborium-io", - "half", + "half 1.8.2", ] [[package]] @@ -1990,6 +2355,33 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" +[[package]] +name = "client" +version = "0.2.0" +dependencies = [ + "api", + "arrow-flight", + "async-stream", + "common-base", + "common-catalog", + "common-error", + "common-grpc", + "common-grpc-expr", + "common-query", + "common-recordbatch", + "common-telemetry", + "common-time", + "datafusion", + "datatypes", + "enum_dispatch", + "futures-util", + "parking_lot", + "prost", + "rand 0.8.5", + "snafu", + "tonic", +] + [[package]] name = "clipboard-win" version = "4.4.2" @@ -2094,68 +2486,271 @@ dependencies = [ ] [[package]] -name = "concurrent-queue" -version = "1.2.4" +name = "comfy-table" +version = "6.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c" +checksum = "7e959d788268e3bf9d35ace83e81b124190378e4c91c9067524675e33394b8ba" dependencies = [ - "cache-padded", + "strum", + "strum_macros", + "unicode-width", ] [[package]] -name = "concurrent-queue" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7bef69dc86e3c610e4e7aed41035e2a7ed12e72dd7530f61327a6579a4390b" +name = "common-base" +version = "0.2.0" dependencies = [ - "crossbeam-utils", + "anymap", + "bitvec", + "bytes 1.4.0", + "common-error", + "paste", + "serde", + "snafu", ] [[package]] -name = "confy" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e37668cb35145dcfaa1931a5f37fde375eeae8068b4c0d2f289da28a270b2d2c" +name = "common-catalog" +version = "0.2.0" dependencies = [ - "directories 4.0.1", + "async-trait", + "common-error", + "common-telemetry", + "datatypes", + "lazy_static", + "regex", "serde", - "thiserror", - "toml 0.5.11", + "serde_json", + "snafu", ] [[package]] -name = "console" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c050367d967ced717c04b65d8c619d863ef9292ce0c5760028655a2fb298718c" +name = "common-error" +version = "0.2.0" dependencies = [ - "encode_unicode 0.3.6", - "lazy_static", - "libc", - "terminal_size 0.1.17", - "unicode-width", - "winapi", + "snafu", + "strum", ] [[package]] -name = "console-api" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2895653b4d9f1538a83970077cb01dfc77a4810524e51a110944688e916b18e" +name = "common-function-macro" +version = "0.2.0" dependencies = [ - "prost", - "prost-types", - "tonic", - "tracing-core 0.1.30", + "backtrace", + "common-telemetry", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 1.0.109", ] [[package]] -name = "console-subscriber" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ab2224a0311582eb03adba4caaf18644f7b1f10a760803a803b9b605187fc7" +name = "common-grpc" +version = "0.2.0" dependencies = [ - "console-api", + "api", + "arrow-flight", + "async-trait", + "backtrace", + "common-base", + "common-error", + "common-function-macro", + "common-query", + "common-recordbatch", + "common-runtime", + "common-telemetry", + "dashmap", + "datafusion", + "datatypes", + "flatbuffers", + "futures 0.3.28", + "prost", + "snafu", + "tokio", + "tonic", + "tower", +] + +[[package]] +name = "common-grpc-expr" +version = "0.2.0" +dependencies = [ + "api", + "async-trait", + "common-base", + "common-catalog", + "common-error", + "common-grpc", + "common-query", + "common-telemetry", + "common-time", + "datatypes", + "snafu", + "table", +] + +[[package]] +name = "common-procedure" +version = "0.2.0" +dependencies = [ + "async-stream", + "async-trait", + "backon", + "common-error", + "common-runtime", + "common-telemetry", + "futures 0.3.28", + "object-store", + "serde", + "serde_json", + "smallvec", + "snafu", + "tokio", + "uuid", +] + +[[package]] +name = "common-query" +version = "0.2.0" +dependencies = [ + "async-trait", + "common-error", + "common-recordbatch", + "common-time", + "datafusion", + "datafusion-common", + "datafusion-expr", + "datatypes", + "snafu", + "statrs", +] + +[[package]] +name = "common-recordbatch" +version = "0.2.0" +dependencies = [ + "common-error", + "datafusion", + "datafusion-common", + "datatypes", + "futures 0.3.28", + "paste", + "serde", + "snafu", +] + +[[package]] +name = "common-runtime" +version = "0.2.0" +dependencies = [ + "async-trait", + "common-error", + "common-telemetry", + "metrics 0.20.1", + "once_cell", + "paste", + "snafu", + "tokio", + "tokio-util", +] + +[[package]] +name = "common-telemetry" +version = "0.2.0" +dependencies = [ + "backtrace", + "common-error", + "metrics 0.20.1", + "metrics-exporter-prometheus", + "metrics-util 0.14.0", + "once_cell", + "opentelemetry", + "opentelemetry-jaeger", + "serde", + "tokio", + "tracing 0.1.37", + "tracing-appender", + "tracing-bunyan-formatter", + "tracing-futures 0.2.5", + "tracing-log", + "tracing-opentelemetry", + "tracing-subscriber", +] + +[[package]] +name = "common-time" +version = "0.2.0" +dependencies = [ + "chrono", + "chrono-tz", + "common-error", + "serde", + "serde_json", + "snafu", +] + +[[package]] +name = "concurrent-queue" +version = "1.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c" +dependencies = [ + "cache-padded", +] + +[[package]] +name = "concurrent-queue" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd7bef69dc86e3c610e4e7aed41035e2a7ed12e72dd7530f61327a6579a4390b" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "confy" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e37668cb35145dcfaa1931a5f37fde375eeae8068b4c0d2f289da28a270b2d2c" +dependencies = [ + "directories 4.0.1", + "serde", + "thiserror", + "toml 0.5.11", +] + +[[package]] +name = "console" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c050367d967ced717c04b65d8c619d863ef9292ce0c5760028655a2fb298718c" +dependencies = [ + "encode_unicode 0.3.6", + "lazy_static", + "libc", + "terminal_size 0.1.17", + "unicode-width", + "winapi", +] + +[[package]] +name = "console-api" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2895653b4d9f1538a83970077cb01dfc77a4810524e51a110944688e916b18e" +dependencies = [ + "prost", + "prost-types", + "tonic", + "tracing-core 0.1.30", +] + +[[package]] +name = "console-subscriber" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57ab2224a0311582eb03adba4caaf18644f7b1f10a760803a803b9b605187fc7" +dependencies = [ + "console-api", "crossbeam-channel", "crossbeam-utils", "futures 0.3.28", @@ -2179,6 +2774,40 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" +[[package]] +name = "const-oid" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" + +[[package]] +name = "const-random" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368a7a772ead6ce7e1de82bfb04c485f3db8ec744f72925af5735e29a22cc18e" +dependencies = [ + "const-random-macro", + "proc-macro-hack", +] + +[[package]] +name = "const-random-macro" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d7d6ab3c3a2282db210df5f02c4dab6e0a7057af0fb7ebd4070f30fe05c0ddb" +dependencies = [ + "getrandom 0.2.10", + "once_cell", + "proc-macro-hack", + "tiny-keccak", +] + +[[package]] +name = "constant_time_eq" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6" + [[package]] name = "convert_case" version = "0.4.0" @@ -2595,6 +3224,191 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d7439c3735f405729d52c3fbbe4de140eaf938a1fe47d227c27f8254d4302a5" +[[package]] +name = "datafusion" +version = "22.0.0" +source = "git+https://github.com/waynexia/arrow-datafusion.git?rev=5337c86120de8193406b59be7612484796a46294#5337c86120de8193406b59be7612484796a46294" +dependencies = [ + "ahash 0.8.2", + "arrow", + "arrow-array", + "arrow-schema", + "async-compression 0.3.15", + "async-trait", + "bytes 1.4.0", + "bzip2", + "chrono", + "dashmap", + "datafusion-common", + "datafusion-execution", + "datafusion-expr", + "datafusion-optimizer", + "datafusion-physical-expr", + "datafusion-row", + "datafusion-sql", + "flate2", + "futures 0.3.28", + "glob", + "hashbrown 0.13.2", + "indexmap", + "itertools", + "lazy_static", + "log", + "num_cpus", + "object_store", + "parking_lot", + "parquet", + "percent-encoding", + "pin-project-lite", + "rand 0.8.5", + "smallvec", + "sqlparser", + "tempfile", + "tokio", + "tokio-stream", + "tokio-util", + "url", + "uuid", + "xz2", + "zstd 0.12.3+zstd.1.5.2", +] + +[[package]] +name = "datafusion-common" +version = "22.0.0" +source = "git+https://github.com/waynexia/arrow-datafusion.git?rev=5337c86120de8193406b59be7612484796a46294#5337c86120de8193406b59be7612484796a46294" +dependencies = [ + "arrow", + "arrow-array", + "chrono", + "num_cpus", + "object_store", + "parquet", + "sqlparser", +] + +[[package]] +name = "datafusion-execution" +version = "22.0.0" +source = "git+https://github.com/waynexia/arrow-datafusion.git?rev=5337c86120de8193406b59be7612484796a46294#5337c86120de8193406b59be7612484796a46294" +dependencies = [ + "dashmap", + "datafusion-common", + "datafusion-expr", + "hashbrown 0.13.2", + "log", + "object_store", + "parking_lot", + "rand 0.8.5", + "tempfile", + "url", +] + +[[package]] +name = "datafusion-expr" +version = "22.0.0" +source = "git+https://github.com/waynexia/arrow-datafusion.git?rev=5337c86120de8193406b59be7612484796a46294#5337c86120de8193406b59be7612484796a46294" +dependencies = [ + "ahash 0.8.2", + "arrow", + "datafusion-common", + "sqlparser", +] + +[[package]] +name = "datafusion-optimizer" +version = "22.0.0" +source = "git+https://github.com/waynexia/arrow-datafusion.git?rev=5337c86120de8193406b59be7612484796a46294#5337c86120de8193406b59be7612484796a46294" +dependencies = [ + "arrow", + "async-trait", + "chrono", + "datafusion-common", + "datafusion-expr", + "datafusion-physical-expr", + "hashbrown 0.13.2", + "itertools", + "log", + "regex-syntax 0.6.29", +] + +[[package]] +name = "datafusion-physical-expr" +version = "22.0.0" +source = "git+https://github.com/waynexia/arrow-datafusion.git?rev=5337c86120de8193406b59be7612484796a46294#5337c86120de8193406b59be7612484796a46294" +dependencies = [ + "ahash 0.8.2", + "arrow", + "arrow-array", + "arrow-buffer", + "arrow-schema", + "blake2", + "blake3", + "chrono", + "datafusion-common", + "datafusion-expr", + "datafusion-row", + "half 2.3.0", + "hashbrown 0.13.2", + "indexmap", + "itertools", + "lazy_static", + "md-5", + "paste", + "petgraph", + "rand 0.8.5", + "regex", + "sha2 0.10.7", + "unicode-segmentation", + "uuid", +] + +[[package]] +name = "datafusion-row" +version = "22.0.0" +source = "git+https://github.com/waynexia/arrow-datafusion.git?rev=5337c86120de8193406b59be7612484796a46294#5337c86120de8193406b59be7612484796a46294" +dependencies = [ + "arrow", + "datafusion-common", + "paste", + "rand 0.8.5", +] + +[[package]] +name = "datafusion-sql" +version = "22.0.0" +source = "git+https://github.com/waynexia/arrow-datafusion.git?rev=5337c86120de8193406b59be7612484796a46294#5337c86120de8193406b59be7612484796a46294" +dependencies = [ + "arrow", + "arrow-schema", + "datafusion-common", + "datafusion-expr", + "log", + "sqlparser", +] + +[[package]] +name = "datatypes" +version = "0.2.0" +dependencies = [ + "arrow", + "arrow-array", + "arrow-schema", + "common-base", + "common-error", + "common-telemetry", + "common-time", + "datafusion-common", + "enum_dispatch", + "num", + "num-traits", + "ordered-float 3.7.0", + "paste", + "serde", + "serde_json", + "snafu", +] + [[package]] name = "db-key" version = "0.0.5" @@ -2632,7 +3446,18 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" dependencies = [ - "const-oid", + "const-oid 0.6.2", +] + +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid 0.9.2", + "pem-rfc7468 0.6.0", + "zeroize", ] [[package]] @@ -2657,6 +3482,37 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_builder" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07adf7be193b71cc36b193d0f5fe60b918a3a9db4dad0449f57bcfd519704a3" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4" +dependencies = [ + "darling 0.14.2", + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 1.0.109", +] + +[[package]] +name = "derive_builder_macro" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68" +dependencies = [ + "derive_builder_core", + "syn 1.0.109", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -2698,6 +3554,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.3", + "const-oid 0.9.2", "crypto-common", "subtle", ] @@ -2773,6 +3630,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "dlv-list" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" + [[package]] name = "dns-lookup" version = "1.0.8" @@ -2845,7 +3708,7 @@ version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ - "signature", + "signature 1.6.4", ] [[package]] @@ -3187,6 +4050,16 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda653ca797810c02f7ca4b804b40b8b95ae046eb989d356bce17919a8c25499" +[[package]] +name = "flatbuffers" +version = "23.5.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dac53e22462d78c16d64a1cd22371b54cc3fe94aa15e7886a2fa6e5d1ab8640" +dependencies = [ + "bitflags 1.3.2", + "rustc_version 0.4.0", +] + [[package]] name = "flate2" version = "1.0.26" @@ -3194,7 +4067,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.7.1", ] [[package]] @@ -3404,6 +4277,16 @@ dependencies = [ "version_check", ] +[[package]] +name = "gethostname" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "getrandom" version = "0.1.16" @@ -3439,6 +4322,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "gimli" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" + [[package]] name = "glob" version = "0.3.1" @@ -3552,6 +4441,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "greptime-proto" +version = "0.1.0" +source = "git+https://github.com/GreptimeTeam/greptime-proto.git?rev=ff0a47b6462bf196cbcd01b589c5dddfa6bfbc45#ff0a47b6462bf196cbcd01b589c5dddfa6bfbc45" +dependencies = [ + "prost", + "serde", + "serde_json", + "tonic", + "tonic-build", +] + [[package]] name = "grok" version = "2.0.0" @@ -3587,6 +4488,17 @@ version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +[[package]] +name = "half" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9906a89f1724975a455316ae0554ceaa45ad83bb336f1125a87bfbdb9197cfa0" +dependencies = [ + "cfg-if", + "crunchy", + "num-traits", +] + [[package]] name = "hash_hasher" version = "2.0.3" @@ -3828,6 +4740,15 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "hostname" version = "0.3.1" @@ -3906,6 +4827,16 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +[[package]] +name = "humantime-serde" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c" +dependencies = [ + "humantime", + "serde", +] + [[package]] name = "hyper" version = "0.14.26" @@ -4102,7 +5033,7 @@ dependencies = [ "console", "instant", "number_prefix", - "portable-atomic", + "portable-atomic 1.3.1", "unicode-segmentation", "unicode-width", ] @@ -4164,6 +5095,16 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "integer-encoding" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bb03732005da905c88227371639bf1ad885cc712789c011c31c5fb3ab3ccf02" +dependencies = [ + "async-trait", + "futures-util", +] + [[package]] name = "inventory" version = "0.3.6" @@ -4328,6 +5269,20 @@ dependencies = [ "serde_json", ] +[[package]] +name = "jsonwebtoken" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" +dependencies = [ + "base64 0.21.2", + "pem", + "ring", + "serde", + "serde_json", + "simple_asn1", +] + [[package]] name = "k8s-e2e-tests" version = "0.1.0" @@ -4569,6 +5524,73 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin 0.5.2", +] + +[[package]] +name = "lexical-core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cde5de06e8d4c2faabc400238f9ae1c74d5412d03a7bd067645ccbc47070e46" +dependencies = [ + "lexical-parse-float", + "lexical-parse-integer", + "lexical-util", + "lexical-write-float", + "lexical-write-integer", +] + +[[package]] +name = "lexical-parse-float" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683b3a5ebd0130b8fb52ba0bdc718cc56815b6a097e28ae5a6997d0ad17dc05f" +dependencies = [ + "lexical-parse-integer", + "lexical-util", + "static_assertions", +] + +[[package]] +name = "lexical-parse-integer" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d0994485ed0c312f6d965766754ea177d07f9c00c9b82a5ee62ed5b47945ee9" +dependencies = [ + "lexical-util", + "static_assertions", +] + +[[package]] +name = "lexical-util" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5255b9ff16ff898710eb9eb63cb39248ea8a5bb036bea8085b1a767ff6c4e3fc" +dependencies = [ + "static_assertions", +] + +[[package]] +name = "lexical-write-float" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accabaa1c4581f05a3923d1b4cfd124c329352288b7b9da09e766b0668116862" +dependencies = [ + "lexical-util", + "lexical-write-integer", + "static_assertions", +] + +[[package]] +name = "lexical-write-integer" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1b6f3d1f4422866b68192d62f77bc5c700bee84f3069f2469d7bc8c77852446" +dependencies = [ + "lexical-util", + "static_assertions", +] [[package]] name = "libc" @@ -4701,6 +5723,15 @@ dependencies = [ "snap", ] +[[package]] +name = "lru" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e7d46de488603ffdd5f30afbc64fbba2378214a2c3a2fb83abf3d33126df17" +dependencies = [ + "hashbrown 0.13.2", +] + [[package]] name = "lru" version = "0.10.0" @@ -4754,6 +5785,17 @@ dependencies = [ "libc", ] +[[package]] +name = "lzma-sys" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fda04ab3764e6cde78b9974eec4f779acaba7c4e84b36eca3cf77c581b85d27" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + [[package]] name = "macaddr" version = "1.0.1" @@ -4883,6 +5925,17 @@ dependencies = [ "autocfg", ] +[[package]] +name = "metrics" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b9b8653cec6897f73b519a43fba5ee3d50f62fe9af80b428accdcc093b4a849" +dependencies = [ + "ahash 0.7.6", + "metrics-macros 0.6.0", + "portable-atomic 0.3.20", +] + [[package]] name = "metrics" version = "0.21.0" @@ -4890,8 +5943,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa8ebbd1a9e57bbab77b9facae7f5136aea44c356943bf9a198f647da64285d6" dependencies = [ "ahash 0.8.2", - "metrics-macros", - "portable-atomic", + "metrics-macros 0.7.0", + "portable-atomic 1.3.1", +] + +[[package]] +name = "metrics-exporter-prometheus" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8603921e1f54ef386189335f288441af761e0fc61bcb552168d9cedfe63ebc70" +dependencies = [ + "indexmap", + "metrics 0.20.1", + "metrics-util 0.14.0", + "parking_lot", + "portable-atomic 0.3.20", + "quanta 0.10.1", + "thiserror", +] + +[[package]] +name = "metrics-macros" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "731f8ecebd9f3a4aa847dfe75455e4757a45da40a7793d2f0b1f9b6ed18b23f3" +dependencies = [ + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 1.0.109", ] [[package]] @@ -4913,14 +5992,35 @@ checksum = "8fec95d1490f2b7e2d49462f9d75aa4fed52cc21e0b40aefc5987c6f404d40a2" dependencies = [ "itoa", "lockfree-object-pool", - "metrics", - "metrics-util", + "metrics 0.21.0", + "metrics-util 0.15.0", "once_cell", "tracing 0.1.37", "tracing-core 0.1.30", "tracing-subscriber", ] +[[package]] +name = "metrics-util" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d24dc2dbae22bff6f1f9326ffce828c9f07ef9cc1e8002e5279f845432a30a" +dependencies = [ + "aho-corasick 0.7.20", + "crossbeam-epoch", + "crossbeam-utils", + "hashbrown 0.12.3", + "indexmap", + "metrics 0.20.1", + "num_cpus", + "ordered-float 2.10.0", + "parking_lot", + "portable-atomic 0.3.20", + "quanta 0.10.1", + "radix_trie", + "sketches-ddsketch", +] + [[package]] name = "metrics-util" version = "0.15.0" @@ -4932,10 +6032,10 @@ dependencies = [ "crossbeam-utils", "hashbrown 0.13.2", "indexmap", - "metrics", + "metrics 0.21.0", "num_cpus", "ordered-float 3.7.0", - "quanta", + "quanta 0.11.1", "radix_trie", "sketches-ddsketch", ] @@ -4962,6 +6062,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +[[package]] +name = "miniz_oxide" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +dependencies = [ + "adler", +] + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -5076,6 +6185,35 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" +[[package]] +name = "nalgebra" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d506eb7e08d6329505faa8a3a00a5dcc6de9f76e0c77e4b75763ae3c770831ff" +dependencies = [ + "approx", + "matrixmultiply", + "nalgebra-macros", + "num-complex", + "num-rational 0.4.1", + "num-traits", + "rand 0.8.5", + "rand_distr", + "simba", + "typenum", +] + +[[package]] +name = "nalgebra-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01fcc0b8149b4632adc89ac3b7b31a12fb6099a0317a4eb2ebff574ef7de7218" +dependencies = [ + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 1.0.109", +] + [[package]] name = "native-tls" version = "0.2.11" @@ -5320,6 +6458,20 @@ dependencies = [ "rand 0.8.5", ] +[[package]] +name = "num" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational 0.4.1", + "num-traits", +] + [[package]] name = "num-bigint" version = "0.4.3" @@ -5331,6 +6483,23 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-bigint-dig" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2399c9463abc5f909349d8aa9ba080e0b88b3ce2885389b60b993f39b1a56905" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand 0.8.5", + "smallvec", + "zeroize", +] + [[package]] name = "num-complex" version = "0.4.2" @@ -5361,6 +6530,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-iter" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-rational" version = "0.3.2" @@ -5372,6 +6552,18 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.15" @@ -5478,6 +6670,50 @@ dependencies = [ "malloc_buf", ] +[[package]] +name = "object" +version = "0.30.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" +dependencies = [ + "memchr", +] + +[[package]] +name = "object-store" +version = "0.2.0" +dependencies = [ + "async-trait", + "bytes 1.4.0", + "futures 0.3.28", + "lru 0.9.0", + "md5", + "metrics 0.20.1", + "opendal 0.33.3", + "pin-project", + "tokio", +] + +[[package]] +name = "object_store" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec9cd6ca25e796a49fa242876d1c4de36a24a6da5258e9f0bc062dbf5e81c53b" +dependencies = [ + "async-trait", + "bytes 1.4.0", + "chrono", + "futures 0.3.28", + "itertools", + "parking_lot", + "percent-encoding", + "snafu", + "tokio", + "tracing 0.1.37", + "url", + "walkdir", +] + [[package]] name = "ofb" version = "0.6.1" @@ -5527,6 +6763,40 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "opendal" +version = "0.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37976a7c07a7e1c503c6c369d597e3d046df165dc1da5d0263bc651c0a0f979c" +dependencies = [ + "anyhow", + "async-compat", + "async-trait", + "backon", + "base64 0.21.2", + "bytes 1.4.0", + "chrono", + "flagset", + "futures 0.3.28", + "http", + "hyper", + "log", + "md-5", + "metrics 0.20.1", + "once_cell", + "parking_lot", + "percent-encoding", + "pin-project", + "quick-xml 0.27.1", + "reqsign", + "reqwest", + "serde", + "serde_json", + "tokio", + "tracing 0.1.37", + "uuid", +] + [[package]] name = "opendal" version = "0.37.0" @@ -5550,7 +6820,7 @@ dependencies = [ "parking_lot", "percent-encoding", "pin-project", - "quick-xml", + "quick-xml 0.27.1", "reqwest", "serde", "serde_json", @@ -5636,6 +6906,42 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "opentelemetry" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6105e89802af13fdf48c49d7646d3b533a70e536d818aae7e78ba0433d01acb8" +dependencies = [ + "async-trait", + "crossbeam-channel", + "futures-channel", + "futures-executor", + "futures-util", + "js-sys", + "lazy_static", + "percent-encoding", + "pin-project", + "rand 0.8.5", + "thiserror", + "tokio", + "tokio-stream", +] + +[[package]] +name = "opentelemetry-jaeger" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8c0b12cd9e3f9b35b52f6e0dac66866c519b26f424f4bbf96e3fe8bfbdc5229" +dependencies = [ + "async-trait", + "lazy_static", + "opentelemetry", + "opentelemetry-semantic-conventions", + "thiserror", + "thrift 0.15.0", + "tokio", +] + [[package]] name = "opentelemetry-proto" version = "0.1.0" @@ -5653,12 +6959,30 @@ dependencies = [ "vrl", ] +[[package]] +name = "opentelemetry-semantic-conventions" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985cc35d832d412224b2cffe2f9194b1b89b6aa5d0bef76d080dce09d90e62bd" +dependencies = [ + "opentelemetry", +] + [[package]] name = "option-ext" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "ordered-float" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3305af35278dd29f46fcdd139e0b1fbfae2153f0e5928b39b035542dd31e37b7" +dependencies = [ + "num-traits", +] + [[package]] name = "ordered-float" version = "2.10.0" @@ -5675,6 +6999,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fc2dbde8f8a79f2102cc474ceb0ad68e3b80b85289ea62389b60e66777e4213" dependencies = [ "num-traits", + "rand 0.8.5", + "serde", +] + +[[package]] +name = "ordered-multimap" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a" +dependencies = [ + "dlv-list", + "hashbrown 0.12.3", ] [[package]] @@ -5756,6 +7092,52 @@ dependencies = [ "windows-sys 0.42.0", ] +[[package]] +name = "parquet" +version = "37.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5022d98333271f4ca3e87bab760498e61726bf5a6ca919123c80517e20ded29" +dependencies = [ + "ahash 0.8.2", + "arrow-array", + "arrow-buffer", + "arrow-cast", + "arrow-data", + "arrow-ipc", + "arrow-schema", + "arrow-select", + "base64 0.21.2", + "brotli", + "bytes 1.4.0", + "chrono", + "flate2", + "futures 0.3.28", + "hashbrown 0.13.2", + "lz4", + "num", + "num-bigint", + "paste", + "seq-macro", + "snap", + "thrift 0.17.0", + "tokio", + "twox-hash", + "zstd 0.12.3+zstd.1.5.2", +] + +[[package]] +name = "parquet-format-async-temp" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03abc2f9c83fe9ceec83f47c76cc071bfd56caba33794340330f35623ab1f544" +dependencies = [ + "async-trait", + "byteorder", + "futures 0.3.28", + "integer-encoding", + "ordered-float 1.1.1", +] + [[package]] name = "parse-zoneinfo" version = "0.3.0" @@ -5804,6 +7186,15 @@ dependencies = [ "base64ct", ] +[[package]] +name = "pem-rfc7468" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d159833a9105500e0398934e205e0773f0b27529557134ecfc51c27646adac" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.0" @@ -5955,16 +7346,38 @@ dependencies = [ "tracing 0.1.37", ] +[[package]] +name = "pkcs1" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eff33bdbdfc54cc98a2eca766ebdec3e1b8fb7387523d5c9c9a2891da856f719" +dependencies = [ + "der 0.6.1", + "pkcs8 0.9.0", + "spki 0.6.0", + "zeroize", +] + [[package]] name = "pkcs8" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +dependencies = [ + "der 0.4.5", + "pem-rfc7468 0.2.3", + "spki 0.4.1", + "zeroize", +] + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" dependencies = [ - "der", - "pem-rfc7468", - "spki", - "zeroize", + "der 0.6.1", + "spki 0.6.0", ] [[package]] @@ -6021,6 +7434,15 @@ dependencies = [ "windows-sys 0.42.0", ] +[[package]] +name = "portable-atomic" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e30165d31df606f5726b090ec7592c308a0eaf61721ff64c9a3018e344a8753e" +dependencies = [ + "portable-atomic 1.3.1", +] + [[package]] name = "portable-atomic" version = "1.3.1" @@ -6380,6 +7802,22 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "658fa1faf7a4cc5f057c9ee5ef560f717ad9d8dc66d975267f709624d6e1ab88" +[[package]] +name = "quanta" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e31331286705f455e56cca62e0e717158474ff02b7936c1fa596d983f4ae27" +dependencies = [ + "crossbeam-utils", + "libc", + "mach", + "once_cell", + "raw-cpuid", + "wasi 0.10.2+wasi-snapshot-preview1", + "web-sys", + "winapi", +] + [[package]] name = "quanta" version = "0.11.1" @@ -6412,6 +7850,16 @@ dependencies = [ "serde", ] +[[package]] +name = "quick-xml" +version = "0.28.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce5e73202a820a31f8a0ee32ada5e21029c81fd9e3ebf668a40832e4219d9d1" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "quickcheck" version = "1.0.3" @@ -6496,6 +7944,7 @@ dependencies = [ "libc", "rand_chacha 0.3.1", "rand_core 0.6.4", + "serde", ] [[package]] @@ -6534,6 +7983,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom 0.2.10", + "serde", ] [[package]] @@ -6749,6 +8199,37 @@ dependencies = [ "bytecheck", ] +[[package]] +name = "reqsign" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a16a222894949f891cdfcb0c2c63913a975689fa7f7162d01d85df7837506ab8" +dependencies = [ + "anyhow", + "async-trait", + "base64 0.21.2", + "chrono", + "form_urlencoded", + "hex", + "hmac", + "home", + "http", + "jsonwebtoken", + "log", + "once_cell", + "percent-encoding", + "quick-xml 0.28.2", + "rand 0.8.5", + "reqwest", + "rsa", + "rust-ini", + "serde", + "serde_json", + "sha1", + "sha2 0.10.7", + "tokio", +] + [[package]] name = "reqwest" version = "0.11.18" @@ -6775,6 +8256,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustls 0.21.0", + "rustls-native-certs 0.6.2", "rustls-pemfile 1.0.1", "serde", "serde_json", @@ -6909,6 +8391,37 @@ dependencies = [ "xmlparser", ] +[[package]] +name = "rsa" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55a77d189da1fee555ad95b7e50e7457d91c0e089ec68ca69ad2989413bbdab4" +dependencies = [ + "byteorder", + "digest 0.10.7", + "num-bigint-dig", + "num-integer", + "num-iter", + "num-traits", + "pkcs1", + "pkcs8 0.9.0", + "rand_core 0.6.4", + "sha2 0.10.7", + "signature 2.1.0", + "subtle", + "zeroize", +] + +[[package]] +name = "rust-ini" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df" +dependencies = [ + "cfg-if", + "ordered-multimap", +] + [[package]] name = "rust_decimal" version = "1.29.1" @@ -6927,6 +8440,12 @@ dependencies = [ "serde_json", ] +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + [[package]] name = "rustc-hash" version = "1.1.0" @@ -7122,6 +8641,15 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +[[package]] +name = "safe_arch" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62a7484307bd40f8f7ccbacccac730108f2cae119a3b11c74485b48aa9ea650f" +dependencies = [ + "bytemuck", +] + [[package]] name = "same-file" version = "1.0.6" @@ -7263,6 +8791,12 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "seq-macro" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6b44e8fc93a14e66336d230954dda83d18b4605ccace8fe09bc7514a71ad0bc" + [[package]] name = "serde" version = "1.0.164" @@ -7604,9 +9138,9 @@ version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfecc059e81632eef1dd9b79e22fc28b8fe69b30d3357512a77a0ad8ee3c782" dependencies = [ - "pkcs8", + "pkcs8 0.7.6", "rand_core 0.6.4", - "signature", + "signature 1.6.4", "zeroize", ] @@ -7616,6 +9150,29 @@ version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + +[[package]] +name = "simba" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0b7840f121a46d63066ee7a99fc81dcabbc6105e437cae43528cea199b5a05f" +dependencies = [ + "approx", + "num-complex", + "num-traits", + "paste", + "wide", +] + [[package]] name = "similar" version = "2.2.1" @@ -7642,6 +9199,18 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a30f10c911c0355f80f1c2faa8096efc4a58cdf8590b954d5b395efa071c711" +[[package]] +name = "simple_asn1" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror", + "time", +] + [[package]] name = "siphasher" version = "0.3.10" @@ -7712,6 +9281,7 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0656e7e3ffb70f6c39b3c2a86332bb74aa3c679da781642590f3c1118c5045" dependencies = [ + "backtrace", "doc-comment", "futures-core", "pin-project", @@ -7777,7 +9347,38 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" dependencies = [ - "der", + "der 0.4.5", +] + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der 0.6.1", +] + +[[package]] +name = "sqlparser" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "355dc4d4b6207ca8a3434fc587db0a8016130a574dbcdbfb93d7f7b5bc5b211a" +dependencies = [ + "log", + "sqlparser_derive", +] + +[[package]] +name = "sqlparser_derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55fe75cb4a364c7f7ae06c7dbbc8d84bddd85d6cdf9975963c3935bc1991761e" +dependencies = [ + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 1.0.109", ] [[package]] @@ -7786,6 +9387,37 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "statrs" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d08e5e1748192713cc281da8b16924fb46be7b0c2431854eadc785823e5696e" +dependencies = [ + "approx", + "lazy_static", + "nalgebra", + "num-traits", + "rand 0.8.5", +] + +[[package]] +name = "store-api" +version = "0.2.0" +dependencies = [ + "async-trait", + "bytes 1.4.0", + "common-base", + "common-error", + "common-query", + "common-recordbatch", + "common-time", + "datatypes", + "derive_builder", + "futures 0.3.28", + "serde", + "snafu", +] + [[package]] name = "str-buf" version = "1.0.6" @@ -7876,6 +9508,9 @@ name = "strum" version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros", +] [[package]] name = "strum_macros" @@ -7980,6 +9615,38 @@ dependencies = [ "nom", ] +[[package]] +name = "table" +version = "0.2.0" +dependencies = [ + "anymap", + "async-trait", + "chrono", + "common-base", + "common-catalog", + "common-error", + "common-procedure", + "common-query", + "common-recordbatch", + "common-telemetry", + "common-time", + "datafusion", + "datafusion-common", + "datafusion-expr", + "datafusion-physical-expr", + "datatypes", + "derive_builder", + "futures 0.3.28", + "humantime", + "humantime-serde", + "parquet-format-async-temp", + "paste", + "serde", + "snafu", + "store-api", + "tokio", +] + [[package]] name = "take_mut" version = "0.2.2" @@ -8119,6 +9786,39 @@ dependencies = [ "once_cell", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + +[[package]] +name = "thrift" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b82ca8f46f95b3ce96081fe3dd89160fdea970c254bb72925255d1b62aae692e" +dependencies = [ + "byteorder", + "integer-encoding", + "log", + "ordered-float 1.1.1", + "threadpool", +] + +[[package]] +name = "thrift" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e54bc85fc7faa8bc175c4bab5b92ba8d9a3ce893d0e9f42cc455c8ab16a9e09" +dependencies = [ + "byteorder", + "integer-encoding", + "ordered-float 2.10.0", +] + [[package]] name = "tikv-jemalloc-sys" version = "0.5.2+5.3.0-patched" @@ -8569,6 +10269,17 @@ dependencies = [ "tracing-core 0.2.0", ] +[[package]] +name = "tracing-appender" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d48f71a791638519505cefafe162606f706c25592e4bde4d97600c0195312e" +dependencies = [ + "crossbeam-channel", + "time", + "tracing-subscriber", +] + [[package]] name = "tracing-attributes" version = "0.1.23" @@ -8580,6 +10291,24 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "tracing-bunyan-formatter" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a348912d4e90923cb93343691d3be97e3409607363706c400fc935bb032fb0" +dependencies = [ + "ahash 0.8.2", + "gethostname", + "log", + "serde", + "serde_json", + "time", + "tracing 0.1.37", + "tracing-core 0.1.30", + "tracing-log", + "tracing-subscriber", +] + [[package]] name = "tracing-core" version = "0.1.30" @@ -8653,6 +10382,20 @@ dependencies = [ "tracing-core 0.1.30", ] +[[package]] +name = "tracing-opentelemetry" +version = "0.17.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbbe89715c1dbbb790059e2565353978564924ee85017b5fff365c872ff6721f" +dependencies = [ + "once_cell", + "opentelemetry", + "tracing 0.1.37", + "tracing-core 0.1.30", + "tracing-log", + "tracing-subscriber", +] + [[package]] name = "tracing-serde" version = "0.1.3" @@ -8676,6 +10419,7 @@ dependencies = [ "serde", "serde_json", "sharded-slab", + "smallvec", "thread_local", "tracing 0.1.37", "tracing-core 0.1.30", @@ -8988,7 +10732,7 @@ version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1ee6bfd0a27bf614353809a035cf6880b74239ec6c5e39a7b2860ca16809137" dependencies = [ - "num-rational", + "num-rational 0.3.2", "num-traits", "typenum", ] @@ -9135,6 +10879,7 @@ dependencies = [ "chrono", "cidr-utils", "clap 4.1.14", + "client", "codecs", "colored", "console-subscriber", @@ -9182,10 +10927,10 @@ dependencies = [ "listenfd", "logfmt", "loki-logproto", - "lru", + "lru 0.10.0", "maxminddb", "md-5", - "metrics", + "metrics 0.21.0", "metrics-tracing-context", "mlua", "mongodb", @@ -9197,7 +10942,7 @@ dependencies = [ "num-format", "number_prefix", "once_cell", - "opendal", + "opendal 0.37.0", "openssl", "openssl-probe", "openssl-src", @@ -9324,9 +11069,9 @@ dependencies = [ "futures 0.3.28", "hdrhistogram", "memmap2", - "metrics", + "metrics 0.21.0", "metrics-tracing-context", - "metrics-util", + "metrics-util 0.15.0", "num-traits", "once_cell", "pin-project", @@ -9362,7 +11107,7 @@ dependencies = [ "derivative", "futures 0.3.28", "indexmap", - "metrics", + "metrics 0.21.0", "nom", "ordered-float 3.7.0", "paste", @@ -9462,9 +11207,9 @@ dependencies = [ "http", "hyper-proxy", "indexmap", - "metrics", + "metrics 0.21.0", "metrics-tracing-context", - "metrics-util", + "metrics-util 0.15.0", "mlua", "ndarray", "ndarray-stats", @@ -9479,7 +11224,7 @@ dependencies = [ "prost", "prost-build", "prost-types", - "quanta", + "quanta 0.11.1", "quickcheck", "quickcheck_macros", "rand 0.8.5", @@ -9770,6 +11515,12 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -9931,6 +11682,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "wide" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40018623e2dba2602a9790faba8d33f2ebdebf4b86561b83928db735f8784728" +dependencies = [ + "bytemuck", + "safe_arch", +] + [[package]] name = "widestring" version = "0.4.3" @@ -10209,6 +11970,15 @@ version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d25c75bf9ea12c4040a97f829154768bbbce366287e2dc044af160cd79a13fd" +[[package]] +name = "xz2" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388c44dc09d76f1536602ead6d325eb532f5c122f17782bd57fb47baeeb767e2" +dependencies = [ + "lzma-sys", +] + [[package]] name = "yaml-rust" version = "0.4.5" diff --git a/Cargo.toml b/Cargo.toml index dc838a1ade3c4..8cb2db19fcc7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -225,6 +225,9 @@ tui = { version = "0.19.0", optional = true, default-features = false, features hex = { version = "0.4.3", default-features = false, optional = true } sha2 = { version = "0.10.7", default-features = false, optional = true } +# Greptime +greptimedb-client = { path = "/home/sunng/greptime/greptimedb/src/client", package = "client", optional = true } + # VRL Lang vrl = { package = "vrl", version = "0.4.0", features = ["cli", "test"] } @@ -641,6 +644,7 @@ sinks-metrics = [ "sinks-blackhole", "sinks-console", "sinks-datadog_metrics", + "sinks-greptimedb", "sinks-humio", "sinks-influxdb", "sinks-kafka", @@ -675,6 +679,7 @@ sinks-datadog_traces = ["protobuf-build", "dep:rmpv", "dep:rmp-serde", "dep:serd sinks-elasticsearch = ["aws-core", "transforms-metric_to_log"] sinks-file = ["dep:async-compression"] sinks-gcp = ["dep:base64", "gcp"] +sinks-greptimedb = ["dep:greptimedb-client"] sinks-honeycomb = [] sinks-http = [] sinks-humio = ["sinks-splunk_hec", "transforms-metric_to_log"] diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/client.rs new file mode 100644 index 0000000000000..68ebb73bb154c --- /dev/null +++ b/src/sinks/greptimedb/client.rs @@ -0,0 +1,74 @@ +use greptime_client::api::v1::*; +use greptime_client::{Client, Database, Error as GreptimeError, Output}; + +use super::GreptimeDBConfig; +use crate::sinks::VectorSink; + +#[derive(Clone)] +struct GreptimeDBRetryLogic; + +impl RetryLogic for GreptimeDBRetryLogic { + type Error = GreptimeError; + type Response = Output; + + fn is_retriable_error(&self, error: &Self::Error) -> bool { + // TODO(sunng87): implement this + false + } +} + +#[derive(Debug)] +pub struct GreptimeDBService { + /// the client that connects to greptimedb + client: Database, +} + +impl GreptimeDBService { + pub fn new_sink(config: &GreptimeDBConfig) -> crate::Result { + let grpc_client = Client::with_urls(vec![config.endpoint]); + let client = Database::new(config.catalog, config.schema, grpc_client); + + let batch = config.batch.into_batch_settings()?; + let request = config.request.unwrap_with(&TowerRequestConfig { + retry_attempts: Some(5), + ..Default::default() + }); + + let greptime_service = GreptimeDBService { client }; + let sink = request + .batch_sink( + GreptimeDBRetryLogic, + greptime_service, + MetricsBuffer::new(batch.size), + batch.timeout, + ) + .with_flat_map(move |event: Event| { + // TODO(sunng87): + stream::iter({ + let byte_size = event.size_of(); + normalizer + .normalize(event.into_metric()) + .map(|metric| Ok(EncodedEvent::new(metric, byte_size))) + }) + }) + .sink_map_err(|e| error!(message = "Fatal greptimedb sink error.", %e)); + + Ok(VectorSink::From_event_sink(sink)) + } +} + +impl Service> for GreptimeDBService { + type Response = Output; + type Error = GreptimeError; + type Future = BoxFuture<'static, Result>; + + fn poll_ready(&mut self, cx: &mut std::task::Context) -> Poll> { + self.inner.poll_ready(cx) + } + + // Emission of Error internal event is handled upstream by the caller + fn call(&mut self, items: Vec) -> Self::Future { + // TODO(sunng87): + todo!() + } +} diff --git a/src/sinks/greptimedb/mod.rs b/src/sinks/greptimedb/mod.rs new file mode 100644 index 0000000000000..7a3d5e11547ef --- /dev/null +++ b/src/sinks/greptimedb/mod.rs @@ -0,0 +1,59 @@ +use vector_config::configurable_component; + +use crate::sinks::util::SinkBatchSettings; +use crate::sinks::{Healthcheck, VectorSink}; + +mod client; + +#[derive(Clone, Copy, Debug, Default)] +pub struct GreptimeDBDefaultBatchSettings; + +impl SinkBatchSettings for GreptimeDBDefaultBatchSettings { + const MAX_EVENTS: Option = Some(20); + const MAX_BYTES: Option = None; + const TIMEOUT_SECS: f64 = 1.0; +} + +/// Configuration items for GreptimeDB +#[configurable_component] +#[derive(Clone, Debug)] +pub struct GreptimeDBConfig { + /// The catalog name to connect + #[configurable(metadata(docs::examples = "greptime"))] + pub catalog: String, + /// The schema name to connect + #[configurable(metadata(docs::examples = "public"))] + pub schema: String, + /// The host and port of greptimedb + #[configurable(metadata(docs::examples = "localhost:4001"))] + pub endpoint: String, + + #[configurable(derived)] + #[serde(default)] + pub request: TowerRequestConfig, + + #[configurable(derived)] + #[serde( + default, + deserialize_with = "crate::serde::bool_or_struct", + skip_serializing_if = "crate::serde::skip_serializing_if_default" + )] + acknowledgements: AcknowledgementsConfig, + // TODO: tls configuration +} + +#[async_trait::async_trait] +impl SinkConfig for GreptimeDBConfig { + async fn build(&self, cx: SinkContext) -> crate::Result<(VectorSink, Healthcheck)> { + let sink = client::GreptimeDBSink::new(&self); + sink + } + + fn input(&self) -> Input { + Input::metric() + } + + fn acknowledgements(&self) -> &AcknowledgementsConfig { + &self.acknowledgements + } +} diff --git a/src/sinks/mod.rs b/src/sinks/mod.rs index d64d92e37664b..a0a2a57e5998a 100644 --- a/src/sinks/mod.rs +++ b/src/sinks/mod.rs @@ -55,6 +55,8 @@ pub mod file; pub mod gcp; #[cfg(any(feature = "sinks-gcp"))] pub mod gcs_common; +#[cfg(feature = "sinks-greptimedb")] +pub mod greptimedb; #[cfg(feature = "sinks-honeycomb")] pub mod honeycomb; #[cfg(feature = "sinks-http")] From 5e951fbebbc415e2442e2c616a89a5a6556a9dbf Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Tue, 7 Mar 2023 12:00:25 +0800 Subject: [PATCH 02/34] feat: configure greptimedb as git dependency --- Cargo.toml | 2 +- src/sinks/greptimedb/client.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8cb2db19fcc7d..68de3b2fb75cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -226,7 +226,7 @@ hex = { version = "0.4.3", default-features = false, optional = true } sha2 = { version = "0.10.7", default-features = false, optional = true } # Greptime -greptimedb-client = { path = "/home/sunng/greptime/greptimedb/src/client", package = "client", optional = true } +greptimedb-client = { git = "https://github.com/GreptimeTeam/greptimedb.git", rev = "bd98a26ccaa24e3d26681a1054d2d21972755bd3", package = "client", optional = true } # VRL Lang vrl = { package = "vrl", version = "0.4.0", features = ["cli", "test"] } diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/client.rs index 68ebb73bb154c..b98ba0412c70e 100644 --- a/src/sinks/greptimedb/client.rs +++ b/src/sinks/greptimedb/client.rs @@ -46,9 +46,8 @@ impl GreptimeDBService { // TODO(sunng87): stream::iter({ let byte_size = event.size_of(); - normalizer - .normalize(event.into_metric()) - .map(|metric| Ok(EncodedEvent::new(metric, byte_size))) + let metric = event.into_metric(); + Ok(EncodedEvent::new(metric, byte_size)) }) }) .sink_map_err(|e| error!(message = "Fatal greptimedb sink error.", %e)); @@ -66,7 +65,7 @@ impl Service> for GreptimeDBService { self.inner.poll_ready(cx) } - // Emission of Error internal event is handled upstream by the caller + // Convert vector metrics into GreptimeDB format and send them in batch fn call(&mut self, items: Vec) -> Self::Future { // TODO(sunng87): todo!() From 4efa4c05729d4686868a1c25ec8ccdc540fa8486 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Wed, 15 Mar 2023 18:05:42 +0800 Subject: [PATCH 03/34] feat: transforming vector metric to greptimedb insert request --- src/sinks/greptimedb/client.rs | 256 ++++++++++++++++++++++++++++++--- src/sinks/greptimedb/mod.rs | 61 ++++++-- 2 files changed, 289 insertions(+), 28 deletions(-) diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/client.rs index b98ba0412c70e..36ab564a1aeca 100644 --- a/src/sinks/greptimedb/client.rs +++ b/src/sinks/greptimedb/client.rs @@ -1,40 +1,85 @@ -use greptime_client::api::v1::*; -use greptime_client::{Client, Database, Error as GreptimeError, Output}; +use std::sync::Arc; +use std::task::Poll; + +use chrono::Utc; +use futures::stream; +use futures::SinkExt; +use futures_util::future::BoxFuture; +use greptimedb_client::api::v1::column::*; +use greptimedb_client::api::v1::*; +use greptimedb_client::{Client, Database, Error as GreptimeError, Output}; +use tower::Service; +use vector_core::event::metric::{Bucket, MetricSketch, Quantile, Sample}; +use vector_core::event::{Event, Metric, MetricValue}; +use vector_core::metrics::AgentDDSketch; +use vector_core::ByteSizeOf; use super::GreptimeDBConfig; +use crate::sinks::util::buffer::metrics::MetricNormalize; +use crate::sinks::util::buffer::metrics::MetricNormalizer; +use crate::sinks::util::buffer::metrics::MetricSet; +use crate::sinks::util::buffer::metrics::MetricsBuffer; +use crate::sinks::util::retries::RetryLogic; +use crate::sinks::util::sink::Response; +use crate::sinks::util::statistic::DistributionStatistic; +use crate::sinks::util::{EncodedEvent, TowerRequestConfig}; use crate::sinks::VectorSink; +#[derive(Debug)] +pub struct GreptimeBatchOutput(Vec); + +impl Response for GreptimeBatchOutput {} + #[derive(Clone)] struct GreptimeDBRetryLogic; impl RetryLogic for GreptimeDBRetryLogic { type Error = GreptimeError; - type Response = Output; + type Response = GreptimeBatchOutput; - fn is_retriable_error(&self, error: &Self::Error) -> bool { + fn is_retriable_error(&self, _error: &Self::Error) -> bool { // TODO(sunng87): implement this false } } -#[derive(Debug)] +#[derive(Clone, Debug, Default)] +struct GreptimeDBMetricNormalize; + +impl MetricNormalize for GreptimeDBMetricNormalize { + fn normalize(&mut self, state: &mut MetricSet, metric: Metric) -> Option { + match (metric.kind(), &metric.value()) { + (_, MetricValue::Counter { .. }) => state.make_absolute(metric), + (_, MetricValue::Gauge { .. }) => state.make_absolute(metric), + // All others are left as-is + _ => Some(metric), + } + } +} + +#[derive(Debug, Clone)] pub struct GreptimeDBService { /// the client that connects to greptimedb - client: Database, + client: Arc, } impl GreptimeDBService { pub fn new_sink(config: &GreptimeDBConfig) -> crate::Result { - let grpc_client = Client::with_urls(vec![config.endpoint]); - let client = Database::new(config.catalog, config.schema, grpc_client); + let grpc_client = Client::with_urls(vec![&config.grpc_endpoint]); + let client = Database::new(&config.catalog, &config.schema, grpc_client); let batch = config.batch.into_batch_settings()?; let request = config.request.unwrap_with(&TowerRequestConfig { - retry_attempts: Some(5), + retry_attempts: Some(1), ..Default::default() }); - let greptime_service = GreptimeDBService { client }; + let greptime_service = GreptimeDBService { + client: Arc::new(client), + }; + + let mut normalizer = MetricNormalizer::::default(); + let sink = request .batch_sink( GreptimeDBRetryLogic, @@ -43,31 +88,204 @@ impl GreptimeDBService { batch.timeout, ) .with_flat_map(move |event: Event| { - // TODO(sunng87): stream::iter({ let byte_size = event.size_of(); - let metric = event.into_metric(); - Ok(EncodedEvent::new(metric, byte_size)) + normalizer + .normalize(event.into_metric()) + .map(|metric| Ok(EncodedEvent::new(metric, byte_size))) }) }) .sink_map_err(|e| error!(message = "Fatal greptimedb sink error.", %e)); - Ok(VectorSink::From_event_sink(sink)) + Ok(VectorSink::from_event_sink(sink)) } } impl Service> for GreptimeDBService { - type Response = Output; + type Response = GreptimeBatchOutput; type Error = GreptimeError; type Future = BoxFuture<'static, Result>; - fn poll_ready(&mut self, cx: &mut std::task::Context) -> Poll> { - self.inner.poll_ready(cx) + fn poll_ready(&mut self, _cx: &mut std::task::Context) -> Poll> { + Poll::Ready(Ok(())) } // Convert vector metrics into GreptimeDB format and send them in batch fn call(&mut self, items: Vec) -> Self::Future { - // TODO(sunng87): - todo!() + // TODO(sunng87): group metrics by name and send metrics with same name + // in batch + let requests = items.into_iter().map(metrics_to_insert_request); + let client = self.client.clone(); + + Box::pin(async move { + let mut outputs = Vec::with_capacity(requests.len()); + for request in requests { + let result = client.insert(request).await?; + outputs.push(result); + } + Ok(GreptimeBatchOutput(outputs)) + }) + } +} + +fn f64_column(name: &str, value: f64) -> Column { + Column { + column_name: name.to_owned(), + values: Some(column::Values { + f64_values: vec![value], + ..Default::default() + }), + semantic_type: SemanticType::Field as i32, + datatype: ColumnDataType::Float64 as i32, + ..Default::default() + } +} + +fn ts_column(name: &str, value: i64) -> Column { + Column { + column_name: name.to_owned(), + values: Some(column::Values { + ts_millisecond_values: vec![value], + ..Default::default() + }), + semantic_type: SemanticType::Timestamp as i32, + datatype: ColumnDataType::TimestampMillisecond as i32, + ..Default::default() + } +} + +fn str_column(name: &str, value: &str) -> Column { + Column { + column_name: name.to_owned(), + values: Some(column::Values { + string_values: vec![value.to_owned()], + ..Default::default() + }), + semantic_type: SemanticType::Tag as i32, + datatype: ColumnDataType::String as i32, + ..Default::default() + } +} + +fn metrics_to_insert_request(metric: Metric) -> InsertRequest { + let metric_name = metric.name(); + + let mut columns = Vec::new(); + // timetamp + let timestamp = metric + .timestamp() + .map(|t| t.timestamp()) + .unwrap_or_else(|| Utc::now().timestamp()); + columns.push(ts_column("timestamp", timestamp)); + + // tags + if let Some(tags) = metric.tags() { + for (key, value) in tags.iter_single() { + columns.push(str_column(key, value)); + } + } + + // fields + match metric.value() { + MetricValue::Counter { value } => columns.push(f64_column("value", *value)), + MetricValue::Gauge { value } => columns.push(f64_column("value", *value)), + MetricValue::Set { values } => columns.push(f64_column("value", values.len() as f64)), + MetricValue::Distribution { samples, .. } => { + encode_distribution(samples, &mut columns); + } + + MetricValue::AggregatedHistogram { + buckets, + count, + sum, + } => { + encode_histogram(buckets.as_ref(), &mut columns); + columns.push(f64_column("count", *count as f64)); + columns.push(f64_column("sum", *sum)); + } + MetricValue::AggregatedSummary { + quantiles, + count, + sum, + } => { + encode_quantiles(quantiles.as_ref(), &mut columns); + columns.push(f64_column("count", *count as f64)); + columns.push(f64_column("sum", *sum)); + } + MetricValue::Sketch { sketch } => { + let MetricSketch::AgentDDSketch(sketch) = sketch; + encode_sketch(&sketch, &mut columns); + } + } + + InsertRequest { + table_name: metric_name.to_owned(), + columns, + row_count: 1, + ..Default::default() + } +} + +fn encode_distribution(samples: &[Sample], columns: &mut Vec) { + if let Some(stats) = DistributionStatistic::from_samples(samples, &[0.75, 0.90, 0.95, 0.99]) { + columns.push(f64_column("min", stats.min)); + columns.push(f64_column("max", stats.max)); + columns.push(f64_column("median", stats.median)); + columns.push(f64_column("avg", stats.avg)); + columns.push(f64_column("sum", stats.sum)); + columns.push(f64_column("count", stats.count as f64)); + + for (quantile, value) in stats.quantiles { + columns.push(f64_column(&format!("p{:2}", quantile * 100f64), value)); + } + } +} + +fn encode_histogram(buckets: &[Bucket], columns: &mut Vec) { + for bucket in buckets { + let column_name = format!("b{}", bucket.upper_limit); + columns.push(f64_column(&column_name, bucket.count as f64)); + } +} + +fn encode_quantiles(quantiles: &[Quantile], columns: &mut Vec) { + for quantile in quantiles { + let column_name = format!("p{:2}", quantile.quantile * 100f64); + columns.push(f64_column(&column_name, quantile.value)); + } +} + +fn encode_sketch(sketch: &AgentDDSketch, columns: &mut Vec) { + columns.push(f64_column("count", sketch.count() as f64)); + if let Some(min) = sketch.min() { + columns.push(f64_column("min", min)); + } + + if let Some(max) = sketch.max() { + columns.push(f64_column("max", max)); + } + + if let Some(sum) = sketch.sum() { + columns.push(f64_column("sum", sum)); + } + + if let Some(avg) = sketch.avg() { + columns.push(f64_column("avg", avg)); + } + + if let Some(quantile) = sketch.quantile(0.5) { + columns.push(f64_column("p50", quantile)); + } + if let Some(quantile) = sketch.quantile(0.75) { + columns.push(f64_column("p75", quantile)); + } + if let Some(quantile) = sketch.quantile(0.90) { + columns.push(f64_column("p90", quantile)); + } + if let Some(quantile) = sketch.quantile(0.95) { + columns.push(f64_column("p95", quantile)); + } + if let Some(quantile) = sketch.quantile(0.99) { + columns.push(f64_column("p99", quantile)); } } diff --git a/src/sinks/greptimedb/mod.rs b/src/sinks/greptimedb/mod.rs index 7a3d5e11547ef..c65af50711d7f 100644 --- a/src/sinks/greptimedb/mod.rs +++ b/src/sinks/greptimedb/mod.rs @@ -1,8 +1,17 @@ +use futures_util::FutureExt; +use http::StatusCode; +use tower::Service; use vector_config::configurable_component; +use vector_core::config::{AcknowledgementsConfig, Input}; +use vector_core::tls::{TlsConfig, TlsSettings}; -use crate::sinks::util::SinkBatchSettings; +use crate::config::{SinkConfig, SinkContext}; +use crate::http::HttpClient; +use crate::sinks::util::{BatchConfig, SinkBatchSettings}; use crate::sinks::{Healthcheck, VectorSink}; +use super::util::TowerRequestConfig; + mod client; #[derive(Clone, Copy, Debug, Default)] @@ -15,8 +24,9 @@ impl SinkBatchSettings for GreptimeDBDefaultBatchSettings { } /// Configuration items for GreptimeDB -#[configurable_component] -#[derive(Clone, Debug)] +#[configurable_component(sink("greptimedb_metrics"))] +#[derive(Clone, Debug, Default)] +#[serde(deny_unknown_fields)] pub struct GreptimeDBConfig { /// The catalog name to connect #[configurable(metadata(docs::examples = "greptime"))] @@ -24,29 +34,43 @@ pub struct GreptimeDBConfig { /// The schema name to connect #[configurable(metadata(docs::examples = "public"))] pub schema: String, - /// The host and port of greptimedb + /// The host and port of greptimedb grpc service #[configurable(metadata(docs::examples = "localhost:4001"))] - pub endpoint: String, + pub grpc_endpoint: String, + /// The host and port of greptimedb http service + #[configurable(metadata(docs::examples = "http://localhost:4000"))] + pub http_endpoint: String, #[configurable(derived)] #[serde(default)] pub request: TowerRequestConfig, + #[configurable(derived)] + #[serde(default)] + pub batch: BatchConfig, + #[configurable(derived)] #[serde( default, deserialize_with = "crate::serde::bool_or_struct", skip_serializing_if = "crate::serde::skip_serializing_if_default" )] - acknowledgements: AcknowledgementsConfig, - // TODO: tls configuration + pub acknowledgements: AcknowledgementsConfig, + + #[configurable(derived)] + pub tls: Option, } +impl_generate_config_from_default!(GreptimeDBConfig); + #[async_trait::async_trait] impl SinkConfig for GreptimeDBConfig { async fn build(&self, cx: SinkContext) -> crate::Result<(VectorSink, Healthcheck)> { - let sink = client::GreptimeDBSink::new(&self); - sink + let sink = client::GreptimeDBService::new_sink(&self)?; + let tls_settings = TlsSettings::from_options(&self.tls)?; + let http_client = HttpClient::new(tls_settings, cx.proxy())?; + let healthcheck = healthcheck(&self.http_endpoint, http_client)?; + Ok((sink, healthcheck)) } fn input(&self) -> Input { @@ -57,3 +81,22 @@ impl SinkConfig for GreptimeDBConfig { &self.acknowledgements } } + +fn healthcheck(endpoint: &str, mut client: HttpClient) -> crate::Result { + let uri = format!("{endpoint}/health"); + + let request = hyper::Request::get(uri).body(hyper::Body::empty()).unwrap(); + + Ok(async move { + client + .call(request) + .await + .map_err(|error| error.into()) + .and_then(|response| match response.status() { + StatusCode::OK => Ok(()), + StatusCode::NO_CONTENT => Ok(()), + other => Err(super::HealthcheckError::UnexpectedStatus { status: other }.into()), + }) + } + .boxed()) +} From 52094b86fab8abeac8966c57156a3607865b2296 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Tue, 21 Mar 2023 10:53:24 +0800 Subject: [PATCH 04/34] feat: address issues in latest greptimedb client --- Cargo.toml | 2 +- src/sinks/greptimedb/client.rs | 8 ++++---- src/sinks/greptimedb/mod.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 68de3b2fb75cf..495d708825cd5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -226,7 +226,7 @@ hex = { version = "0.4.3", default-features = false, optional = true } sha2 = { version = "0.10.7", default-features = false, optional = true } # Greptime -greptimedb-client = { git = "https://github.com/GreptimeTeam/greptimedb.git", rev = "bd98a26ccaa24e3d26681a1054d2d21972755bd3", package = "client", optional = true } +greptimedb-client = { git = "https://github.com/GreptimeTeam/greptimedb.git", rev = "f6669a820112a10daf2e933ec34461454940f856", package = "client", optional = true } # VRL Lang vrl = { package = "vrl", version = "0.4.0", features = ["cli", "test"] } diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/client.rs index 36ab564a1aeca..ebb477bd6d670 100644 --- a/src/sinks/greptimedb/client.rs +++ b/src/sinks/greptimedb/client.rs @@ -7,7 +7,7 @@ use futures::SinkExt; use futures_util::future::BoxFuture; use greptimedb_client::api::v1::column::*; use greptimedb_client::api::v1::*; -use greptimedb_client::{Client, Database, Error as GreptimeError, Output}; +use greptimedb_client::{Client, Database, Error as GreptimeError}; use tower::Service; use vector_core::event::metric::{Bucket, MetricSketch, Quantile, Sample}; use vector_core::event::{Event, Metric, MetricValue}; @@ -26,7 +26,7 @@ use crate::sinks::util::{EncodedEvent, TowerRequestConfig}; use crate::sinks::VectorSink; #[derive(Debug)] -pub struct GreptimeBatchOutput(Vec); +pub struct GreptimeBatchOutput(Vec); impl Response for GreptimeBatchOutput {} @@ -174,8 +174,8 @@ fn metrics_to_insert_request(metric: Metric) -> InsertRequest { // timetamp let timestamp = metric .timestamp() - .map(|t| t.timestamp()) - .unwrap_or_else(|| Utc::now().timestamp()); + .map(|t| t.timestamp_millis()) + .unwrap_or_else(|| Utc::now().timestamp_millis()); columns.push(ts_column("timestamp", timestamp)); // tags diff --git a/src/sinks/greptimedb/mod.rs b/src/sinks/greptimedb/mod.rs index c65af50711d7f..b5a80a8f57532 100644 --- a/src/sinks/greptimedb/mod.rs +++ b/src/sinks/greptimedb/mod.rs @@ -24,7 +24,7 @@ impl SinkBatchSettings for GreptimeDBDefaultBatchSettings { } /// Configuration items for GreptimeDB -#[configurable_component(sink("greptimedb_metrics"))] +#[configurable_component(sink("greptimedb"))] #[derive(Clone, Debug, Default)] #[serde(deny_unknown_fields)] pub struct GreptimeDBConfig { From a080f306ea7704ef6efe6d4a632d297afe1a0046 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Tue, 21 Mar 2023 14:07:51 +0800 Subject: [PATCH 05/34] feat: add grpc auth support --- src/sinks/greptimedb/client.rs | 10 +++++++++- src/sinks/greptimedb/mod.rs | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/client.rs index ebb477bd6d670..df81b4bb19bd4 100644 --- a/src/sinks/greptimedb/client.rs +++ b/src/sinks/greptimedb/client.rs @@ -5,6 +5,7 @@ use chrono::Utc; use futures::stream; use futures::SinkExt; use futures_util::future::BoxFuture; +use greptimedb_client::api::v1::auth_header::AuthScheme; use greptimedb_client::api::v1::column::*; use greptimedb_client::api::v1::*; use greptimedb_client::{Client, Database, Error as GreptimeError}; @@ -66,7 +67,14 @@ pub struct GreptimeDBService { impl GreptimeDBService { pub fn new_sink(config: &GreptimeDBConfig) -> crate::Result { let grpc_client = Client::with_urls(vec![&config.grpc_endpoint]); - let client = Database::new(&config.catalog, &config.schema, grpc_client); + let mut client = Database::new(&config.catalog, &config.schema, grpc_client); + + if let (Some(username), Some(password)) = (&config.username, &config.password) { + client.set_auth(AuthScheme::Basic(Basic { + username: username.to_owned(), + password: password.to_owned(), + })) + } let batch = config.batch.into_batch_settings()?; let request = config.request.unwrap_with(&TowerRequestConfig { diff --git a/src/sinks/greptimedb/mod.rs b/src/sinks/greptimedb/mod.rs index b5a80a8f57532..cfd46002ba594 100644 --- a/src/sinks/greptimedb/mod.rs +++ b/src/sinks/greptimedb/mod.rs @@ -40,6 +40,14 @@ pub struct GreptimeDBConfig { /// The host and port of greptimedb http service #[configurable(metadata(docs::examples = "http://localhost:4000"))] pub http_endpoint: String, + /// The username of greptimedb + #[configurable(metadata(docs::examples = "username"))] + #[serde(default)] + pub username: Option, + /// The password of greptimedb + #[configurable(metadata(docs::examples = "password"))] + #[serde(default)] + pub password: Option, #[configurable(derived)] #[serde(default)] From 9e8d3548a0826aeab02fa03230bcbe6a25a6a40c Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Tue, 21 Mar 2023 17:37:53 +0800 Subject: [PATCH 06/34] refactor: default value for catalog and schema, rename column fn --- src/sinks/greptimedb/client.rs | 166 ++++++++++++++++++++++++++------- src/sinks/greptimedb/mod.rs | 30 +++++- 2 files changed, 162 insertions(+), 34 deletions(-) diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/client.rs index df81b4bb19bd4..010f1e3c64e39 100644 --- a/src/sinks/greptimedb/client.rs +++ b/src/sinks/greptimedb/client.rs @@ -8,7 +8,9 @@ use futures_util::future::BoxFuture; use greptimedb_client::api::v1::auth_header::AuthScheme; use greptimedb_client::api::v1::column::*; use greptimedb_client::api::v1::*; -use greptimedb_client::{Client, Database, Error as GreptimeError}; +use greptimedb_client::{ + Client, Database, Error as GreptimeError, DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME, +}; use tower::Service; use vector_core::event::metric::{Bucket, MetricSketch, Quantile, Sample}; use vector_core::event::{Event, Metric, MetricValue}; @@ -67,7 +69,11 @@ pub struct GreptimeDBService { impl GreptimeDBService { pub fn new_sink(config: &GreptimeDBConfig) -> crate::Result { let grpc_client = Client::with_urls(vec![&config.grpc_endpoint]); - let mut client = Database::new(&config.catalog, &config.schema, grpc_client); + let mut client = Database::new( + config.catalog.as_deref().unwrap_or(DEFAULT_CATALOG_NAME), + config.schema.as_deref().unwrap_or(DEFAULT_SCHEMA_NAME), + grpc_client, + ); if let (Some(username), Some(password)) = (&config.username, &config.password) { client.set_auth(AuthScheme::Basic(Basic { @@ -78,7 +84,7 @@ impl GreptimeDBService { let batch = config.batch.into_batch_settings()?; let request = config.request.unwrap_with(&TowerRequestConfig { - retry_attempts: Some(1), + retry_attempts: None, ..Default::default() }); @@ -136,7 +142,7 @@ impl Service> for GreptimeDBService { } } -fn f64_column(name: &str, value: f64) -> Column { +fn f64_field(name: &str, value: f64) -> Column { Column { column_name: name.to_owned(), values: Some(column::Values { @@ -162,7 +168,7 @@ fn ts_column(name: &str, value: i64) -> Column { } } -fn str_column(name: &str, value: &str) -> Column { +fn tag_column(name: &str, value: &str) -> Column { Column { column_name: name.to_owned(), values: Some(column::Values { @@ -189,15 +195,15 @@ fn metrics_to_insert_request(metric: Metric) -> InsertRequest { // tags if let Some(tags) = metric.tags() { for (key, value) in tags.iter_single() { - columns.push(str_column(key, value)); + columns.push(tag_column(key, value)); } } // fields match metric.value() { - MetricValue::Counter { value } => columns.push(f64_column("value", *value)), - MetricValue::Gauge { value } => columns.push(f64_column("value", *value)), - MetricValue::Set { values } => columns.push(f64_column("value", values.len() as f64)), + MetricValue::Counter { value } => columns.push(f64_field("value", *value)), + MetricValue::Gauge { value } => columns.push(f64_field("value", *value)), + MetricValue::Set { values } => columns.push(f64_field("value", values.len() as f64)), MetricValue::Distribution { samples, .. } => { encode_distribution(samples, &mut columns); } @@ -208,8 +214,8 @@ fn metrics_to_insert_request(metric: Metric) -> InsertRequest { sum, } => { encode_histogram(buckets.as_ref(), &mut columns); - columns.push(f64_column("count", *count as f64)); - columns.push(f64_column("sum", *sum)); + columns.push(f64_field("count", *count as f64)); + columns.push(f64_field("sum", *sum)); } MetricValue::AggregatedSummary { quantiles, @@ -217,8 +223,8 @@ fn metrics_to_insert_request(metric: Metric) -> InsertRequest { sum, } => { encode_quantiles(quantiles.as_ref(), &mut columns); - columns.push(f64_column("count", *count as f64)); - columns.push(f64_column("sum", *sum)); + columns.push(f64_field("count", *count as f64)); + columns.push(f64_field("sum", *sum)); } MetricValue::Sketch { sketch } => { let MetricSketch::AgentDDSketch(sketch) = sketch; @@ -236,15 +242,15 @@ fn metrics_to_insert_request(metric: Metric) -> InsertRequest { fn encode_distribution(samples: &[Sample], columns: &mut Vec) { if let Some(stats) = DistributionStatistic::from_samples(samples, &[0.75, 0.90, 0.95, 0.99]) { - columns.push(f64_column("min", stats.min)); - columns.push(f64_column("max", stats.max)); - columns.push(f64_column("median", stats.median)); - columns.push(f64_column("avg", stats.avg)); - columns.push(f64_column("sum", stats.sum)); - columns.push(f64_column("count", stats.count as f64)); + columns.push(f64_field("min", stats.min)); + columns.push(f64_field("max", stats.max)); + columns.push(f64_field("median", stats.median)); + columns.push(f64_field("avg", stats.avg)); + columns.push(f64_field("sum", stats.sum)); + columns.push(f64_field("count", stats.count as f64)); for (quantile, value) in stats.quantiles { - columns.push(f64_column(&format!("p{:2}", quantile * 100f64), value)); + columns.push(f64_field(&format!("p{:2}", quantile * 100f64), value)); } } } @@ -252,48 +258,144 @@ fn encode_distribution(samples: &[Sample], columns: &mut Vec) { fn encode_histogram(buckets: &[Bucket], columns: &mut Vec) { for bucket in buckets { let column_name = format!("b{}", bucket.upper_limit); - columns.push(f64_column(&column_name, bucket.count as f64)); + columns.push(f64_field(&column_name, bucket.count as f64)); } } fn encode_quantiles(quantiles: &[Quantile], columns: &mut Vec) { for quantile in quantiles { let column_name = format!("p{:2}", quantile.quantile * 100f64); - columns.push(f64_column(&column_name, quantile.value)); + columns.push(f64_field(&column_name, quantile.value)); } } fn encode_sketch(sketch: &AgentDDSketch, columns: &mut Vec) { - columns.push(f64_column("count", sketch.count() as f64)); + columns.push(f64_field("count", sketch.count() as f64)); if let Some(min) = sketch.min() { - columns.push(f64_column("min", min)); + columns.push(f64_field("min", min)); } if let Some(max) = sketch.max() { - columns.push(f64_column("max", max)); + columns.push(f64_field("max", max)); } if let Some(sum) = sketch.sum() { - columns.push(f64_column("sum", sum)); + columns.push(f64_field("sum", sum)); } if let Some(avg) = sketch.avg() { - columns.push(f64_column("avg", avg)); + columns.push(f64_field("avg", avg)); } if let Some(quantile) = sketch.quantile(0.5) { - columns.push(f64_column("p50", quantile)); + columns.push(f64_field("p50", quantile)); } if let Some(quantile) = sketch.quantile(0.75) { - columns.push(f64_column("p75", quantile)); + columns.push(f64_field("p75", quantile)); } if let Some(quantile) = sketch.quantile(0.90) { - columns.push(f64_column("p90", quantile)); + columns.push(f64_field("p90", quantile)); } if let Some(quantile) = sketch.quantile(0.95) { - columns.push(f64_column("p95", quantile)); + columns.push(f64_field("p95", quantile)); } if let Some(quantile) = sketch.quantile(0.99) { - columns.push(f64_column("p99", quantile)); + columns.push(f64_field("p99", quantile)); + } +} + +#[cfg(test)] +mod tests { + + use similar_asserts::assert_eq; + + use super::*; + use crate::event::metric::{MetricKind, StatisticKind}; + + fn get_column(columns: &[Column], name: &str) -> f64 { + let col = columns.iter().find(|c| c.column_name == name).unwrap(); + *col.values.unwrap().f64_values.get(0).unwrap() + } + + #[test] + fn test_metric_data_to_insert_request() { + let metric = Metric::new( + "load1", + MetricKind::Absolute, + MetricValue::Gauge { value: 1.1 }, + ) + .with_namespace(Some("ns")) + .with_tags(Some([("host".to_owned(), "thinkneo".to_owned())].into())) + .with_timestamp(Some(Utc::now())); + + let insert = metrics_to_insert_request(metric); + + assert_eq!(insert.table_name, "load1"); + assert_eq!(insert.row_count, 1); + assert_eq!(insert.columns.len(), 3); + + let column_names = insert + .columns + .iter() + .map(|c| c.column_name.as_ref()) + .collect::>(); + assert!(column_names.contains(&"timestamp")); + assert!(column_names.contains(&"host")); + assert!(column_names.contains(&"value")); + + assert_eq!(get_column(&insert.columns, "value"), 1.1); + } + + #[test] + fn test_counter() { + let metric = Metric::new( + "cpu_seconds_total", + MetricKind::Incremental, + MetricValue::Counter { value: 1.1 }, + ); + let insert = metrics_to_insert_request(metric); + assert_eq!(insert.columns.len(), 2); + + assert_eq!(get_column(&insert.columns, "value"), 1.1); + } + + #[test] + fn test_set() { + let metric = Metric::new( + "cpu_seconds_total", + MetricKind::Absolute, + MetricValue::Set { + values: ["foo".to_owned(), "bar".to_owned()].iter().collect(), + }, + ); + let insert = metrics_to_insert_request(metric); + assert_eq!(insert.columns.len(), 2); + + assert_eq!(get_column(&insert.columns, "value"), 2.0); + } + + #[test] + fn test_distribution() { + let metric = Metric::new( + "cpu_seconds_total", + MetricKind::Incremental, + MetricValue::Distribution { + samples: vector_core::samples![1.0 => 2, 2.0 => 4, 3.0 => 2], + statistic: StatisticKind::Histogram, + }, + ); + let insert = metrics_to_insert_request(metric); + assert_eq!(insert.columns.len(), 11); + + assert_eq!(get_column(&insert.columns, "max"), 3.0); + assert_eq!(get_column(&insert.columns, "min"), 1.0); + assert_eq!(get_column(&insert.columns, "median"), 2.0); + assert_eq!(get_column(&insert.columns, "avg"), 2.0); + assert_eq!(get_column(&insert.columns, "sum"), 16.0); + assert_eq!(get_column(&insert.columns, "count"), 8.0); + assert_eq!(get_column(&insert.columns, "p75"), 2.0); + assert_eq!(get_column(&insert.columns, "p90"), 3.0); + assert_eq!(get_column(&insert.columns, "p95"), 3.0); + assert_eq!(get_column(&insert.columns, "p99"), 3.0); } } diff --git a/src/sinks/greptimedb/mod.rs b/src/sinks/greptimedb/mod.rs index cfd46002ba594..f4414f25b78b0 100644 --- a/src/sinks/greptimedb/mod.rs +++ b/src/sinks/greptimedb/mod.rs @@ -30,10 +30,12 @@ impl SinkBatchSettings for GreptimeDBDefaultBatchSettings { pub struct GreptimeDBConfig { /// The catalog name to connect #[configurable(metadata(docs::examples = "greptime"))] - pub catalog: String, + #[serde(default)] + pub catalog: Option, /// The schema name to connect #[configurable(metadata(docs::examples = "public"))] - pub schema: String, + #[serde(default)] + pub schema: Option, /// The host and port of greptimedb grpc service #[configurable(metadata(docs::examples = "localhost:4001"))] pub grpc_endpoint: String, @@ -108,3 +110,27 @@ fn healthcheck(endpoint: &str, mut client: HttpClient) -> crate::Result(); + } + + #[test] + fn test_config_with_username() { + let config = indoc! {r#" + grpc_endpoint = "foo-bar.ap-southeast-1.aws.greptime.cloud:4001" + http_endpoint = "http://alpha-bravo.ap-southeast-1.aws.greptime.cloud/health" + catalog = "foo" + schema = "bar" + "#}; + + toml::from_str::(config).unwrap(); + } +} From 7c13ceaa61207d8fc74d2fd479f45e994d215325 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Wed, 22 Mar 2023 14:52:56 +0800 Subject: [PATCH 07/34] refactor: small tweaks --- src/sinks/greptimedb/client.rs | 84 ++++++++++++++++++++++++++++------ src/sinks/greptimedb/mod.rs | 3 +- 2 files changed, 72 insertions(+), 15 deletions(-) diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/client.rs index 010f1e3c64e39..3036c27ae2faa 100644 --- a/src/sinks/greptimedb/client.rs +++ b/src/sinks/greptimedb/client.rs @@ -41,8 +41,7 @@ impl RetryLogic for GreptimeDBRetryLogic { type Response = GreptimeBatchOutput; fn is_retriable_error(&self, _error: &Self::Error) -> bool { - // TODO(sunng87): implement this - false + true } } @@ -78,13 +77,13 @@ impl GreptimeDBService { if let (Some(username), Some(password)) = (&config.username, &config.password) { client.set_auth(AuthScheme::Basic(Basic { username: username.to_owned(), - password: password.to_owned(), + password: password.clone().into(), })) } let batch = config.batch.into_batch_settings()?; let request = config.request.unwrap_with(&TowerRequestConfig { - retry_attempts: None, + retry_attempts: Some(1), ..Default::default() }); @@ -128,7 +127,7 @@ impl Service> for GreptimeDBService { fn call(&mut self, items: Vec) -> Self::Future { // TODO(sunng87): group metrics by name and send metrics with same name // in batch - let requests = items.into_iter().map(metrics_to_insert_request); + let requests = items.into_iter().map(metric_to_insert_request); let client = self.client.clone(); Box::pin(async move { @@ -181,8 +180,14 @@ fn tag_column(name: &str, value: &str) -> Column { } } -fn metrics_to_insert_request(metric: Metric) -> InsertRequest { +fn metric_to_insert_request(metric: Metric) -> InsertRequest { + let ns = metric.namespace(); let metric_name = metric.name(); + let table_name = if let Some(ns) = ns { + format!("{ns}_{metric_name}") + } else { + metric_name.to_owned() + }; let mut columns = Vec::new(); // timetamp @@ -233,7 +238,7 @@ fn metrics_to_insert_request(metric: Metric) -> InsertRequest { } InsertRequest { - table_name: metric_name.to_owned(), + table_name, columns, row_count: 1, ..Default::default() @@ -314,7 +319,7 @@ mod tests { fn get_column(columns: &[Column], name: &str) -> f64 { let col = columns.iter().find(|c| c.column_name == name).unwrap(); - *col.values.unwrap().f64_values.get(0).unwrap() + *(col.values.as_ref().unwrap().f64_values.get(0).unwrap()) } #[test] @@ -328,9 +333,9 @@ mod tests { .with_tags(Some([("host".to_owned(), "thinkneo".to_owned())].into())) .with_timestamp(Some(Utc::now())); - let insert = metrics_to_insert_request(metric); + let insert = metric_to_insert_request(metric); - assert_eq!(insert.table_name, "load1"); + assert_eq!(insert.table_name, "ns_load1"); assert_eq!(insert.row_count, 1); assert_eq!(insert.columns.len(), 3); @@ -344,6 +349,14 @@ mod tests { assert!(column_names.contains(&"value")); assert_eq!(get_column(&insert.columns, "value"), 1.1); + + let metric2 = Metric::new( + "load1", + MetricKind::Absolute, + MetricValue::Gauge { value: 1.1 }, + ); + let insert2 = metric_to_insert_request(metric2); + assert_eq!(insert2.table_name, "load1"); } #[test] @@ -353,7 +366,7 @@ mod tests { MetricKind::Incremental, MetricValue::Counter { value: 1.1 }, ); - let insert = metrics_to_insert_request(metric); + let insert = metric_to_insert_request(metric); assert_eq!(insert.columns.len(), 2); assert_eq!(get_column(&insert.columns, "value"), 1.1); @@ -365,10 +378,10 @@ mod tests { "cpu_seconds_total", MetricKind::Absolute, MetricValue::Set { - values: ["foo".to_owned(), "bar".to_owned()].iter().collect(), + values: ["foo".to_owned(), "bar".to_owned()].into_iter().collect(), }, ); - let insert = metrics_to_insert_request(metric); + let insert = metric_to_insert_request(metric); assert_eq!(insert.columns.len(), 2); assert_eq!(get_column(&insert.columns, "value"), 2.0); @@ -384,7 +397,7 @@ mod tests { statistic: StatisticKind::Histogram, }, ); - let insert = metrics_to_insert_request(metric); + let insert = metric_to_insert_request(metric); assert_eq!(insert.columns.len(), 11); assert_eq!(get_column(&insert.columns, "max"), 3.0); @@ -398,4 +411,47 @@ mod tests { assert_eq!(get_column(&insert.columns, "p95"), 3.0); assert_eq!(get_column(&insert.columns, "p99"), 3.0); } + + #[test] + fn test_histogram() { + let metric = Metric::new( + "cpu_seconds_totoal", + MetricKind::Incremental, + MetricValue::AggregatedHistogram { + buckets: vector_core::buckets![1.0 => 1, 2.0 => 2, 3.0 => 1], + count: 4, + sum: 8.0, + }, + ); + let insert = metric_to_insert_request(metric); + assert_eq!(insert.columns.len(), 5); + + assert_eq!(get_column(&insert.columns, "b1.0"), 1.0); + assert_eq!(get_column(&insert.columns, "b2.0"), 2.0); + assert_eq!(get_column(&insert.columns, "b3.0"), 1.0); + assert_eq!(get_column(&insert.columns, "count"), 4.0); + assert_eq!(get_column(&insert.columns, "sum"), 8.0); + } + + #[test] + fn test_summary() { + let metric = Metric::new( + "cpu_seconds_totoal", + MetricKind::Incremental, + MetricValue::AggregatedSummary { + quantiles: vector_core::quantiles![0.01 => 1.5, 0.5 => 2.0, 0.99 => 3.0], + count: 6, + sum: 12.0, + }, + ); + + let insert = metric_to_insert_request(metric); + assert_eq!(insert.columns.len(), 5); + + assert_eq!(get_column(&insert.columns, "p01"), 1.5); + assert_eq!(get_column(&insert.columns, "p50"), 2.0); + assert_eq!(get_column(&insert.columns, "p99"), 3.0); + assert_eq!(get_column(&insert.columns, "count"), 6.0); + assert_eq!(get_column(&insert.columns, "sum"), 12.0); + } } diff --git a/src/sinks/greptimedb/mod.rs b/src/sinks/greptimedb/mod.rs index f4414f25b78b0..c17715805052c 100644 --- a/src/sinks/greptimedb/mod.rs +++ b/src/sinks/greptimedb/mod.rs @@ -1,6 +1,7 @@ use futures_util::FutureExt; use http::StatusCode; use tower::Service; +use vector_common::sensitive_string::SensitiveString; use vector_config::configurable_component; use vector_core::config::{AcknowledgementsConfig, Input}; use vector_core::tls::{TlsConfig, TlsSettings}; @@ -49,7 +50,7 @@ pub struct GreptimeDBConfig { /// The password of greptimedb #[configurable(metadata(docs::examples = "password"))] #[serde(default)] - pub password: Option, + pub password: Option, #[configurable(derived)] #[serde(default)] From 6f7add64797a92ffea62d8a4407d01f2e9e2dce1 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Fri, 24 Mar 2023 10:17:53 +0800 Subject: [PATCH 08/34] test: add integration test wip --- src/sinks/greptimedb/client.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/client.rs index 3036c27ae2faa..586a02df3b113 100644 --- a/src/sinks/greptimedb/client.rs +++ b/src/sinks/greptimedb/client.rs @@ -455,3 +455,7 @@ mod tests { assert_eq!(get_column(&insert.columns, "sum"), 12.0); } } + +#[cfg(feature = "greptimedb-integration-tests")] +#[cfg(test)] +mod integration_tests {} From c51c2efd42598cdb90752efcf46a484b98aaa206 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Fri, 31 Mar 2023 10:27:06 +0800 Subject: [PATCH 09/34] feat: update greptimedb grpc client, dbname and healthcheck for grpc --- Cargo.toml | 2 +- src/sinks/greptimedb/client.rs | 11 +++---- src/sinks/greptimedb/mod.rs | 54 +++++++++------------------------- 3 files changed, 19 insertions(+), 48 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 495d708825cd5..4991f0175f6b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -226,7 +226,7 @@ hex = { version = "0.4.3", default-features = false, optional = true } sha2 = { version = "0.10.7", default-features = false, optional = true } # Greptime -greptimedb-client = { git = "https://github.com/GreptimeTeam/greptimedb.git", rev = "f6669a820112a10daf2e933ec34461454940f856", package = "client", optional = true } +greptimedb-client = { git = "https://github.com/GreptimeTeam/greptimedb.git", rev = "b5e5f8e555065da0ba1d3f13b6b76fad59cb4017", package = "client", optional = true } # VRL Lang vrl = { package = "vrl", version = "0.4.0", features = ["cli", "test"] } diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/client.rs index 586a02df3b113..4ac0d762962d1 100644 --- a/src/sinks/greptimedb/client.rs +++ b/src/sinks/greptimedb/client.rs @@ -8,9 +8,7 @@ use futures_util::future::BoxFuture; use greptimedb_client::api::v1::auth_header::AuthScheme; use greptimedb_client::api::v1::column::*; use greptimedb_client::api::v1::*; -use greptimedb_client::{ - Client, Database, Error as GreptimeError, DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME, -}; +use greptimedb_client::{Client, Database, Error as GreptimeError, DEFAULT_SCHEMA_NAME}; use tower::Service; use vector_core::event::metric::{Bucket, MetricSketch, Quantile, Sample}; use vector_core::event::{Event, Metric, MetricValue}; @@ -67,10 +65,9 @@ pub struct GreptimeDBService { impl GreptimeDBService { pub fn new_sink(config: &GreptimeDBConfig) -> crate::Result { - let grpc_client = Client::with_urls(vec![&config.grpc_endpoint]); - let mut client = Database::new( - config.catalog.as_deref().unwrap_or(DEFAULT_CATALOG_NAME), - config.schema.as_deref().unwrap_or(DEFAULT_SCHEMA_NAME), + let grpc_client = Client::with_urls(vec![&config.endpoint]); + let mut client = Database::new_with_dbname( + config.dbname.as_deref().unwrap_or(DEFAULT_SCHEMA_NAME), grpc_client, ); diff --git a/src/sinks/greptimedb/mod.rs b/src/sinks/greptimedb/mod.rs index c17715805052c..0a5f3746ecd50 100644 --- a/src/sinks/greptimedb/mod.rs +++ b/src/sinks/greptimedb/mod.rs @@ -1,13 +1,11 @@ use futures_util::FutureExt; -use http::StatusCode; -use tower::Service; +use greptimedb_client::Client; use vector_common::sensitive_string::SensitiveString; use vector_config::configurable_component; use vector_core::config::{AcknowledgementsConfig, Input}; -use vector_core::tls::{TlsConfig, TlsSettings}; +use vector_core::tls::TlsConfig; use crate::config::{SinkConfig, SinkContext}; -use crate::http::HttpClient; use crate::sinks::util::{BatchConfig, SinkBatchSettings}; use crate::sinks::{Healthcheck, VectorSink}; @@ -29,20 +27,13 @@ impl SinkBatchSettings for GreptimeDBDefaultBatchSettings { #[derive(Clone, Debug, Default)] #[serde(deny_unknown_fields)] pub struct GreptimeDBConfig { - /// The catalog name to connect - #[configurable(metadata(docs::examples = "greptime"))] - #[serde(default)] - pub catalog: Option, - /// The schema name to connect + /// The database name to connect #[configurable(metadata(docs::examples = "public"))] #[serde(default)] - pub schema: Option, + pub dbname: Option, /// The host and port of greptimedb grpc service - #[configurable(metadata(docs::examples = "localhost:4001"))] - pub grpc_endpoint: String, - /// The host and port of greptimedb http service - #[configurable(metadata(docs::examples = "http://localhost:4000"))] - pub http_endpoint: String, + #[configurable(metadata(docs::examples = "example.com:4001"))] + pub endpoint: String, /// The username of greptimedb #[configurable(metadata(docs::examples = "username"))] #[serde(default)] @@ -76,11 +67,9 @@ impl_generate_config_from_default!(GreptimeDBConfig); #[async_trait::async_trait] impl SinkConfig for GreptimeDBConfig { - async fn build(&self, cx: SinkContext) -> crate::Result<(VectorSink, Healthcheck)> { + async fn build(&self, _cx: SinkContext) -> crate::Result<(VectorSink, Healthcheck)> { let sink = client::GreptimeDBService::new_sink(&self)?; - let tls_settings = TlsSettings::from_options(&self.tls)?; - let http_client = HttpClient::new(tls_settings, cx.proxy())?; - let healthcheck = healthcheck(&self.http_endpoint, http_client)?; + let healthcheck = healthcheck(&self)?; Ok((sink, healthcheck)) } @@ -93,23 +82,10 @@ impl SinkConfig for GreptimeDBConfig { } } -fn healthcheck(endpoint: &str, mut client: HttpClient) -> crate::Result { - let uri = format!("{endpoint}/health"); - - let request = hyper::Request::get(uri).body(hyper::Body::empty()).unwrap(); - - Ok(async move { - client - .call(request) - .await - .map_err(|error| error.into()) - .and_then(|response| match response.status() { - StatusCode::OK => Ok(()), - StatusCode::NO_CONTENT => Ok(()), - other => Err(super::HealthcheckError::UnexpectedStatus { status: other }.into()), - }) - } - .boxed()) +fn healthcheck(config: &GreptimeDBConfig) -> crate::Result { + let client = Client::with_urls(vec![&config.endpoint]); + + Ok(async move { client.health_check().await.map_err(|error| error.into()) }.boxed()) } #[cfg(test)] @@ -126,10 +102,8 @@ mod tests { #[test] fn test_config_with_username() { let config = indoc! {r#" - grpc_endpoint = "foo-bar.ap-southeast-1.aws.greptime.cloud:4001" - http_endpoint = "http://alpha-bravo.ap-southeast-1.aws.greptime.cloud/health" - catalog = "foo" - schema = "bar" + endpoint = "foo-bar.ap-southeast-1.aws.greptime.cloud:4001" + dbname = "foo-bar" "#}; toml::from_str::(config).unwrap(); From e766b624c5143b6af3d3b56b958e661c253cae8b Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Thu, 6 Apr 2023 14:31:13 +0800 Subject: [PATCH 10/34] feat: change default timestmap column name to ts --- src/sinks/greptimedb/client.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/client.rs index 4ac0d762962d1..3d40cca8d52b1 100644 --- a/src/sinks/greptimedb/client.rs +++ b/src/sinks/greptimedb/client.rs @@ -192,7 +192,7 @@ fn metric_to_insert_request(metric: Metric) -> InsertRequest { .timestamp() .map(|t| t.timestamp_millis()) .unwrap_or_else(|| Utc::now().timestamp_millis()); - columns.push(ts_column("timestamp", timestamp)); + columns.push(ts_column("ts", timestamp)); // tags if let Some(tags) = metric.tags() { @@ -341,7 +341,7 @@ mod tests { .iter() .map(|c| c.column_name.as_ref()) .collect::>(); - assert!(column_names.contains(&"timestamp")); + assert!(column_names.contains(&"ts")); assert!(column_names.contains(&"host")); assert!(column_names.contains(&"value")); From 2c5cafcd44af12eaf8065399ce4dbb754f3e1f5f Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Tue, 11 Apr 2023 23:06:20 +0800 Subject: [PATCH 11/34] test: add integration tests for greptimedb --- .github/workflows/changes.yml | 3 + .github/workflows/integration-comment.yml | 2 + .github/workflows/integration.yml | 2 + Makefile | 2 +- scripts/integration/greptimedb/compose.yaml | 11 +++ scripts/integration/greptimedb/test.yaml | 12 ++++ src/sinks/greptimedb/client.rs | 77 ++++++++++++++++++++- 7 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 scripts/integration/greptimedb/compose.yaml create mode 100644 scripts/integration/greptimedb/test.yaml diff --git a/.github/workflows/changes.yml b/.github/workflows/changes.yml index db6c4225073e0..653d3395bdfda 100644 --- a/.github/workflows/changes.yml +++ b/.github/workflows/changes.yml @@ -70,6 +70,8 @@ on: value: ${{ jobs.int_tests.outputs.fluent }} gcp: value: ${{ jobs.int_tests.outputs.gcp }} + greptimedb: + value: ${{ jobs.int_tests.outputs.greptimedb }} humio: value: ${{ jobs.int_tests.outputs.humio }} http-client: @@ -194,6 +196,7 @@ jobs: eventstoredb: ${{ steps.filter.outputs.eventstoredb }} fluent: ${{ steps.filter.outputs.fluent }} gcp: ${{ steps.filter.outputs.gcp }} + greptimedb: ${{ steps.filter.outputs.greptimedb }} humio: ${{ steps.filter.outputs.humio }} http-client: ${{ steps.filter.outputs.http-client }} influxdb: ${{ steps.filter.outputs.influxdb }} diff --git a/.github/workflows/integration-comment.yml b/.github/workflows/integration-comment.yml index 629278ff95c20..e41c17a8f309e 100644 --- a/.github/workflows/integration-comment.yml +++ b/.github/workflows/integration-comment.yml @@ -110,6 +110,8 @@ jobs: if: ${{ contains(github.event.comment.body, '/ci-run-integration-fluent') || contains(github.event.comment.body, '/ci-run-all') }} - test_name: 'gcp' if: ${{ contains(github.event.comment.body, '/ci-run-integration-gcp') || contains(github.event.comment.body, '/ci-run-all') }} + - test_name: 'greptimedb' + if: ${{ contains(github.event.comment.body, '/ci-run-integration-greptimedb') || contains(github.event.comment.body, '/ci-run-all') }} - test_name: 'humio' if: ${{ contains(github.event.comment.body, '/ci-run-integration-humio') || contains(github.event.comment.body, '/ci-run-all') }} - test_name: 'http-client' diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 7f85870e7dff4..2a6a25c35bf8d 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -88,6 +88,8 @@ jobs: if: ${{ github.event_name == 'merge_group' || needs.changes.outputs.int-all == 'true' || needs.changes.outputs.fluent == 'true' }} - test_name: 'gcp' if: ${{ github.event_name == 'merge_group' || needs.changes.outputs.int-all == 'true' || needs.changes.outputs.gcp == 'true' }} + - test_name: 'greptimedb' + if: ${{ github.event_name == 'merge_group' || needs.changes.outputs.int-all == 'true' || needs.changes.outputs.greptimedb == 'true' }} - test_name: 'humio' if: ${{ github.event_name == 'merge_group' || needs.changes.outputs.int-all == 'true' || needs.changes.outputs.humio == 'true' }} - test_name: 'http-client' diff --git a/Makefile b/Makefile index d988725b612f8..c1c2970767305 100644 --- a/Makefile +++ b/Makefile @@ -332,7 +332,7 @@ test-behavior: test-behavior-transforms test-behavior-formats test-behavior-conf test-integration: ## Runs all integration tests test-integration: test-integration-amqp test-integration-appsignal test-integration-aws test-integration-axiom test-integration-azure test-integration-chronicle test-integration-clickhouse test-integration: test-integration-databend test-integration-docker-logs test-integration-elasticsearch -test-integration: test-integration-eventstoredb test-integration-fluent test-integration-gcp test-integration-humio test-integration-http-client test-integration-influxdb +test-integration: test-integration-eventstoredb test-integration-fluent test-integration-gcp test-integration-greptimedb test-integration-humio test-integration-http-client test-integration-influxdb test-integration: test-integration-kafka test-integration-logstash test-integration-loki test-integration-mongodb test-integration-nats test-integration: test-integration-nginx test-integration-opentelemetry test-integration-postgres test-integration-prometheus test-integration-pulsar test-integration: test-integration-redis test-integration-splunk test-integration-dnstap test-integration-datadog-agent test-integration-datadog-logs diff --git a/scripts/integration/greptimedb/compose.yaml b/scripts/integration/greptimedb/compose.yaml new file mode 100644 index 0000000000000..128ff7ae34043 --- /dev/null +++ b/scripts/integration/greptimedb/compose.yaml @@ -0,0 +1,11 @@ +version: '3' + +services: + greptimedb: + image: docker.io/greptime/greptimedb:${CONFIG_VERSION} + healthcheck: + test: "curl -f localhost:4000/health || exit 1" + +networks: + default: + name: ${VECTOR_NETWORK} diff --git a/scripts/integration/greptimedb/test.yaml b/scripts/integration/greptimedb/test.yaml new file mode 100644 index 0000000000000..6e15b265f8f59 --- /dev/null +++ b/scripts/integration/greptimedb/test.yaml @@ -0,0 +1,12 @@ +features: +- greptimedb-integration-tests + +test_filter: '::greptimedb::' + +runner: + env: + GREPTIMEDB_ENDPOINT: greptimedb:4001 + GREPTIMEDB_HTTP: greptimedb:4000 + +matrix: + version: ['latest'] diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/client.rs index 3d40cca8d52b1..15f161267404e 100644 --- a/src/sinks/greptimedb/client.rs +++ b/src/sinks/greptimedb/client.rs @@ -455,4 +455,79 @@ mod tests { #[cfg(feature = "greptimedb-integration-tests")] #[cfg(test)] -mod integration_tests {} +mod integration_tests { + use vector_core::event::MetricKind; + use vector_core::metric_tags; + + use crate::sinks::util::test::load_sink; + use crate::{ + config::{SinkConfig, SinkContext}, + test_util::{ + components::{run_and_assert_sink_compliance, SINK_TAGS}, + trace_init, + }, + }; + + use super::*; + + #[tokio::test] + async fn test_greptimedb_sink() { + trace_init(); + let cfg = format!( + r#"endpoint= "{}" +"#, + std::env::var("GREPTIMEDB_ENDPOINT").unwrap_or_else(|_| "localhost:4001".to_owned()) + ); + + let (config, _) = load_sink::(&cfg).unwrap(); + let (sink, _hc) = config.build(SinkContext::new_test()).await.unwrap(); + + let events: Vec<_> = (0..10).map(create_event).collect(); + run_and_assert_sink_compliance(sink, stream::iter(events), &SINK_TAGS).await; + + let query_client = query_client(); + let query_response = query_client + .get(&format!( + "{}/v1/sql", + std::env::var("GREPTIMEDB_HTTP") + .unwrap_or_else(|_| "http://localhost:4000".to_owned()) + )) + .query(&[("sql", "SELECT region, value FROM ms_mycounter")]) + .send() + .await + .unwrap() + .text() + .await + .expect("Fetch json from greptimedb failed"); + let result: serde_json::Value = serde_json::from_str(&query_response) + .expect("Invalid json returned from greptimedb query"); + assert_eq!( + result + .pointer("/output/0/records/rows") + .and_then(|v| v.as_array()) + .expect("Error getting greptimedb resposne array") + .len(), + 10 + ) + } + + fn query_client() -> reqwest::Client { + reqwest::Client::builder().build().unwrap() + } + + fn create_event(i: i32) -> Event { + Event::Metric( + Metric::new( + format!("mycounter"), + MetricKind::Incremental, + MetricValue::Counter { value: i as f64 }, + ) + .with_namespace(Some("ns")) + .with_tags(Some(metric_tags!( + "region" => "us-west-1", + "production" => "true", + ))) + .with_timestamp(Some(Utc::now())), + ) + } +} From 64704f75daab56e03cd53058fadd179cd6d02c79 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Thu, 4 May 2023 16:35:05 +0800 Subject: [PATCH 12/34] test: correct column count in test cases --- sample.toml | 19 +++++++++++++++++++ src/sinks/greptimedb/client.rs | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 sample.toml diff --git a/sample.toml b/sample.toml new file mode 100644 index 0000000000000..2698544b5f99c --- /dev/null +++ b/sample.toml @@ -0,0 +1,19 @@ +[sources.in] +type = "host_metrics" + +# [sources.prom] +# type = "prometheus_scrape" +# endpoints = [ "http://localhost:9100/metrics" ] + +[sinks.out] +inputs = ["in"] +type = "greptimedb" +endpoint = "localhost:4001" + +# [sinks.cloud] +# inputs = ["in"] +# type = "greptimedb" +# endpoint = "ri90pr79jvuf.test-ap-southeast-1.aws.greptime.cloud:4001" +# dbname = "rhe8afku6uws-test" +# username = "8eXxD6lHdbDYBVByQ0KjDsvp" +# password = "I7vppnCLFCaJevlGlf5dUBzX" diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/client.rs index 15f161267404e..b3d13c5a1171a 100644 --- a/src/sinks/greptimedb/client.rs +++ b/src/sinks/greptimedb/client.rs @@ -421,7 +421,7 @@ mod tests { }, ); let insert = metric_to_insert_request(metric); - assert_eq!(insert.columns.len(), 5); + assert_eq!(insert.columns.len(), 6); assert_eq!(get_column(&insert.columns, "b1.0"), 1.0); assert_eq!(get_column(&insert.columns, "b2.0"), 2.0); @@ -443,7 +443,7 @@ mod tests { ); let insert = metric_to_insert_request(metric); - assert_eq!(insert.columns.len(), 5); + assert_eq!(insert.columns.len(), 6); assert_eq!(get_column(&insert.columns, "p01"), 1.5); assert_eq!(get_column(&insert.columns, "p50"), 2.0); From 945cf901a3aa0bb28e8c6f8089b66072a6b354ba Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Thu, 4 May 2023 18:36:59 +0800 Subject: [PATCH 13/34] test: resolve lint and test errors --- src/sinks/greptimedb/client.rs | 17 +++++++++-------- src/sinks/greptimedb/mod.rs | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/client.rs index b3d13c5a1171a..0ae96bdb6b9f9 100644 --- a/src/sinks/greptimedb/client.rs +++ b/src/sinks/greptimedb/client.rs @@ -125,7 +125,7 @@ impl Service> for GreptimeDBService { // TODO(sunng87): group metrics by name and send metrics with same name // in batch let requests = items.into_iter().map(metric_to_insert_request); - let client = self.client.clone(); + let client = Arc::clone(&self.client); Box::pin(async move { let mut outputs = Vec::with_capacity(requests.len()); @@ -230,7 +230,7 @@ fn metric_to_insert_request(metric: Metric) -> InsertRequest { } MetricValue::Sketch { sketch } => { let MetricSketch::AgentDDSketch(sketch) = sketch; - encode_sketch(&sketch, &mut columns); + encode_sketch(sketch, &mut columns); } } @@ -252,7 +252,7 @@ fn encode_distribution(samples: &[Sample], columns: &mut Vec) { columns.push(f64_field("count", stats.count as f64)); for (quantile, value) in stats.quantiles { - columns.push(f64_field(&format!("p{:2}", quantile * 100f64), value)); + columns.push(f64_field(&format!("p{:02}", quantile * 100f64), value)); } } } @@ -266,7 +266,8 @@ fn encode_histogram(buckets: &[Bucket], columns: &mut Vec) { fn encode_quantiles(quantiles: &[Quantile], columns: &mut Vec) { for quantile in quantiles { - let column_name = format!("p{:2}", quantile.quantile * 100f64); + let column_name = format!("p{:02}", quantile.quantile * 100f64); + dbg!(&column_name); columns.push(f64_field(&column_name, quantile.value)); } } @@ -316,7 +317,7 @@ mod tests { fn get_column(columns: &[Column], name: &str) -> f64 { let col = columns.iter().find(|c| c.column_name == name).unwrap(); - *(col.values.as_ref().unwrap().f64_values.get(0).unwrap()) + *(col.values.as_ref().unwrap().f64_values.first().unwrap()) } #[test] @@ -423,9 +424,9 @@ mod tests { let insert = metric_to_insert_request(metric); assert_eq!(insert.columns.len(), 6); - assert_eq!(get_column(&insert.columns, "b1.0"), 1.0); - assert_eq!(get_column(&insert.columns, "b2.0"), 2.0); - assert_eq!(get_column(&insert.columns, "b3.0"), 1.0); + assert_eq!(get_column(&insert.columns, "b1"), 1.0); + assert_eq!(get_column(&insert.columns, "b2"), 2.0); + assert_eq!(get_column(&insert.columns, "b3"), 1.0); assert_eq!(get_column(&insert.columns, "count"), 4.0); assert_eq!(get_column(&insert.columns, "sum"), 8.0); } diff --git a/src/sinks/greptimedb/mod.rs b/src/sinks/greptimedb/mod.rs index 0a5f3746ecd50..52eed051a9f0d 100644 --- a/src/sinks/greptimedb/mod.rs +++ b/src/sinks/greptimedb/mod.rs @@ -68,8 +68,8 @@ impl_generate_config_from_default!(GreptimeDBConfig); #[async_trait::async_trait] impl SinkConfig for GreptimeDBConfig { async fn build(&self, _cx: SinkContext) -> crate::Result<(VectorSink, Healthcheck)> { - let sink = client::GreptimeDBService::new_sink(&self)?; - let healthcheck = healthcheck(&self)?; + let sink = client::GreptimeDBService::new_sink(self)?; + let healthcheck = healthcheck(self)?; Ok((sink, healthcheck)) } From 9c37da805da7742808aa82a7ffde26ae64a82bb1 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Fri, 5 May 2023 18:46:23 +0800 Subject: [PATCH 14/34] chore: switch to compact greptimedb rust client --- .github/actions/spelling/allow.txt | 2 ++ Cargo.lock | 21 +++++++++++++++++++++ Cargo.toml | 2 +- sample.toml | 19 ------------------- src/sinks/greptimedb/client.rs | 17 +++++++---------- 5 files changed, 31 insertions(+), 30 deletions(-) delete mode 100644 sample.toml diff --git a/.github/actions/spelling/allow.txt b/.github/actions/spelling/allow.txt index c3a73ef09667c..c37cb395d4754 100644 --- a/.github/actions/spelling/allow.txt +++ b/.github/actions/spelling/allow.txt @@ -295,6 +295,8 @@ gpg gql grafana graphiql +greptime +greptimedb gvisor gws hadoop diff --git a/Cargo.lock b/Cargo.lock index bd3922fd5ddbc..86fec948884e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4453,6 +4453,26 @@ dependencies = [ "tonic-build", ] +[[package]] +name = "greptimedb-client-rust" +version = "0.1.0" +source = "git+https://github.com/GreptimeTeam/greptimedb-client-rust.git?rev=2b5d575fd4aaff2955b20e59e752e1eba71c4b75#2b5d575fd4aaff2955b20e59e752e1eba71c4b75" +dependencies = [ + "dashmap", + "enum_dispatch", + "futures 0.3.28", + "futures-util", + "greptime-proto", + "parking_lot", + "prost", + "rand 0.8.5", + "snafu", + "tokio", + "tonic 0.9.2", + "tonic-build", + "tower", +] + [[package]] name = "grok" version = "2.0.0" @@ -10902,6 +10922,7 @@ dependencies = [ "glob", "goauth", "governor", + "greptimedb-client-rust", "grok", "h2", "hash_hasher", diff --git a/Cargo.toml b/Cargo.toml index 4991f0175f6b3..ed2a18cadd7a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -226,7 +226,7 @@ hex = { version = "0.4.3", default-features = false, optional = true } sha2 = { version = "0.10.7", default-features = false, optional = true } # Greptime -greptimedb-client = { git = "https://github.com/GreptimeTeam/greptimedb.git", rev = "b5e5f8e555065da0ba1d3f13b6b76fad59cb4017", package = "client", optional = true } +greptimedb-client = { git = "https://github.com/GreptimeTeam/greptimedb-client-rust.git", rev = "2b5d575fd4aaff2955b20e59e752e1eba71c4b75", package = "greptimedb-client-rust", optional = true } # VRL Lang vrl = { package = "vrl", version = "0.4.0", features = ["cli", "test"] } diff --git a/sample.toml b/sample.toml deleted file mode 100644 index 2698544b5f99c..0000000000000 --- a/sample.toml +++ /dev/null @@ -1,19 +0,0 @@ -[sources.in] -type = "host_metrics" - -# [sources.prom] -# type = "prometheus_scrape" -# endpoints = [ "http://localhost:9100/metrics" ] - -[sinks.out] -inputs = ["in"] -type = "greptimedb" -endpoint = "localhost:4001" - -# [sinks.cloud] -# inputs = ["in"] -# type = "greptimedb" -# endpoint = "ri90pr79jvuf.test-ap-southeast-1.aws.greptime.cloud:4001" -# dbname = "rhe8afku6uws-test" -# username = "8eXxD6lHdbDYBVByQ0KjDsvp" -# password = "I7vppnCLFCaJevlGlf5dUBzX" diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/client.rs index 0ae96bdb6b9f9..6fd0a244076e6 100644 --- a/src/sinks/greptimedb/client.rs +++ b/src/sinks/greptimedb/client.rs @@ -122,8 +122,6 @@ impl Service> for GreptimeDBService { // Convert vector metrics into GreptimeDB format and send them in batch fn call(&mut self, items: Vec) -> Self::Future { - // TODO(sunng87): group metrics by name and send metrics with same name - // in batch let requests = items.into_iter().map(metric_to_insert_request); let client = Arc::clone(&self.client); @@ -187,7 +185,7 @@ fn metric_to_insert_request(metric: Metric) -> InsertRequest { }; let mut columns = Vec::new(); - // timetamp + // timestamp let timestamp = metric .timestamp() .map(|t| t.timestamp_millis()) @@ -267,7 +265,6 @@ fn encode_histogram(buckets: &[Bucket], columns: &mut Vec) { fn encode_quantiles(quantiles: &[Quantile], columns: &mut Vec) { for quantile in quantiles { let column_name = format!("p{:02}", quantile.quantile * 100f64); - dbg!(&column_name); columns.push(f64_field(&column_name, quantile.value)); } } @@ -328,7 +325,7 @@ mod tests { MetricValue::Gauge { value: 1.1 }, ) .with_namespace(Some("ns")) - .with_tags(Some([("host".to_owned(), "thinkneo".to_owned())].into())) + .with_tags(Some([("host".to_owned(), "my_host".to_owned())].into())) .with_timestamp(Some(Utc::now())); let insert = metric_to_insert_request(metric); @@ -413,7 +410,7 @@ mod tests { #[test] fn test_histogram() { let metric = Metric::new( - "cpu_seconds_totoal", + "cpu_seconds_total", MetricKind::Incremental, MetricValue::AggregatedHistogram { buckets: vector_core::buckets![1.0 => 1, 2.0 => 2, 3.0 => 1], @@ -434,7 +431,7 @@ mod tests { #[test] fn test_summary() { let metric = Metric::new( - "cpu_seconds_totoal", + "cpu_seconds_total", MetricKind::Incremental, MetricValue::AggregatedSummary { quantiles: vector_core::quantiles![0.01 => 1.5, 0.5 => 2.0, 0.99 => 3.0], @@ -493,7 +490,7 @@ mod integration_tests { std::env::var("GREPTIMEDB_HTTP") .unwrap_or_else(|_| "http://localhost:4000".to_owned()) )) - .query(&[("sql", "SELECT region, value FROM ms_mycounter")]) + .query(&[("sql", "SELECT region, value FROM ns_my_counter")]) .send() .await .unwrap() @@ -506,7 +503,7 @@ mod integration_tests { result .pointer("/output/0/records/rows") .and_then(|v| v.as_array()) - .expect("Error getting greptimedb resposne array") + .expect("Error getting greptimedb response array") .len(), 10 ) @@ -519,7 +516,7 @@ mod integration_tests { fn create_event(i: i32) -> Event { Event::Metric( Metric::new( - format!("mycounter"), + format!("my_counter"), MetricKind::Incremental, MetricValue::Counter { value: i as f64 }, ) From a888bf92688a620447777cb76089dfeaf7601ed7 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Mon, 22 May 2023 15:37:45 +0800 Subject: [PATCH 15/34] docs: add website docs --- .../components/sinks/base/greptimedb.cue | 312 ++++++++++++++++++ 1 file changed, 312 insertions(+) create mode 100644 website/cue/reference/components/sinks/base/greptimedb.cue diff --git a/website/cue/reference/components/sinks/base/greptimedb.cue b/website/cue/reference/components/sinks/base/greptimedb.cue new file mode 100644 index 0000000000000..b0e5147b20e42 --- /dev/null +++ b/website/cue/reference/components/sinks/base/greptimedb.cue @@ -0,0 +1,312 @@ +package metadata + +base: components: sinks: greptimedb: configuration: { + acknowledgements: { + description: """ + Controls how acknowledgements are handled for this sink. + + See [End-to-end Acknowledgements][e2e_acks] for more information on how event acknowledgement is handled. + + [e2e_acks]: https://vector.dev/docs/about/under-the-hood/architecture/end-to-end-acknowledgements/ + """ + required: false + type: object: options: enabled: { + description: """ + Whether or not end-to-end acknowledgements are enabled. + + When enabled for a sink, any source connected to that sink, where the source supports + end-to-end acknowledgements as well, waits for events to be acknowledged by the sink + before acknowledging them at the source. + + Enabling or disabling acknowledgements at the sink level takes precedence over any global + [`acknowledgements`][global_acks] configuration. + + [global_acks]: https://vector.dev/docs/reference/configuration/global-options/#acknowledgements + """ + required: false + type: bool: {} + } + } + batch: { + description: "Event batching behavior." + required: false + type: object: options: { + max_bytes: { + description: """ + The maximum size of a batch that is processed by a sink. + + This is based on the uncompressed size of the batched events, before they are + serialized/compressed. + """ + required: false + type: uint: unit: "bytes" + } + max_events: { + description: "The maximum size of a batch before it is flushed." + required: false + type: uint: { + default: 20 + unit: "events" + } + } + timeout_secs: { + description: "The maximum age of a batch before it is flushed." + required: false + type: float: { + default: 1.0 + unit: "seconds" + } + } + } + } + dbname: { + description: "The database name to connect" + required: false + type: string: examples: [ + "public", + ] + } + endpoint: { + description: "The host and port of greptimedb grpc service" + required: true + type: string: examples: ["example.com:4001"] + } + password: { + description: "The password of greptimedb" + required: false + type: string: examples: ["password"] + } + request: { + description: """ + Middleware settings for outbound requests. + + Various settings can be configured, such as concurrency and rate limits, timeouts, etc. + """ + required: false + type: object: options: { + adaptive_concurrency: { + description: """ + Configuration of adaptive concurrency parameters. + + These parameters typically do not require changes from the default, and incorrect values can lead to meta-stable or + unstable performance and sink behavior. Proceed with caution. + """ + required: false + type: object: options: { + decrease_ratio: { + description: """ + The fraction of the current value to set the new concurrency limit when decreasing the limit. + + Valid values are greater than `0` and less than `1`. Smaller values cause the algorithm to scale back rapidly + when latency increases. + + Note that the new limit is rounded down after applying this ratio. + """ + required: false + type: float: default: 0.9 + } + ewma_alpha: { + description: """ + The weighting of new measurements compared to older measurements. + + Valid values are greater than `0` and less than `1`. + + ARC uses an exponentially weighted moving average (EWMA) of past RTT measurements as a reference to compare with + the current RTT. Smaller values cause this reference to adjust more slowly, which may be useful if a service has + unusually high response variability. + """ + required: false + type: float: default: 0.4 + } + rtt_deviation_scale: { + description: """ + Scale of RTT deviations which are not considered anomalous. + + Valid values are greater than or equal to `0`, and we expect reasonable values to range from `1.0` to `3.0`. + + When calculating the past RTT average, we also compute a secondary “deviation” value that indicates how variable + those values are. We use that deviation when comparing the past RTT average to the current measurements, so we + can ignore increases in RTT that are within an expected range. This factor is used to scale up the deviation to + an appropriate range. Larger values cause the algorithm to ignore larger increases in the RTT. + """ + required: false + type: float: default: 2.5 + } + } + } + concurrency: { + description: "Configuration for outbound request concurrency." + required: false + type: { + string: { + default: "none" + enum: { + adaptive: """ + Concurrency will be managed by Vector's [Adaptive Request Concurrency][arc] feature. + + [arc]: https://vector.dev/docs/about/under-the-hood/networking/arc/ + """ + none: """ + A fixed concurrency of 1. + + Only one request can be outstanding at any given time. + """ + } + } + uint: {} + } + } + rate_limit_duration_secs: { + description: "The time window used for the `rate_limit_num` option." + required: false + type: uint: { + default: 1 + unit: "seconds" + } + } + rate_limit_num: { + description: "The maximum number of requests allowed within the `rate_limit_duration_secs` time window." + required: false + type: uint: { + default: 9223372036854775807 + unit: "requests" + } + } + retry_attempts: { + description: """ + The maximum number of retries to make for failed requests. + + The default, for all intents and purposes, represents an infinite number of retries. + """ + required: false + type: uint: { + default: 9223372036854775807 + unit: "retries" + } + } + retry_initial_backoff_secs: { + description: """ + The amount of time to wait before attempting the first retry for a failed request. + + After the first retry has failed, the fibonacci sequence is used to select future backoffs. + """ + required: false + type: uint: { + default: 1 + unit: "seconds" + } + } + retry_max_duration_secs: { + description: "The maximum amount of time to wait between retries." + required: false + type: uint: { + default: 3600 + unit: "seconds" + } + } + timeout_secs: { + description: """ + The time a request can take before being aborted. + + Datadog highly recommends that you do not lower this value below the service's internal timeout, as this could + create orphaned requests, pile on retries, and result in duplicate data downstream. + """ + required: false + type: uint: { + default: 60 + unit: "seconds" + } + } + } + } + tls: { + description: "TLS configuration." + required: false + type: object: options: { + alpn_protocols: { + description: """ + Sets the list of supported ALPN protocols. + + Declare the supported ALPN protocols, which are used during negotiation with peer. They are prioritized in the order + that they are defined. + """ + required: false + type: array: items: type: string: examples: ["h2"] + } + ca_file: { + description: """ + Absolute path to an additional CA certificate file. + + The certificate must be in the DER or PEM (X.509) format. Additionally, the certificate can be provided as an inline string in PEM format. + """ + required: false + type: string: examples: ["/path/to/certificate_authority.crt"] + } + crt_file: { + description: """ + Absolute path to a certificate file used to identify this server. + + The certificate must be in DER, PEM (X.509), or PKCS#12 format. Additionally, the certificate can be provided as + an inline string in PEM format. + + If this is set, and is not a PKCS#12 archive, `key_file` must also be set. + """ + required: false + type: string: examples: ["/path/to/host_certificate.crt"] + } + key_file: { + description: """ + Absolute path to a private key file used to identify this server. + + The key must be in DER or PEM (PKCS#8) format. Additionally, the key can be provided as an inline string in PEM format. + """ + required: false + type: string: examples: ["/path/to/host_certificate.key"] + } + key_pass: { + description: """ + Passphrase used to unlock the encrypted key file. + + This has no effect unless `key_file` is set. + """ + required: false + type: string: examples: ["${KEY_PASS_ENV_VAR}", "PassWord1"] + } + verify_certificate: { + description: """ + Enables certificate verification. + + If enabled, certificates must not be expired and must be issued by a trusted + issuer. This verification operates in a hierarchical manner, checking that the leaf certificate (the + certificate presented by the client/server) is not only valid, but that the issuer of that certificate is also valid, and + so on until the verification process reaches a root certificate. + + Relevant for both incoming and outgoing connections. + + Do NOT set this to `false` unless you understand the risks of not verifying the validity of certificates. + """ + required: false + type: bool: {} + } + verify_hostname: { + description: """ + Enables hostname verification. + + If enabled, the hostname used to connect to the remote host must be present in the TLS certificate presented by + the remote host, either as the Common Name or as an entry in the Subject Alternative Name extension. + + Only relevant for outgoing connections. + + Do NOT set this to `false` unless you understand the risks of not verifying the remote hostname. + """ + required: false + type: bool: {} + } + } + } + username: { + description: "The username of greptimedb" + required: false + type: string: examples: ["username"] + } +} From 2bfbce3663d4fae86020b18dc3d1d7da25e328a9 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Mon, 22 May 2023 18:09:48 +0800 Subject: [PATCH 16/34] chore: update 3rd-party license file --- Cargo.lock | 2 +- LICENSE-3rdparty.csv | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 86fec948884e6..6e46e77ccdd27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4468,7 +4468,7 @@ dependencies = [ "rand 0.8.5", "snafu", "tokio", - "tonic 0.9.2", + "tonic", "tonic-build", "tower", ] diff --git a/LICENSE-3rdparty.csv b/LICENSE-3rdparty.csv index 2af031a4db1ea..71104fde06065 100644 --- a/LICENSE-3rdparty.csv +++ b/LICENSE-3rdparty.csv @@ -215,6 +215,8 @@ graphql-parser,https://github.com/graphql-rust/graphql-parser,MIT OR Apache-2.0, graphql_client,https://github.com/graphql-rust/graphql-client,Apache-2.0 OR MIT,Tom Houlé graphql_client_codegen,https://github.com/graphql-rust/graphql-client,Apache-2.0 OR MIT,Tom Houlé graphql_query_derive,https://github.com/graphql-rust/graphql-client,Apache-2.0 OR MIT,Tom Houlé +greptime-proto,https://github.com/GreptimeTeam/greptime-proto,Apache-2.0,The greptime-proto Authors +greptimedb-client-rust,https://github.com/GreptimeTeam/greptimedb-client-rust,Apache-2.0,The greptimedb-client-rust Authors grok,https://github.com/daschl/grok,Apache-2.0,Michael Nitschinger h2,https://github.com/hyperium/h2,MIT,"Carl Lerche , Sean McArthur " hash_hasher,https://github.com/Fraser999/Hash-Hasher,Apache-2.0 OR MIT,Fraser Hutchison From b4774ffc5ae7044e9b4b458dbb60edef877f7c1d Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Wed, 24 May 2023 16:20:01 +0800 Subject: [PATCH 17/34] fix: add greptimedb-integration-tests feature --- Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index ed2a18cadd7a7..21e215caae06b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -740,6 +740,7 @@ all-integration-tests = [ "gcp-cloud-storage-integration-tests", "gcp-integration-tests", "gcp-pubsub-integration-tests", + "greptimedb-integration-tests", "http-client-integration-tests", "humio-integration-tests", "influxdb-integration-tests", @@ -801,6 +802,7 @@ fluent-integration-tests = ["docker", "sources-fluent"] gcp-cloud-storage-integration-tests = ["sinks-gcp"] gcp-integration-tests = ["sinks-gcp"] gcp-pubsub-integration-tests = ["sinks-gcp", "sources-gcp_pubsub"] +greptimedb-integration-tests = ["sinks-greptimedb"] humio-integration-tests = ["sinks-humio"] http-client-integration-tests = ["sources-http_client"] influxdb-integration-tests = ["sinks-influxdb"] From 31107a41206c3a88e8ac7ea1250f3700dc66959b Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Thu, 25 May 2023 15:17:36 +0800 Subject: [PATCH 18/34] chore: remove network section from integration tests --- scripts/integration/greptimedb/compose.yaml | 4 ---- scripts/integration/greptimedb/test.yaml | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/integration/greptimedb/compose.yaml b/scripts/integration/greptimedb/compose.yaml index 128ff7ae34043..4836cd7d11179 100644 --- a/scripts/integration/greptimedb/compose.yaml +++ b/scripts/integration/greptimedb/compose.yaml @@ -5,7 +5,3 @@ services: image: docker.io/greptime/greptimedb:${CONFIG_VERSION} healthcheck: test: "curl -f localhost:4000/health || exit 1" - -networks: - default: - name: ${VECTOR_NETWORK} diff --git a/scripts/integration/greptimedb/test.yaml b/scripts/integration/greptimedb/test.yaml index 6e15b265f8f59..b428b37a03ed2 100644 --- a/scripts/integration/greptimedb/test.yaml +++ b/scripts/integration/greptimedb/test.yaml @@ -6,7 +6,7 @@ test_filter: '::greptimedb::' runner: env: GREPTIMEDB_ENDPOINT: greptimedb:4001 - GREPTIMEDB_HTTP: greptimedb:4000 + GREPTIMEDB_HTTP: http://greptimedb:4000 matrix: version: ['latest'] From 2dc19f51b0f931e1e1d1b66bb7ac29c5f91da234 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Fri, 2 Jun 2023 10:35:03 +0800 Subject: [PATCH 19/34] fix: resolve new lint warnings --- src/sinks/greptimedb/client.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/client.rs index 6fd0a244076e6..f8029fa1fb2a5 100644 --- a/src/sinks/greptimedb/client.rs +++ b/src/sinks/greptimedb/client.rs @@ -14,6 +14,7 @@ use vector_core::event::metric::{Bucket, MetricSketch, Quantile, Sample}; use vector_core::event::{Event, Metric, MetricValue}; use vector_core::metrics::AgentDDSketch; use vector_core::ByteSizeOf; +use vector_core::EstimatedJsonEncodedSizeOf; use super::GreptimeDBConfig; use crate::sinks::util::buffer::metrics::MetricNormalize; @@ -100,9 +101,10 @@ impl GreptimeDBService { .with_flat_map(move |event: Event| { stream::iter({ let byte_size = event.size_of(); + let json_size = event.estimated_json_encoded_size_of(); normalizer .normalize(event.into_metric()) - .map(|metric| Ok(EncodedEvent::new(metric, byte_size))) + .map(|metric| Ok(EncodedEvent::new(metric, byte_size, json_size))) }) }) .sink_map_err(|e| error!(message = "Fatal greptimedb sink error.", %e)); @@ -516,7 +518,7 @@ mod integration_tests { fn create_event(i: i32) -> Event { Event::Metric( Metric::new( - format!("my_counter"), + "my_counter".to_owned(), MetricKind::Incremental, MetricValue::Counter { value: i as f64 }, ) From 352bd135890d8afd9c6442b301999a7d44db8351 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Wed, 7 Jun 2023 22:19:20 +0800 Subject: [PATCH 20/34] test: fix compose file by adding command --- scripts/integration/greptimedb/compose.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/integration/greptimedb/compose.yaml b/scripts/integration/greptimedb/compose.yaml index 4836cd7d11179..7cd131240b49d 100644 --- a/scripts/integration/greptimedb/compose.yaml +++ b/scripts/integration/greptimedb/compose.yaml @@ -3,5 +3,6 @@ version: '3' services: greptimedb: image: docker.io/greptime/greptimedb:${CONFIG_VERSION} + command: "standalone start --http-addr=0.0.0.0:4000 --rpc-addr=0.0.0.0:4001" healthcheck: test: "curl -f localhost:4000/health || exit 1" From b320d6142978fc70f0f41a0edc66db8177dfc876 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Tue, 6 Jun 2023 10:50:56 +0800 Subject: [PATCH 21/34] feat: use latest client protocol --- Cargo.lock | 4 ++-- Cargo.toml | 4 ++-- src/sinks/greptimedb/client.rs | 15 +++++++-------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6e46e77ccdd27..6b2a246d9f302 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4444,7 +4444,7 @@ dependencies = [ [[package]] name = "greptime-proto" version = "0.1.0" -source = "git+https://github.com/GreptimeTeam/greptime-proto.git?rev=ff0a47b6462bf196cbcd01b589c5dddfa6bfbc45#ff0a47b6462bf196cbcd01b589c5dddfa6bfbc45" +source = "git+https://github.com/GreptimeTeam/greptime-proto.git?tag=0.2.1#4398d20c56d5f7939cc2960789cb1fa7dd18e6fe" dependencies = [ "prost", "serde", @@ -4456,7 +4456,7 @@ dependencies = [ [[package]] name = "greptimedb-client-rust" version = "0.1.0" -source = "git+https://github.com/GreptimeTeam/greptimedb-client-rust.git?rev=2b5d575fd4aaff2955b20e59e752e1eba71c4b75#2b5d575fd4aaff2955b20e59e752e1eba71c4b75" +source = "git+https://github.com/GreptimeTeam/greptimedb-client-rust.git?rev=48121652b8e6dfb95abefcf342808a4e78d024b4#48121652b8e6dfb95abefcf342808a4e78d024b4" dependencies = [ "dashmap", "enum_dispatch", diff --git a/Cargo.toml b/Cargo.toml index 21e215caae06b..dc3dfde84eac6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -225,8 +225,8 @@ tui = { version = "0.19.0", optional = true, default-features = false, features hex = { version = "0.4.3", default-features = false, optional = true } sha2 = { version = "0.10.7", default-features = false, optional = true } -# Greptime -greptimedb-client = { git = "https://github.com/GreptimeTeam/greptimedb-client-rust.git", rev = "2b5d575fd4aaff2955b20e59e752e1eba71c4b75", package = "greptimedb-client-rust", optional = true } +# GreptimeDB +greptimedb-client = { git = "https://github.com/GreptimeTeam/greptimedb-client-rust.git", rev = "48121652b8e6dfb95abefcf342808a4e78d024b4", package = "greptimedb-client-rust", optional = true } # VRL Lang vrl = { package = "vrl", version = "0.4.0", features = ["cli", "test"] } diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/client.rs index f8029fa1fb2a5..dc46db97a5a31 100644 --- a/src/sinks/greptimedb/client.rs +++ b/src/sinks/greptimedb/client.rs @@ -28,7 +28,7 @@ use crate::sinks::util::{EncodedEvent, TowerRequestConfig}; use crate::sinks::VectorSink; #[derive(Debug)] -pub struct GreptimeBatchOutput(Vec); +pub struct GreptimeBatchOutput(u32); impl Response for GreptimeBatchOutput {} @@ -124,16 +124,15 @@ impl Service> for GreptimeDBService { // Convert vector metrics into GreptimeDB format and send them in batch fn call(&mut self, items: Vec) -> Self::Future { - let requests = items.into_iter().map(metric_to_insert_request); + let requests = items + .into_iter() + .map(metric_to_insert_request) + .collect::>(); let client = Arc::clone(&self.client); Box::pin(async move { - let mut outputs = Vec::with_capacity(requests.len()); - for request in requests { - let result = client.insert(request).await?; - outputs.push(result); - } - Ok(GreptimeBatchOutput(outputs)) + let result = client.insert(requests).await?; + Ok(GreptimeBatchOutput(result)) }) } } From 26a7a61964cc1def6b0b08bced04e8be58fe7a71 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Sun, 11 Jun 2023 21:34:21 +0800 Subject: [PATCH 22/34] refactor: use stream sink apis --- src/sinks/greptimedb/batch.rs | 39 +++ src/sinks/greptimedb/integration_tests.rs | 73 ++++++ src/sinks/greptimedb/mod.rs | 16 +- .../{client.rs => request_builder.rs} | 222 +----------------- src/sinks/greptimedb/service.rs | 140 +++++++++++ src/sinks/greptimedb/sink.rs | 56 +++++ 6 files changed, 329 insertions(+), 217 deletions(-) create mode 100644 src/sinks/greptimedb/batch.rs create mode 100644 src/sinks/greptimedb/integration_tests.rs rename src/sinks/greptimedb/{client.rs => request_builder.rs} (59%) create mode 100644 src/sinks/greptimedb/service.rs create mode 100644 src/sinks/greptimedb/sink.rs diff --git a/src/sinks/greptimedb/batch.rs b/src/sinks/greptimedb/batch.rs new file mode 100644 index 0000000000000..ab85bf7ac9ee7 --- /dev/null +++ b/src/sinks/greptimedb/batch.rs @@ -0,0 +1,39 @@ +use vector_core::{ + event::{Metric, MetricValue}, + stream::batcher::limiter::ItemBatchSize, +}; + +#[derive(Default)] +pub(super) struct GreptimeDBBatchSizer; + +impl GreptimeDBBatchSizer { + pub(super) fn estimated_size_of(&self, item: &Metric) -> usize { + // Metric name. + item.series().name().name().len() + // Metric namespace, with an additional 1 to account for the namespace separator. + + item.series().name().namespace().map(|s| s.len() + 1).unwrap_or(0) + // Metric tags, with an additional 1 per tag to account for the tag key/value separator. + + item.series().tags().map(|t| { + t.iter_all().map(|(k, v)| { + k.len() + 1 + v.map(|v| v.len()).unwrap_or(0) + }) + .sum() + }) + .unwrap_or(0) + + + // value size + match item.value() { + MetricValue::Counter { .. } | MetricValue::Gauge { .. } | MetricValue::Set { ..} => 8, + MetricValue::Distribution { .. } => 8 * 10, + MetricValue::AggregatedHistogram { buckets, .. } => 8 * (buckets.len() + 2), + MetricValue::AggregatedSummary { quantiles, .. } => 8 * (quantiles.len() + 2), + MetricValue::Sketch { .. } => 8 * 10, + } + } +} + +impl ItemBatchSize for GreptimeDBBatchSizer { + fn size(&self, item: &Metric) -> usize { + self.estimated_size_of(item) + } +} diff --git a/src/sinks/greptimedb/integration_tests.rs b/src/sinks/greptimedb/integration_tests.rs new file mode 100644 index 0000000000000..f7e57f08f9eb0 --- /dev/null +++ b/src/sinks/greptimedb/integration_tests.rs @@ -0,0 +1,73 @@ +use vector_core::event::MetricKind; +use vector_core::metric_tags; + +use crate::sinks::util::test::load_sink; +use crate::{ + config::{SinkConfig, SinkContext}, + test_util::{ + components::{run_and_assert_sink_compliance, SINK_TAGS}, + trace_init, + }, +}; + +use super::*; + +#[tokio::test] +async fn test_greptimedb_sink() { + trace_init(); + let cfg = format!( + r#"endpoint= "{}" +"#, + std::env::var("GREPTIMEDB_ENDPOINT").unwrap_or_else(|_| "localhost:4001".to_owned()) + ); + + let (config, _) = load_sink::(&cfg).unwrap(); + let (sink, _hc) = config.build(SinkContext::new_test()).await.unwrap(); + + let events: Vec<_> = (0..10).map(create_event).collect(); + run_and_assert_sink_compliance(sink, stream::iter(events), &SINK_TAGS).await; + + let query_client = query_client(); + let query_response = query_client + .get(&format!( + "{}/v1/sql", + std::env::var("GREPTIMEDB_HTTP").unwrap_or_else(|_| "http://localhost:4000".to_owned()) + )) + .query(&[("sql", "SELECT region, value FROM ns_my_counter")]) + .send() + .await + .unwrap() + .text() + .await + .expect("Fetch json from greptimedb failed"); + let result: serde_json::Value = + serde_json::from_str(&query_response).expect("Invalid json returned from greptimedb query"); + assert_eq!( + result + .pointer("/output/0/records/rows") + .and_then(|v| v.as_array()) + .expect("Error getting greptimedb response array") + .len(), + 10 + ) +} + +fn query_client() -> reqwest::Client { + reqwest::Client::builder().build().unwrap() +} + +fn create_event(i: i32) -> Event { + Event::Metric( + Metric::new( + "my_counter".to_owned(), + MetricKind::Incremental, + MetricValue::Counter { value: i as f64 }, + ) + .with_namespace(Some("ns")) + .with_tags(Some(metric_tags!( + "region" => "us-west-1", + "production" => "true", + ))) + .with_timestamp(Some(Utc::now())), + ) +} diff --git a/src/sinks/greptimedb/mod.rs b/src/sinks/greptimedb/mod.rs index 52eed051a9f0d..f1b84136ac8f1 100644 --- a/src/sinks/greptimedb/mod.rs +++ b/src/sinks/greptimedb/mod.rs @@ -11,7 +11,12 @@ use crate::sinks::{Healthcheck, VectorSink}; use super::util::TowerRequestConfig; -mod client; +mod batch; +#[cfg(all(test, feature = "greptimedb-integration-tests"))] +mod integration_tests; +mod request_builder; +mod service; +mod sink; #[derive(Clone, Copy, Debug, Default)] pub struct GreptimeDBDefaultBatchSettings; @@ -68,9 +73,14 @@ impl_generate_config_from_default!(GreptimeDBConfig); #[async_trait::async_trait] impl SinkConfig for GreptimeDBConfig { async fn build(&self, _cx: SinkContext) -> crate::Result<(VectorSink, Healthcheck)> { - let sink = client::GreptimeDBService::new_sink(self)?; + let service = service::GreptimeDBService::new(self); + let sink = sink::GreptimeDBSink { + service, + batch_settings: self.batch.into_batcher_settings()?, + }; + let healthcheck = healthcheck(self)?; - Ok((sink, healthcheck)) + Ok((VectorSink::from_event_streamsink(sink), healthcheck)) } fn input(&self) -> Input { diff --git a/src/sinks/greptimedb/client.rs b/src/sinks/greptimedb/request_builder.rs similarity index 59% rename from src/sinks/greptimedb/client.rs rename to src/sinks/greptimedb/request_builder.rs index dc46db97a5a31..f9e9154bddb80 100644 --- a/src/sinks/greptimedb/client.rs +++ b/src/sinks/greptimedb/request_builder.rs @@ -1,141 +1,11 @@ -use std::sync::Arc; -use std::task::Poll; - use chrono::Utc; -use futures::stream; -use futures::SinkExt; -use futures_util::future::BoxFuture; -use greptimedb_client::api::v1::auth_header::AuthScheme; use greptimedb_client::api::v1::column::*; use greptimedb_client::api::v1::*; -use greptimedb_client::{Client, Database, Error as GreptimeError, DEFAULT_SCHEMA_NAME}; -use tower::Service; use vector_core::event::metric::{Bucket, MetricSketch, Quantile, Sample}; -use vector_core::event::{Event, Metric, MetricValue}; +use vector_core::event::{Metric, MetricValue}; use vector_core::metrics::AgentDDSketch; -use vector_core::ByteSizeOf; -use vector_core::EstimatedJsonEncodedSizeOf; - -use super::GreptimeDBConfig; -use crate::sinks::util::buffer::metrics::MetricNormalize; -use crate::sinks::util::buffer::metrics::MetricNormalizer; -use crate::sinks::util::buffer::metrics::MetricSet; -use crate::sinks::util::buffer::metrics::MetricsBuffer; -use crate::sinks::util::retries::RetryLogic; -use crate::sinks::util::sink::Response; -use crate::sinks::util::statistic::DistributionStatistic; -use crate::sinks::util::{EncodedEvent, TowerRequestConfig}; -use crate::sinks::VectorSink; - -#[derive(Debug)] -pub struct GreptimeBatchOutput(u32); - -impl Response for GreptimeBatchOutput {} - -#[derive(Clone)] -struct GreptimeDBRetryLogic; - -impl RetryLogic for GreptimeDBRetryLogic { - type Error = GreptimeError; - type Response = GreptimeBatchOutput; - - fn is_retriable_error(&self, _error: &Self::Error) -> bool { - true - } -} - -#[derive(Clone, Debug, Default)] -struct GreptimeDBMetricNormalize; - -impl MetricNormalize for GreptimeDBMetricNormalize { - fn normalize(&mut self, state: &mut MetricSet, metric: Metric) -> Option { - match (metric.kind(), &metric.value()) { - (_, MetricValue::Counter { .. }) => state.make_absolute(metric), - (_, MetricValue::Gauge { .. }) => state.make_absolute(metric), - // All others are left as-is - _ => Some(metric), - } - } -} - -#[derive(Debug, Clone)] -pub struct GreptimeDBService { - /// the client that connects to greptimedb - client: Arc, -} - -impl GreptimeDBService { - pub fn new_sink(config: &GreptimeDBConfig) -> crate::Result { - let grpc_client = Client::with_urls(vec![&config.endpoint]); - let mut client = Database::new_with_dbname( - config.dbname.as_deref().unwrap_or(DEFAULT_SCHEMA_NAME), - grpc_client, - ); - - if let (Some(username), Some(password)) = (&config.username, &config.password) { - client.set_auth(AuthScheme::Basic(Basic { - username: username.to_owned(), - password: password.clone().into(), - })) - } - - let batch = config.batch.into_batch_settings()?; - let request = config.request.unwrap_with(&TowerRequestConfig { - retry_attempts: Some(1), - ..Default::default() - }); - - let greptime_service = GreptimeDBService { - client: Arc::new(client), - }; - - let mut normalizer = MetricNormalizer::::default(); - - let sink = request - .batch_sink( - GreptimeDBRetryLogic, - greptime_service, - MetricsBuffer::new(batch.size), - batch.timeout, - ) - .with_flat_map(move |event: Event| { - stream::iter({ - let byte_size = event.size_of(); - let json_size = event.estimated_json_encoded_size_of(); - normalizer - .normalize(event.into_metric()) - .map(|metric| Ok(EncodedEvent::new(metric, byte_size, json_size))) - }) - }) - .sink_map_err(|e| error!(message = "Fatal greptimedb sink error.", %e)); - - Ok(VectorSink::from_event_sink(sink)) - } -} -impl Service> for GreptimeDBService { - type Response = GreptimeBatchOutput; - type Error = GreptimeError; - type Future = BoxFuture<'static, Result>; - - fn poll_ready(&mut self, _cx: &mut std::task::Context) -> Poll> { - Poll::Ready(Ok(())) - } - - // Convert vector metrics into GreptimeDB format and send them in batch - fn call(&mut self, items: Vec) -> Self::Future { - let requests = items - .into_iter() - .map(metric_to_insert_request) - .collect::>(); - let client = Arc::clone(&self.client); - - Box::pin(async move { - let result = client.insert(requests).await?; - Ok(GreptimeBatchOutput(result)) - }) - } -} +use crate::sinks::util::statistic::DistributionStatistic; fn f64_field(name: &str, value: f64) -> Column { Column { @@ -176,7 +46,7 @@ fn tag_column(name: &str, value: &str) -> Column { } } -fn metric_to_insert_request(metric: Metric) -> InsertRequest { +pub(super) fn metric_to_insert_request(metric: Metric) -> InsertRequest { let ns = metric.namespace(); let metric_name = metric.name(); let table_name = if let Some(ns) = ns { @@ -242,7 +112,9 @@ fn metric_to_insert_request(metric: Metric) -> InsertRequest { } fn encode_distribution(samples: &[Sample], columns: &mut Vec) { - if let Some(stats) = DistributionStatistic::from_samples(samples, &[0.75, 0.90, 0.95, 0.99]) { + if let Some(stats) = + DistributionStatistic::from_samples(samples, &[0.5, 0.75, 0.90, 0.95, 0.99]) + { columns.push(f64_field("min", stats.min)); columns.push(f64_field("max", stats.max)); columns.push(f64_field("median", stats.median)); @@ -394,7 +266,7 @@ mod tests { }, ); let insert = metric_to_insert_request(metric); - assert_eq!(insert.columns.len(), 11); + assert_eq!(insert.columns.len(), 12); assert_eq!(get_column(&insert.columns, "max"), 3.0); assert_eq!(get_column(&insert.columns, "min"), 1.0); @@ -402,6 +274,7 @@ mod tests { assert_eq!(get_column(&insert.columns, "avg"), 2.0); assert_eq!(get_column(&insert.columns, "sum"), 16.0); assert_eq!(get_column(&insert.columns, "count"), 8.0); + assert_eq!(get_column(&insert.columns, "p50"), 2.0); assert_eq!(get_column(&insert.columns, "p75"), 2.0); assert_eq!(get_column(&insert.columns, "p90"), 3.0); assert_eq!(get_column(&insert.columns, "p95"), 3.0); @@ -451,82 +324,3 @@ mod tests { assert_eq!(get_column(&insert.columns, "sum"), 12.0); } } - -#[cfg(feature = "greptimedb-integration-tests")] -#[cfg(test)] -mod integration_tests { - use vector_core::event::MetricKind; - use vector_core::metric_tags; - - use crate::sinks::util::test::load_sink; - use crate::{ - config::{SinkConfig, SinkContext}, - test_util::{ - components::{run_and_assert_sink_compliance, SINK_TAGS}, - trace_init, - }, - }; - - use super::*; - - #[tokio::test] - async fn test_greptimedb_sink() { - trace_init(); - let cfg = format!( - r#"endpoint= "{}" -"#, - std::env::var("GREPTIMEDB_ENDPOINT").unwrap_or_else(|_| "localhost:4001".to_owned()) - ); - - let (config, _) = load_sink::(&cfg).unwrap(); - let (sink, _hc) = config.build(SinkContext::new_test()).await.unwrap(); - - let events: Vec<_> = (0..10).map(create_event).collect(); - run_and_assert_sink_compliance(sink, stream::iter(events), &SINK_TAGS).await; - - let query_client = query_client(); - let query_response = query_client - .get(&format!( - "{}/v1/sql", - std::env::var("GREPTIMEDB_HTTP") - .unwrap_or_else(|_| "http://localhost:4000".to_owned()) - )) - .query(&[("sql", "SELECT region, value FROM ns_my_counter")]) - .send() - .await - .unwrap() - .text() - .await - .expect("Fetch json from greptimedb failed"); - let result: serde_json::Value = serde_json::from_str(&query_response) - .expect("Invalid json returned from greptimedb query"); - assert_eq!( - result - .pointer("/output/0/records/rows") - .and_then(|v| v.as_array()) - .expect("Error getting greptimedb response array") - .len(), - 10 - ) - } - - fn query_client() -> reqwest::Client { - reqwest::Client::builder().build().unwrap() - } - - fn create_event(i: i32) -> Event { - Event::Metric( - Metric::new( - "my_counter".to_owned(), - MetricKind::Incremental, - MetricValue::Counter { value: i as f64 }, - ) - .with_namespace(Some("ns")) - .with_tags(Some(metric_tags!( - "region" => "us-west-1", - "production" => "true", - ))) - .with_timestamp(Some(Utc::now())), - ) - } -} diff --git a/src/sinks/greptimedb/service.rs b/src/sinks/greptimedb/service.rs new file mode 100644 index 0000000000000..1ce2612f979f9 --- /dev/null +++ b/src/sinks/greptimedb/service.rs @@ -0,0 +1,140 @@ +use std::num::NonZeroUsize; +use std::sync::Arc; +use std::task::Poll; + +use futures_util::future::BoxFuture; + +use greptimedb_client::api::v1::auth_header::AuthScheme; +use greptimedb_client::api::v1::*; +use greptimedb_client::{Client, Database, Error as GreptimeError, DEFAULT_SCHEMA_NAME}; +use tower::Service; +use vector_common::finalization::{EventFinalizers, EventStatus, Finalizable}; +use vector_common::internal_event::CountByteSize; +use vector_common::request_metadata::{MetaDescriptive, RequestMetadata}; +use vector_core::event::Metric; +use vector_core::stream::DriverResponse; + +use crate::sinks::util::metadata::RequestMetadataBuilder; + +use super::batch::GreptimeDBBatchSizer; +use super::request_builder::metric_to_insert_request; +use super::GreptimeDBConfig; + +pub(super) struct GreptimeDBRequest { + items: Vec, + finalizers: EventFinalizers, + metadata: RequestMetadata, +} + +impl GreptimeDBRequest { + pub(super) fn from_metrics(metrics: Vec) -> Self { + let mut items = Vec::with_capacity(metrics.len()); + let mut finalizers = EventFinalizers::default(); + let mut request_metadata_builder = RequestMetadataBuilder::default(); + + let sizer = GreptimeDBBatchSizer::default(); + let mut estimated_request_size = 0; + for mut metric in metrics.into_iter() { + finalizers.merge(metric.take_finalizers()); + estimated_request_size += sizer.estimated_size_of(&metric); + request_metadata_builder.track_event(&metric); + items.push(metric_to_insert_request(metric)); + } + + let request_size = + NonZeroUsize::new(estimated_request_size).expect("request should never be zero length"); + + GreptimeDBRequest { + items, + finalizers, + metadata: request_metadata_builder.with_request_size(request_size), + } + } +} + +impl Finalizable for GreptimeDBRequest { + fn take_finalizers(&mut self) -> EventFinalizers { + std::mem::take(&mut self.finalizers) + } +} + +impl MetaDescriptive for GreptimeDBRequest { + fn get_metadata(&self) -> RequestMetadata { + self.metadata + } +} + +#[derive(Debug)] +pub struct GreptimeDBBatchOutput { + item_count: u32, + metadata: RequestMetadata, +} + +impl DriverResponse for GreptimeDBBatchOutput { + fn event_status(&self) -> EventStatus { + EventStatus::Delivered + } + + fn events_sent(&self) -> CountByteSize { + CountByteSize( + self.item_count as usize, + self.metadata.events_estimated_json_encoded_byte_size(), + ) + } + + fn bytes_sent(&self) -> Option { + Some(self.metadata.request_wire_size()) + } +} + +#[derive(Debug, Clone)] +pub struct GreptimeDBService { + /// the client that connects to greptimedb + client: Arc, +} + +impl GreptimeDBService { + pub fn new(config: &GreptimeDBConfig) -> Self { + let grpc_client = Client::with_urls(vec![&config.endpoint]); + let mut client = Database::new_with_dbname( + config.dbname.as_deref().unwrap_or(DEFAULT_SCHEMA_NAME), + grpc_client, + ); + + if let (Some(username), Some(password)) = (&config.username, &config.password) { + client.set_auth(AuthScheme::Basic(Basic { + username: username.to_owned(), + password: password.clone().into(), + })) + }; + + GreptimeDBService { + client: Arc::new(client), + } + } +} + +impl Service for GreptimeDBService { + type Response = GreptimeDBBatchOutput; + type Error = GreptimeError; + type Future = BoxFuture<'static, Result>; + + fn poll_ready(&mut self, _cx: &mut std::task::Context) -> Poll> { + Poll::Ready(Ok(())) + } + + // Convert vector metrics into GreptimeDB format and send them in batch + fn call(&mut self, req: GreptimeDBRequest) -> Self::Future { + let client = Arc::clone(&self.client); + + Box::pin(async move { + let metadata = req.get_metadata(); + let result = client.insert(req.items).await?; + + Ok(GreptimeDBBatchOutput { + item_count: result, + metadata, + }) + }) + } +} diff --git a/src/sinks/greptimedb/sink.rs b/src/sinks/greptimedb/sink.rs new file mode 100644 index 0000000000000..7125036feec56 --- /dev/null +++ b/src/sinks/greptimedb/sink.rs @@ -0,0 +1,56 @@ +use async_trait::async_trait; + +use futures::StreamExt; +use futures_util::stream::BoxStream; +use vector_core::event::{Event, Metric, MetricValue}; +use vector_core::sink::StreamSink; +use vector_core::stream::BatcherSettings; + +use crate::sinks::util::buffer::metrics::MetricNormalize; +use crate::sinks::util::buffer::metrics::MetricSet; +use crate::sinks::util::SinkBuilderExt; + +use super::batch::GreptimeDBBatchSizer; +use super::service::{GreptimeDBRequest, GreptimeDBService}; + +#[derive(Clone, Debug, Default)] +pub struct GreptimeDBMetricNormalize; + +impl MetricNormalize for GreptimeDBMetricNormalize { + fn normalize(&mut self, state: &mut MetricSet, metric: Metric) -> Option { + match (metric.kind(), &metric.value()) { + (_, MetricValue::Counter { .. }) => state.make_absolute(metric), + (_, MetricValue::Gauge { .. }) => state.make_absolute(metric), + // All others are left as-is + _ => Some(metric), + } + } +} + +pub struct GreptimeDBSink { + pub(super) service: GreptimeDBService, + pub(super) batch_settings: BatcherSettings, +} + +impl GreptimeDBSink { + async fn run_inner(self: Box, input: BoxStream<'_, Event>) -> Result<(), ()> { + input + .map(|event| event.into_metric()) + .normalized_with_default::() + .batched( + self.batch_settings + .into_item_size_config(GreptimeDBBatchSizer::default()), + ) + .map(GreptimeDBRequest::from_metrics) + .into_driver(self.service) + .run() + .await + } +} + +#[async_trait] +impl StreamSink for GreptimeDBSink { + async fn run(self: Box, input: BoxStream<'_, Event>) -> Result<(), ()> { + self.run_inner(input).await + } +} From 828bebcb7866c245215fa7d148b37c117531b482 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Mon, 12 Jun 2023 22:05:32 +0800 Subject: [PATCH 23/34] fix: integration tests --- src/sinks/greptimedb/integration_tests.rs | 27 ++++++++++++++++++----- src/sinks/greptimedb/sink.rs | 6 +++-- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/sinks/greptimedb/integration_tests.rs b/src/sinks/greptimedb/integration_tests.rs index f7e57f08f9eb0..2f9078b8e3b14 100644 --- a/src/sinks/greptimedb/integration_tests.rs +++ b/src/sinks/greptimedb/integration_tests.rs @@ -1,4 +1,6 @@ -use vector_core::event::MetricKind; +use chrono::{DateTime, Duration, Utc}; +use futures::stream; +use vector_core::event::{Event, Metric, MetricKind, MetricValue}; use vector_core::metric_tags; use crate::sinks::util::test::load_sink; @@ -10,7 +12,7 @@ use crate::{ }, }; -use super::*; +use super::GreptimeDBConfig; #[tokio::test] async fn test_greptimedb_sink() { @@ -24,10 +26,23 @@ async fn test_greptimedb_sink() { let (config, _) = load_sink::(&cfg).unwrap(); let (sink, _hc) = config.build(SinkContext::new_test()).await.unwrap(); - let events: Vec<_> = (0..10).map(create_event).collect(); + let query_client = query_client(); + + // Drop the table and data inside + let _ = query_client + .get(&format!( + "{}/v1/sql", + std::env::var("GREPTIMEDB_HTTP").unwrap_or_else(|_| "http://localhost:4000".to_owned()) + )) + .query(&[("sql", "DROP TABLE ns_my_counter")]) + .send() + .await + .unwrap(); + + let base_time = Utc::now(); + let events: Vec<_> = (0..10).map(|idx| create_event(idx, base_time)).collect(); run_and_assert_sink_compliance(sink, stream::iter(events), &SINK_TAGS).await; - let query_client = query_client(); let query_response = query_client .get(&format!( "{}/v1/sql", @@ -56,7 +71,7 @@ fn query_client() -> reqwest::Client { reqwest::Client::builder().build().unwrap() } -fn create_event(i: i32) -> Event { +fn create_event(i: i32, base_time: DateTime) -> Event { Event::Metric( Metric::new( "my_counter".to_owned(), @@ -68,6 +83,6 @@ fn create_event(i: i32) -> Event { "region" => "us-west-1", "production" => "true", ))) - .with_timestamp(Some(Utc::now())), + .with_timestamp(Some(base_time + Duration::seconds(i as i64))), ) } diff --git a/src/sinks/greptimedb/sink.rs b/src/sinks/greptimedb/sink.rs index 7125036feec56..fe1856e0611f3 100644 --- a/src/sinks/greptimedb/sink.rs +++ b/src/sinks/greptimedb/sink.rs @@ -8,10 +8,11 @@ use vector_core::stream::BatcherSettings; use crate::sinks::util::buffer::metrics::MetricNormalize; use crate::sinks::util::buffer::metrics::MetricSet; +use crate::sinks::util::service::Svc; use crate::sinks::util::SinkBuilderExt; use super::batch::GreptimeDBBatchSizer; -use super::service::{GreptimeDBRequest, GreptimeDBService}; +use super::service::{GreptimeDBRequest, GreptimeDBRetryLogic, GreptimeDBService}; #[derive(Clone, Debug, Default)] pub struct GreptimeDBMetricNormalize; @@ -28,7 +29,7 @@ impl MetricNormalize for GreptimeDBMetricNormalize { } pub struct GreptimeDBSink { - pub(super) service: GreptimeDBService, + pub(super) service: Svc, pub(super) batch_settings: BatcherSettings, } @@ -43,6 +44,7 @@ impl GreptimeDBSink { ) .map(GreptimeDBRequest::from_metrics) .into_driver(self.service) + .protocol("grpc") .run() .await } From 8fb9943cb24adfcb1bfbdf816f58bcc634082651 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Mon, 12 Jun 2023 22:05:46 +0800 Subject: [PATCH 24/34] feat: add retry logic back --- src/sinks/greptimedb/mod.rs | 9 ++++++++- src/sinks/greptimedb/service.rs | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/sinks/greptimedb/mod.rs b/src/sinks/greptimedb/mod.rs index f1b84136ac8f1..f7d91f7d040e5 100644 --- a/src/sinks/greptimedb/mod.rs +++ b/src/sinks/greptimedb/mod.rs @@ -1,5 +1,6 @@ use futures_util::FutureExt; use greptimedb_client::Client; +use tower::ServiceBuilder; use vector_common::sensitive_string::SensitiveString; use vector_config::configurable_component; use vector_core::config::{AcknowledgementsConfig, Input}; @@ -9,6 +10,9 @@ use crate::config::{SinkConfig, SinkContext}; use crate::sinks::util::{BatchConfig, SinkBatchSettings}; use crate::sinks::{Healthcheck, VectorSink}; +use self::service::GreptimeDBRetryLogic; + +use super::prelude::ServiceBuilderExt; use super::util::TowerRequestConfig; mod batch; @@ -73,7 +77,10 @@ impl_generate_config_from_default!(GreptimeDBConfig); #[async_trait::async_trait] impl SinkConfig for GreptimeDBConfig { async fn build(&self, _cx: SinkContext) -> crate::Result<(VectorSink, Healthcheck)> { - let service = service::GreptimeDBService::new(self); + let request_settings = self.request.unwrap_with(&TowerRequestConfig::default()); + let service = ServiceBuilder::new() + .settings(request_settings, GreptimeDBRetryLogic) + .service(service::GreptimeDBService::new(self)); let sink = sink::GreptimeDBSink { service, batch_settings: self.batch.into_batcher_settings()?, diff --git a/src/sinks/greptimedb/service.rs b/src/sinks/greptimedb/service.rs index 1ce2612f979f9..b28eac0a30eba 100644 --- a/src/sinks/greptimedb/service.rs +++ b/src/sinks/greptimedb/service.rs @@ -14,12 +14,26 @@ use vector_common::request_metadata::{MetaDescriptive, RequestMetadata}; use vector_core::event::Metric; use vector_core::stream::DriverResponse; +use crate::sinks::prelude::RetryLogic; use crate::sinks::util::metadata::RequestMetadataBuilder; use super::batch::GreptimeDBBatchSizer; use super::request_builder::metric_to_insert_request; use super::GreptimeDBConfig; +#[derive(Clone, Default)] +pub(super) struct GreptimeDBRetryLogic; + +impl RetryLogic for GreptimeDBRetryLogic { + type Response = GreptimeDBBatchOutput; + type Error = GreptimeError; + + fn is_retriable_error(&self, _error: &Self::Error) -> bool { + true + } +} + +#[derive(Clone)] pub(super) struct GreptimeDBRequest { items: Vec, finalizers: EventFinalizers, From 542a820f4b3d0c0e5e83f2019f8065ef886c68cd Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Thu, 15 Jun 2023 21:56:58 +0800 Subject: [PATCH 25/34] fix: change default column name to val instead of value --- src/sinks/greptimedb/integration_tests.rs | 2 +- src/sinks/greptimedb/request_builder.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sinks/greptimedb/integration_tests.rs b/src/sinks/greptimedb/integration_tests.rs index 2f9078b8e3b14..165394a8a496b 100644 --- a/src/sinks/greptimedb/integration_tests.rs +++ b/src/sinks/greptimedb/integration_tests.rs @@ -48,7 +48,7 @@ async fn test_greptimedb_sink() { "{}/v1/sql", std::env::var("GREPTIMEDB_HTTP").unwrap_or_else(|_| "http://localhost:4000".to_owned()) )) - .query(&[("sql", "SELECT region, value FROM ns_my_counter")]) + .query(&[("sql", "SELECT region, val FROM ns_my_counter")]) .send() .await .unwrap() diff --git a/src/sinks/greptimedb/request_builder.rs b/src/sinks/greptimedb/request_builder.rs index f9e9154bddb80..861cfbf5c5077 100644 --- a/src/sinks/greptimedb/request_builder.rs +++ b/src/sinks/greptimedb/request_builder.rs @@ -72,9 +72,9 @@ pub(super) fn metric_to_insert_request(metric: Metric) -> InsertRequest { // fields match metric.value() { - MetricValue::Counter { value } => columns.push(f64_field("value", *value)), - MetricValue::Gauge { value } => columns.push(f64_field("value", *value)), - MetricValue::Set { values } => columns.push(f64_field("value", values.len() as f64)), + MetricValue::Counter { value } => columns.push(f64_field("val", *value)), + MetricValue::Gauge { value } => columns.push(f64_field("val", *value)), + MetricValue::Set { values } => columns.push(f64_field("val", values.len() as f64)), MetricValue::Distribution { samples, .. } => { encode_distribution(samples, &mut columns); } @@ -214,9 +214,9 @@ mod tests { .collect::>(); assert!(column_names.contains(&"ts")); assert!(column_names.contains(&"host")); - assert!(column_names.contains(&"value")); + assert!(column_names.contains(&"val")); - assert_eq!(get_column(&insert.columns, "value"), 1.1); + assert_eq!(get_column(&insert.columns, "val"), 1.1); let metric2 = Metric::new( "load1", @@ -237,7 +237,7 @@ mod tests { let insert = metric_to_insert_request(metric); assert_eq!(insert.columns.len(), 2); - assert_eq!(get_column(&insert.columns, "value"), 1.1); + assert_eq!(get_column(&insert.columns, "val"), 1.1); } #[test] @@ -252,7 +252,7 @@ mod tests { let insert = metric_to_insert_request(metric); assert_eq!(insert.columns.len(), 2); - assert_eq!(get_column(&insert.columns, "value"), 2.0); + assert_eq!(get_column(&insert.columns, "val"), 2.0); } #[test] From 2d39446ca2d6d8354368489f475cbc88acb201e2 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Mon, 26 Jun 2023 15:42:03 +0800 Subject: [PATCH 26/34] refactor: minor tunes --- Cargo.lock | 1933 ++--------------------- Cargo.toml | 2 +- src/sinks/greptimedb/mod.rs | 64 +- src/sinks/greptimedb/request_builder.rs | 4 +- src/sinks/greptimedb/service.rs | 13 +- 5 files changed, 149 insertions(+), 1867 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6b2a246d9f302..e9631b7f4b1d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,15 +18,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b5ace29ee3216de37c0546865ad08edef58b0f9e76838ed8959a84a990e58c5" -[[package]] -name = "addr2line" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" -dependencies = [ - "gimli", -] - [[package]] name = "adler" version = "1.0.2" @@ -68,7 +59,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf6ccdb167abbf410dcb915cabd428929d7f6a04980b54a11f26a39f1c7f7107" dependencies = [ "cfg-if", - "const-random", "getrandom 0.2.10", "once_cell", "version_check", @@ -92,21 +82,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "alloc-no-stdlib" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" - -[[package]] -name = "alloc-stdlib" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" -dependencies = [ - "alloc-no-stdlib", -] - [[package]] name = "amq-protocol" version = "7.0.1" @@ -234,22 +209,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "api" -version = "0.2.0" -dependencies = [ - "arrow-flight", - "common-base", - "common-error", - "common-time", - "datatypes", - "greptime-proto", - "prost", - "snafu", - "tonic", - "tonic-build", -] - [[package]] name = "approx" version = "0.5.1" @@ -296,12 +255,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "arrayref" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" - [[package]] name = "arrayvec" version = "0.5.2" @@ -314,239 +267,6 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" -[[package]] -name = "arrow" -version = "37.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aea9fcb25bbb70f7f922f95b99ca29c1013dab47f6df61a6f24861842dd7f2e" -dependencies = [ - "ahash 0.8.2", - "arrow-arith", - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-csv", - "arrow-data", - "arrow-ipc", - "arrow-json", - "arrow-ord", - "arrow-row", - "arrow-schema", - "arrow-select", - "arrow-string", -] - -[[package]] -name = "arrow-arith" -version = "37.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d967b42f7b12c91fd78acd396b20c2973b184c8866846674abbb00c963e93ab" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "chrono", - "half 2.3.0", - "num", -] - -[[package]] -name = "arrow-array" -version = "37.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3190f208ee7aa0f3596fa0098d42911dec5e123ca88c002a08b24877ad14c71e" -dependencies = [ - "ahash 0.8.2", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "chrono", - "chrono-tz", - "half 2.3.0", - "hashbrown 0.13.2", - "num", -] - -[[package]] -name = "arrow-buffer" -version = "37.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d33c733c5b6c44a0fc526f29c09546e04eb56772a7a21e48e602f368be381f6" -dependencies = [ - "half 2.3.0", - "num", -] - -[[package]] -name = "arrow-cast" -version = "37.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abd349520b6a1ed4924ae2afc9d23330a3044319e4ec3d5b124c09e4d440ae87" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "arrow-select", - "chrono", - "comfy-table", - "lexical-core", - "num", -] - -[[package]] -name = "arrow-csv" -version = "37.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c80af3c3e290a2a7e1cc518f1471dff331878cb4af9a5b088bf030b89debf649" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-data", - "arrow-schema", - "chrono", - "csv", - "csv-core", - "lazy_static", - "lexical-core", - "regex", -] - -[[package]] -name = "arrow-data" -version = "37.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c8361947aaa96d331da9df3f7a08bdd8ab805a449994c97f5c4d24c4b7e2cf" -dependencies = [ - "arrow-buffer", - "arrow-schema", - "half 2.3.0", - "num", -] - -[[package]] -name = "arrow-flight" -version = "37.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd1fc687f3e4ffe91ccb7f2ffb06143ff97029448d427a9641006242bcbd0c24" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-ipc", - "arrow-schema", - "base64 0.21.2", - "bytes 1.4.0", - "futures 0.3.28", - "paste", - "prost", - "tokio", - "tonic", -] - -[[package]] -name = "arrow-ipc" -version = "37.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a46ee000b9fbd1e8db6e8b26acb8c760838512b39d8c9f9d73892cb55351d50" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-data", - "arrow-schema", - "flatbuffers", -] - -[[package]] -name = "arrow-json" -version = "37.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bf2366607be867ced681ad7f272371a5cf1fc2941328eef7b4fee14565166fb" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-data", - "arrow-schema", - "chrono", - "half 2.3.0", - "indexmap", - "lexical-core", - "num", - "serde", - "serde_json", -] - -[[package]] -name = "arrow-ord" -version = "37.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "304069901c867200e21ec868ae7521165875470ef2f1f6d58f979a443d63997e" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "arrow-select", - "half 2.3.0", - "num", -] - -[[package]] -name = "arrow-row" -version = "37.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d57fe8ceef3392fdd493269d8a2d589de17bafce151aacbffbddac7a57f441a" -dependencies = [ - "ahash 0.8.2", - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "half 2.3.0", - "hashbrown 0.13.2", -] - -[[package]] -name = "arrow-schema" -version = "37.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a16b88a93ac8350f0200b1cd336a1f887315925b8dd7aa145a37b8bdbd8497a4" -dependencies = [ - "serde", -] - -[[package]] -name = "arrow-select" -version = "37.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98e8a4d6ca37d5212439b24caad4d80743fcbb706706200dd174bb98e68fe9d8" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "num", -] - -[[package]] -name = "arrow-string" -version = "37.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbb594efa397eb6a546f42b1f8df3d242ea84dbfda5232e06035dc2b2e2c8459" -dependencies = [ - "arrow-array", - "arrow-buffer", - "arrow-data", - "arrow-schema", - "arrow-select", - "regex", - "regex-syntax 0.6.29", -] - [[package]] name = "ascii" version = "0.9.3" @@ -617,16 +337,11 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "942c7cd7ae39e91bde4820d74132e9862e62c2f386c3aa90ccf55949f5bad63a" dependencies = [ - "bzip2", "flate2", "futures-core", - "futures-io", "memchr", "pin-project-lite", "tokio", - "xz2", - "zstd 0.11.2+zstd.1.5.2", - "zstd-safe 5.0.2+zstd.1.5.2", ] [[package]] @@ -1643,21 +1358,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "backtrace" -version = "0.3.67" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide 0.6.2", - "object", - "rustc-demangle", -] - [[package]] name = "base16" version = "0.2.1" @@ -1762,29 +1462,6 @@ dependencies = [ "wyz", ] -[[package]] -name = "blake2" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "blake3" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "729b71f35bd3fa1a4c86b85d32c8b9069ea7fe14f7a53cfabb65f62d4265b888" -dependencies = [ - "arrayref", - "arrayvec 0.7.2", - "cc", - "cfg-if", - "constant_time_eq", - "digest 0.10.7", -] - [[package]] name = "block-buffer" version = "0.9.0" @@ -1928,27 +1605,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "brotli" -version = "3.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", - "brotli-decompressor", -] - -[[package]] -name = "brotli-decompressor" -version = "2.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", -] - [[package]] name = "bson" version = "2.6.1" @@ -2067,27 +1723,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38fcc2979eff34a4b84e1cf9a1e3da42a7d44b3b690a40cdcb23e3d556cfb2e5" -[[package]] -name = "bzip2" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" -dependencies = [ - "bzip2-sys", - "libc", -] - -[[package]] -name = "bzip2-sys" -version = "0.1.11+1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - [[package]] name = "cache-padded" version = "1.2.0" @@ -2252,7 +1887,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213030a2b5a4e0c0892b6652260cf6ccac84827b83a85a534e178e3906c4cf1b" dependencies = [ "ciborium-io", - "half 1.8.2", + "half", ] [[package]] @@ -2355,33 +1990,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" -[[package]] -name = "client" -version = "0.2.0" -dependencies = [ - "api", - "arrow-flight", - "async-stream", - "common-base", - "common-catalog", - "common-error", - "common-grpc", - "common-grpc-expr", - "common-query", - "common-recordbatch", - "common-telemetry", - "common-time", - "datafusion", - "datatypes", - "enum_dispatch", - "futures-util", - "parking_lot", - "prost", - "rand 0.8.5", - "snafu", - "tonic", -] - [[package]] name = "clipboard-win" version = "4.4.2" @@ -2486,269 +2094,66 @@ dependencies = [ ] [[package]] -name = "comfy-table" -version = "6.2.0" +name = "concurrent-queue" +version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e959d788268e3bf9d35ace83e81b124190378e4c91c9067524675e33394b8ba" +checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c" dependencies = [ - "strum", - "strum_macros", - "unicode-width", + "cache-padded", ] [[package]] -name = "common-base" -version = "0.2.0" +name = "concurrent-queue" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd7bef69dc86e3c610e4e7aed41035e2a7ed12e72dd7530f61327a6579a4390b" dependencies = [ - "anymap", - "bitvec", - "bytes 1.4.0", - "common-error", - "paste", - "serde", - "snafu", + "crossbeam-utils", ] [[package]] -name = "common-catalog" -version = "0.2.0" +name = "confy" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e37668cb35145dcfaa1931a5f37fde375eeae8068b4c0d2f289da28a270b2d2c" dependencies = [ - "async-trait", - "common-error", - "common-telemetry", - "datatypes", - "lazy_static", - "regex", + "directories 4.0.1", "serde", - "serde_json", - "snafu", + "thiserror", + "toml 0.5.11", ] [[package]] -name = "common-error" -version = "0.2.0" +name = "console" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c050367d967ced717c04b65d8c619d863ef9292ce0c5760028655a2fb298718c" dependencies = [ - "snafu", - "strum", + "encode_unicode 0.3.6", + "lazy_static", + "libc", + "terminal_size 0.1.17", + "unicode-width", + "winapi", ] [[package]] -name = "common-function-macro" -version = "0.2.0" +name = "console-api" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2895653b4d9f1538a83970077cb01dfc77a4810524e51a110944688e916b18e" dependencies = [ - "backtrace", - "common-telemetry", - "proc-macro2 1.0.60", - "quote 1.0.28", - "syn 1.0.109", + "prost", + "prost-types", + "tonic", + "tracing-core 0.1.30", ] [[package]] -name = "common-grpc" -version = "0.2.0" -dependencies = [ - "api", - "arrow-flight", - "async-trait", - "backtrace", - "common-base", - "common-error", - "common-function-macro", - "common-query", - "common-recordbatch", - "common-runtime", - "common-telemetry", - "dashmap", - "datafusion", - "datatypes", - "flatbuffers", - "futures 0.3.28", - "prost", - "snafu", - "tokio", - "tonic", - "tower", -] - -[[package]] -name = "common-grpc-expr" -version = "0.2.0" -dependencies = [ - "api", - "async-trait", - "common-base", - "common-catalog", - "common-error", - "common-grpc", - "common-query", - "common-telemetry", - "common-time", - "datatypes", - "snafu", - "table", -] - -[[package]] -name = "common-procedure" -version = "0.2.0" -dependencies = [ - "async-stream", - "async-trait", - "backon", - "common-error", - "common-runtime", - "common-telemetry", - "futures 0.3.28", - "object-store", - "serde", - "serde_json", - "smallvec", - "snafu", - "tokio", - "uuid", -] - -[[package]] -name = "common-query" -version = "0.2.0" -dependencies = [ - "async-trait", - "common-error", - "common-recordbatch", - "common-time", - "datafusion", - "datafusion-common", - "datafusion-expr", - "datatypes", - "snafu", - "statrs", -] - -[[package]] -name = "common-recordbatch" -version = "0.2.0" -dependencies = [ - "common-error", - "datafusion", - "datafusion-common", - "datatypes", - "futures 0.3.28", - "paste", - "serde", - "snafu", -] - -[[package]] -name = "common-runtime" -version = "0.2.0" -dependencies = [ - "async-trait", - "common-error", - "common-telemetry", - "metrics 0.20.1", - "once_cell", - "paste", - "snafu", - "tokio", - "tokio-util", -] - -[[package]] -name = "common-telemetry" -version = "0.2.0" -dependencies = [ - "backtrace", - "common-error", - "metrics 0.20.1", - "metrics-exporter-prometheus", - "metrics-util 0.14.0", - "once_cell", - "opentelemetry", - "opentelemetry-jaeger", - "serde", - "tokio", - "tracing 0.1.37", - "tracing-appender", - "tracing-bunyan-formatter", - "tracing-futures 0.2.5", - "tracing-log", - "tracing-opentelemetry", - "tracing-subscriber", -] - -[[package]] -name = "common-time" -version = "0.2.0" -dependencies = [ - "chrono", - "chrono-tz", - "common-error", - "serde", - "serde_json", - "snafu", -] - -[[package]] -name = "concurrent-queue" -version = "1.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c" -dependencies = [ - "cache-padded", -] - -[[package]] -name = "concurrent-queue" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7bef69dc86e3c610e4e7aed41035e2a7ed12e72dd7530f61327a6579a4390b" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "confy" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e37668cb35145dcfaa1931a5f37fde375eeae8068b4c0d2f289da28a270b2d2c" -dependencies = [ - "directories 4.0.1", - "serde", - "thiserror", - "toml 0.5.11", -] - -[[package]] -name = "console" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c050367d967ced717c04b65d8c619d863ef9292ce0c5760028655a2fb298718c" -dependencies = [ - "encode_unicode 0.3.6", - "lazy_static", - "libc", - "terminal_size 0.1.17", - "unicode-width", - "winapi", -] - -[[package]] -name = "console-api" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2895653b4d9f1538a83970077cb01dfc77a4810524e51a110944688e916b18e" -dependencies = [ - "prost", - "prost-types", - "tonic", - "tracing-core 0.1.30", -] - -[[package]] -name = "console-subscriber" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ab2224a0311582eb03adba4caaf18644f7b1f10a760803a803b9b605187fc7" +name = "console-subscriber" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57ab2224a0311582eb03adba4caaf18644f7b1f10a760803a803b9b605187fc7" dependencies = [ "console-api", "crossbeam-channel", @@ -2774,40 +2179,6 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" -[[package]] -name = "const-oid" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" - -[[package]] -name = "const-random" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368a7a772ead6ce7e1de82bfb04c485f3db8ec744f72925af5735e29a22cc18e" -dependencies = [ - "const-random-macro", - "proc-macro-hack", -] - -[[package]] -name = "const-random-macro" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d7d6ab3c3a2282db210df5f02c4dab6e0a7057af0fb7ebd4070f30fe05c0ddb" -dependencies = [ - "getrandom 0.2.10", - "once_cell", - "proc-macro-hack", - "tiny-keccak", -] - -[[package]] -name = "constant_time_eq" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6" - [[package]] name = "convert_case" version = "0.4.0" @@ -3224,191 +2595,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d7439c3735f405729d52c3fbbe4de140eaf938a1fe47d227c27f8254d4302a5" -[[package]] -name = "datafusion" -version = "22.0.0" -source = "git+https://github.com/waynexia/arrow-datafusion.git?rev=5337c86120de8193406b59be7612484796a46294#5337c86120de8193406b59be7612484796a46294" -dependencies = [ - "ahash 0.8.2", - "arrow", - "arrow-array", - "arrow-schema", - "async-compression 0.3.15", - "async-trait", - "bytes 1.4.0", - "bzip2", - "chrono", - "dashmap", - "datafusion-common", - "datafusion-execution", - "datafusion-expr", - "datafusion-optimizer", - "datafusion-physical-expr", - "datafusion-row", - "datafusion-sql", - "flate2", - "futures 0.3.28", - "glob", - "hashbrown 0.13.2", - "indexmap", - "itertools", - "lazy_static", - "log", - "num_cpus", - "object_store", - "parking_lot", - "parquet", - "percent-encoding", - "pin-project-lite", - "rand 0.8.5", - "smallvec", - "sqlparser", - "tempfile", - "tokio", - "tokio-stream", - "tokio-util", - "url", - "uuid", - "xz2", - "zstd 0.12.3+zstd.1.5.2", -] - -[[package]] -name = "datafusion-common" -version = "22.0.0" -source = "git+https://github.com/waynexia/arrow-datafusion.git?rev=5337c86120de8193406b59be7612484796a46294#5337c86120de8193406b59be7612484796a46294" -dependencies = [ - "arrow", - "arrow-array", - "chrono", - "num_cpus", - "object_store", - "parquet", - "sqlparser", -] - -[[package]] -name = "datafusion-execution" -version = "22.0.0" -source = "git+https://github.com/waynexia/arrow-datafusion.git?rev=5337c86120de8193406b59be7612484796a46294#5337c86120de8193406b59be7612484796a46294" -dependencies = [ - "dashmap", - "datafusion-common", - "datafusion-expr", - "hashbrown 0.13.2", - "log", - "object_store", - "parking_lot", - "rand 0.8.5", - "tempfile", - "url", -] - -[[package]] -name = "datafusion-expr" -version = "22.0.0" -source = "git+https://github.com/waynexia/arrow-datafusion.git?rev=5337c86120de8193406b59be7612484796a46294#5337c86120de8193406b59be7612484796a46294" -dependencies = [ - "ahash 0.8.2", - "arrow", - "datafusion-common", - "sqlparser", -] - -[[package]] -name = "datafusion-optimizer" -version = "22.0.0" -source = "git+https://github.com/waynexia/arrow-datafusion.git?rev=5337c86120de8193406b59be7612484796a46294#5337c86120de8193406b59be7612484796a46294" -dependencies = [ - "arrow", - "async-trait", - "chrono", - "datafusion-common", - "datafusion-expr", - "datafusion-physical-expr", - "hashbrown 0.13.2", - "itertools", - "log", - "regex-syntax 0.6.29", -] - -[[package]] -name = "datafusion-physical-expr" -version = "22.0.0" -source = "git+https://github.com/waynexia/arrow-datafusion.git?rev=5337c86120de8193406b59be7612484796a46294#5337c86120de8193406b59be7612484796a46294" -dependencies = [ - "ahash 0.8.2", - "arrow", - "arrow-array", - "arrow-buffer", - "arrow-schema", - "blake2", - "blake3", - "chrono", - "datafusion-common", - "datafusion-expr", - "datafusion-row", - "half 2.3.0", - "hashbrown 0.13.2", - "indexmap", - "itertools", - "lazy_static", - "md-5", - "paste", - "petgraph", - "rand 0.8.5", - "regex", - "sha2 0.10.7", - "unicode-segmentation", - "uuid", -] - -[[package]] -name = "datafusion-row" -version = "22.0.0" -source = "git+https://github.com/waynexia/arrow-datafusion.git?rev=5337c86120de8193406b59be7612484796a46294#5337c86120de8193406b59be7612484796a46294" -dependencies = [ - "arrow", - "datafusion-common", - "paste", - "rand 0.8.5", -] - -[[package]] -name = "datafusion-sql" -version = "22.0.0" -source = "git+https://github.com/waynexia/arrow-datafusion.git?rev=5337c86120de8193406b59be7612484796a46294#5337c86120de8193406b59be7612484796a46294" -dependencies = [ - "arrow", - "arrow-schema", - "datafusion-common", - "datafusion-expr", - "log", - "sqlparser", -] - -[[package]] -name = "datatypes" -version = "0.2.0" -dependencies = [ - "arrow", - "arrow-array", - "arrow-schema", - "common-base", - "common-error", - "common-telemetry", - "common-time", - "datafusion-common", - "enum_dispatch", - "num", - "num-traits", - "ordered-float 3.7.0", - "paste", - "serde", - "serde_json", - "snafu", -] - [[package]] name = "db-key" version = "0.0.5" @@ -3446,18 +2632,7 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" dependencies = [ - "const-oid 0.6.2", -] - -[[package]] -name = "der" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" -dependencies = [ - "const-oid 0.9.2", - "pem-rfc7468 0.6.0", - "zeroize", + "const-oid", ] [[package]] @@ -3482,37 +2657,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "derive_builder" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07adf7be193b71cc36b193d0f5fe60b918a3a9db4dad0449f57bcfd519704a3" -dependencies = [ - "derive_builder_macro", -] - -[[package]] -name = "derive_builder_core" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4" -dependencies = [ - "darling 0.14.2", - "proc-macro2 1.0.60", - "quote 1.0.28", - "syn 1.0.109", -] - -[[package]] -name = "derive_builder_macro" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68" -dependencies = [ - "derive_builder_core", - "syn 1.0.109", -] - [[package]] name = "derive_more" version = "0.99.17" @@ -3554,7 +2698,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.3", - "const-oid 0.9.2", "crypto-common", "subtle", ] @@ -3630,12 +2773,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "dlv-list" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" - [[package]] name = "dns-lookup" version = "1.0.8" @@ -3708,7 +2845,7 @@ version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ - "signature 1.6.4", + "signature", ] [[package]] @@ -4050,16 +3187,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda653ca797810c02f7ca4b804b40b8b95ae046eb989d356bce17919a8c25499" -[[package]] -name = "flatbuffers" -version = "23.5.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dac53e22462d78c16d64a1cd22371b54cc3fe94aa15e7886a2fa6e5d1ab8640" -dependencies = [ - "bitflags 1.3.2", - "rustc_version 0.4.0", -] - [[package]] name = "flate2" version = "1.0.26" @@ -4067,7 +3194,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", - "miniz_oxide 0.7.1", + "miniz_oxide", ] [[package]] @@ -4277,16 +3404,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "gethostname" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "getrandom" version = "0.1.16" @@ -4322,12 +3439,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "gimli" -version = "0.27.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" - [[package]] name = "glob" version = "0.3.1" @@ -4454,9 +3565,9 @@ dependencies = [ ] [[package]] -name = "greptimedb-client-rust" +name = "greptimedb-client" version = "0.1.0" -source = "git+https://github.com/GreptimeTeam/greptimedb-client-rust.git?rev=48121652b8e6dfb95abefcf342808a4e78d024b4#48121652b8e6dfb95abefcf342808a4e78d024b4" +source = "git+https://github.com/GreptimeTeam/greptimedb-client-rust.git?rev=0841134b004cfcf228af038b2b338dccaf743644#0841134b004cfcf228af038b2b338dccaf743644" dependencies = [ "dashmap", "enum_dispatch", @@ -4468,6 +3579,7 @@ dependencies = [ "rand 0.8.5", "snafu", "tokio", + "tokio-stream", "tonic", "tonic-build", "tower", @@ -4508,17 +3620,6 @@ version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" -[[package]] -name = "half" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9906a89f1724975a455316ae0554ceaa45ad83bb336f1125a87bfbdb9197cfa0" -dependencies = [ - "cfg-if", - "crunchy", - "num-traits", -] - [[package]] name = "hash_hasher" version = "2.0.3" @@ -4760,15 +3861,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "home" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" -dependencies = [ - "windows-sys 0.48.0", -] - [[package]] name = "hostname" version = "0.3.1" @@ -4847,16 +3939,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "humantime-serde" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c" -dependencies = [ - "humantime", - "serde", -] - [[package]] name = "hyper" version = "0.14.26" @@ -5053,7 +4135,7 @@ dependencies = [ "console", "instant", "number_prefix", - "portable-atomic 1.3.1", + "portable-atomic", "unicode-segmentation", "unicode-width", ] @@ -5115,16 +4197,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "integer-encoding" -version = "3.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bb03732005da905c88227371639bf1ad885cc712789c011c31c5fb3ab3ccf02" -dependencies = [ - "async-trait", - "futures-util", -] - [[package]] name = "inventory" version = "0.3.6" @@ -5289,20 +4361,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "jsonwebtoken" -version = "8.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" -dependencies = [ - "base64 0.21.2", - "pem", - "ring", - "serde", - "serde_json", - "simple_asn1", -] - [[package]] name = "k8s-e2e-tests" version = "0.1.0" @@ -5544,73 +4602,6 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -dependencies = [ - "spin 0.5.2", -] - -[[package]] -name = "lexical-core" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cde5de06e8d4c2faabc400238f9ae1c74d5412d03a7bd067645ccbc47070e46" -dependencies = [ - "lexical-parse-float", - "lexical-parse-integer", - "lexical-util", - "lexical-write-float", - "lexical-write-integer", -] - -[[package]] -name = "lexical-parse-float" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "683b3a5ebd0130b8fb52ba0bdc718cc56815b6a097e28ae5a6997d0ad17dc05f" -dependencies = [ - "lexical-parse-integer", - "lexical-util", - "static_assertions", -] - -[[package]] -name = "lexical-parse-integer" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d0994485ed0c312f6d965766754ea177d07f9c00c9b82a5ee62ed5b47945ee9" -dependencies = [ - "lexical-util", - "static_assertions", -] - -[[package]] -name = "lexical-util" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5255b9ff16ff898710eb9eb63cb39248ea8a5bb036bea8085b1a767ff6c4e3fc" -dependencies = [ - "static_assertions", -] - -[[package]] -name = "lexical-write-float" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accabaa1c4581f05a3923d1b4cfd124c329352288b7b9da09e766b0668116862" -dependencies = [ - "lexical-util", - "lexical-write-integer", - "static_assertions", -] - -[[package]] -name = "lexical-write-integer" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1b6f3d1f4422866b68192d62f77bc5c700bee84f3069f2469d7bc8c77852446" -dependencies = [ - "lexical-util", - "static_assertions", -] [[package]] name = "libc" @@ -5743,15 +4734,6 @@ dependencies = [ "snap", ] -[[package]] -name = "lru" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e7d46de488603ffdd5f30afbc64fbba2378214a2c3a2fb83abf3d33126df17" -dependencies = [ - "hashbrown 0.13.2", -] - [[package]] name = "lru" version = "0.10.0" @@ -5805,17 +4787,6 @@ dependencies = [ "libc", ] -[[package]] -name = "lzma-sys" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fda04ab3764e6cde78b9974eec4f779acaba7c4e84b36eca3cf77c581b85d27" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - [[package]] name = "macaddr" version = "1.0.1" @@ -5945,17 +4916,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "metrics" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b9b8653cec6897f73b519a43fba5ee3d50f62fe9af80b428accdcc093b4a849" -dependencies = [ - "ahash 0.7.6", - "metrics-macros 0.6.0", - "portable-atomic 0.3.20", -] - [[package]] name = "metrics" version = "0.21.0" @@ -5963,34 +4923,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa8ebbd1a9e57bbab77b9facae7f5136aea44c356943bf9a198f647da64285d6" dependencies = [ "ahash 0.8.2", - "metrics-macros 0.7.0", - "portable-atomic 1.3.1", -] - -[[package]] -name = "metrics-exporter-prometheus" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8603921e1f54ef386189335f288441af761e0fc61bcb552168d9cedfe63ebc70" -dependencies = [ - "indexmap", - "metrics 0.20.1", - "metrics-util 0.14.0", - "parking_lot", - "portable-atomic 0.3.20", - "quanta 0.10.1", - "thiserror", -] - -[[package]] -name = "metrics-macros" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "731f8ecebd9f3a4aa847dfe75455e4757a45da40a7793d2f0b1f9b6ed18b23f3" -dependencies = [ - "proc-macro2 1.0.60", - "quote 1.0.28", - "syn 1.0.109", + "metrics-macros", + "portable-atomic", ] [[package]] @@ -6001,44 +4935,23 @@ checksum = "ddece26afd34c31585c74a4db0630c376df271c285d682d1e55012197830b6df" dependencies = [ "proc-macro2 1.0.60", "quote 1.0.28", - "syn 2.0.10", -] - -[[package]] -name = "metrics-tracing-context" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fec95d1490f2b7e2d49462f9d75aa4fed52cc21e0b40aefc5987c6f404d40a2" -dependencies = [ - "itoa", - "lockfree-object-pool", - "metrics 0.21.0", - "metrics-util 0.15.0", - "once_cell", - "tracing 0.1.37", - "tracing-core 0.1.30", - "tracing-subscriber", -] - -[[package]] -name = "metrics-util" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d24dc2dbae22bff6f1f9326ffce828c9f07ef9cc1e8002e5279f845432a30a" -dependencies = [ - "aho-corasick 0.7.20", - "crossbeam-epoch", - "crossbeam-utils", - "hashbrown 0.12.3", - "indexmap", - "metrics 0.20.1", - "num_cpus", - "ordered-float 2.10.0", - "parking_lot", - "portable-atomic 0.3.20", - "quanta 0.10.1", - "radix_trie", - "sketches-ddsketch", + "syn 2.0.10", +] + +[[package]] +name = "metrics-tracing-context" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec95d1490f2b7e2d49462f9d75aa4fed52cc21e0b40aefc5987c6f404d40a2" +dependencies = [ + "itoa", + "lockfree-object-pool", + "metrics", + "metrics-util", + "once_cell", + "tracing 0.1.37", + "tracing-core 0.1.30", + "tracing-subscriber", ] [[package]] @@ -6052,10 +4965,10 @@ dependencies = [ "crossbeam-utils", "hashbrown 0.13.2", "indexmap", - "metrics 0.21.0", + "metrics", "num_cpus", "ordered-float 3.7.0", - "quanta 0.11.1", + "quanta", "radix_trie", "sketches-ddsketch", ] @@ -6082,15 +4995,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -6205,35 +5109,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" -[[package]] -name = "nalgebra" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d506eb7e08d6329505faa8a3a00a5dcc6de9f76e0c77e4b75763ae3c770831ff" -dependencies = [ - "approx", - "matrixmultiply", - "nalgebra-macros", - "num-complex", - "num-rational 0.4.1", - "num-traits", - "rand 0.8.5", - "rand_distr", - "simba", - "typenum", -] - -[[package]] -name = "nalgebra-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01fcc0b8149b4632adc89ac3b7b31a12fb6099a0317a4eb2ebff574ef7de7218" -dependencies = [ - "proc-macro2 1.0.60", - "quote 1.0.28", - "syn 1.0.109", -] - [[package]] name = "native-tls" version = "0.2.11" @@ -6478,20 +5353,6 @@ dependencies = [ "rand 0.8.5", ] -[[package]] -name = "num" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational 0.4.1", - "num-traits", -] - [[package]] name = "num-bigint" version = "0.4.3" @@ -6503,23 +5364,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-bigint-dig" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2399c9463abc5f909349d8aa9ba080e0b88b3ce2885389b60b993f39b1a56905" -dependencies = [ - "byteorder", - "lazy_static", - "libm", - "num-integer", - "num-iter", - "num-traits", - "rand 0.8.5", - "smallvec", - "zeroize", -] - [[package]] name = "num-complex" version = "0.4.2" @@ -6550,17 +5394,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-rational" version = "0.3.2" @@ -6572,18 +5405,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.15" @@ -6690,50 +5511,6 @@ dependencies = [ "malloc_buf", ] -[[package]] -name = "object" -version = "0.30.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" -dependencies = [ - "memchr", -] - -[[package]] -name = "object-store" -version = "0.2.0" -dependencies = [ - "async-trait", - "bytes 1.4.0", - "futures 0.3.28", - "lru 0.9.0", - "md5", - "metrics 0.20.1", - "opendal 0.33.3", - "pin-project", - "tokio", -] - -[[package]] -name = "object_store" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec9cd6ca25e796a49fa242876d1c4de36a24a6da5258e9f0bc062dbf5e81c53b" -dependencies = [ - "async-trait", - "bytes 1.4.0", - "chrono", - "futures 0.3.28", - "itertools", - "parking_lot", - "percent-encoding", - "snafu", - "tokio", - "tracing 0.1.37", - "url", - "walkdir", -] - [[package]] name = "ofb" version = "0.6.1" @@ -6783,40 +5560,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "opendal" -version = "0.33.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37976a7c07a7e1c503c6c369d597e3d046df165dc1da5d0263bc651c0a0f979c" -dependencies = [ - "anyhow", - "async-compat", - "async-trait", - "backon", - "base64 0.21.2", - "bytes 1.4.0", - "chrono", - "flagset", - "futures 0.3.28", - "http", - "hyper", - "log", - "md-5", - "metrics 0.20.1", - "once_cell", - "parking_lot", - "percent-encoding", - "pin-project", - "quick-xml 0.27.1", - "reqsign", - "reqwest", - "serde", - "serde_json", - "tokio", - "tracing 0.1.37", - "uuid", -] - [[package]] name = "opendal" version = "0.37.0" @@ -6840,7 +5583,7 @@ dependencies = [ "parking_lot", "percent-encoding", "pin-project", - "quick-xml 0.27.1", + "quick-xml", "reqwest", "serde", "serde_json", @@ -6926,42 +5669,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "opentelemetry" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6105e89802af13fdf48c49d7646d3b533a70e536d818aae7e78ba0433d01acb8" -dependencies = [ - "async-trait", - "crossbeam-channel", - "futures-channel", - "futures-executor", - "futures-util", - "js-sys", - "lazy_static", - "percent-encoding", - "pin-project", - "rand 0.8.5", - "thiserror", - "tokio", - "tokio-stream", -] - -[[package]] -name = "opentelemetry-jaeger" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8c0b12cd9e3f9b35b52f6e0dac66866c519b26f424f4bbf96e3fe8bfbdc5229" -dependencies = [ - "async-trait", - "lazy_static", - "opentelemetry", - "opentelemetry-semantic-conventions", - "thiserror", - "thrift 0.15.0", - "tokio", -] - [[package]] name = "opentelemetry-proto" version = "0.1.0" @@ -6979,30 +5686,12 @@ dependencies = [ "vrl", ] -[[package]] -name = "opentelemetry-semantic-conventions" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "985cc35d832d412224b2cffe2f9194b1b89b6aa5d0bef76d080dce09d90e62bd" -dependencies = [ - "opentelemetry", -] - [[package]] name = "option-ext" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" -[[package]] -name = "ordered-float" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3305af35278dd29f46fcdd139e0b1fbfae2153f0e5928b39b035542dd31e37b7" -dependencies = [ - "num-traits", -] - [[package]] name = "ordered-float" version = "2.10.0" @@ -7019,18 +5708,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fc2dbde8f8a79f2102cc474ceb0ad68e3b80b85289ea62389b60e66777e4213" dependencies = [ "num-traits", - "rand 0.8.5", - "serde", -] - -[[package]] -name = "ordered-multimap" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a" -dependencies = [ - "dlv-list", - "hashbrown 0.12.3", ] [[package]] @@ -7112,52 +5789,6 @@ dependencies = [ "windows-sys 0.42.0", ] -[[package]] -name = "parquet" -version = "37.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5022d98333271f4ca3e87bab760498e61726bf5a6ca919123c80517e20ded29" -dependencies = [ - "ahash 0.8.2", - "arrow-array", - "arrow-buffer", - "arrow-cast", - "arrow-data", - "arrow-ipc", - "arrow-schema", - "arrow-select", - "base64 0.21.2", - "brotli", - "bytes 1.4.0", - "chrono", - "flate2", - "futures 0.3.28", - "hashbrown 0.13.2", - "lz4", - "num", - "num-bigint", - "paste", - "seq-macro", - "snap", - "thrift 0.17.0", - "tokio", - "twox-hash", - "zstd 0.12.3+zstd.1.5.2", -] - -[[package]] -name = "parquet-format-async-temp" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03abc2f9c83fe9ceec83f47c76cc071bfd56caba33794340330f35623ab1f544" -dependencies = [ - "async-trait", - "byteorder", - "futures 0.3.28", - "integer-encoding", - "ordered-float 1.1.1", -] - [[package]] name = "parse-zoneinfo" version = "0.3.0" @@ -7206,15 +5837,6 @@ dependencies = [ "base64ct", ] -[[package]] -name = "pem-rfc7468" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d159833a9105500e0398934e205e0773f0b27529557134ecfc51c27646adac" -dependencies = [ - "base64ct", -] - [[package]] name = "percent-encoding" version = "2.3.0" @@ -7366,38 +5988,16 @@ dependencies = [ "tracing 0.1.37", ] -[[package]] -name = "pkcs1" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff33bdbdfc54cc98a2eca766ebdec3e1b8fb7387523d5c9c9a2891da856f719" -dependencies = [ - "der 0.6.1", - "pkcs8 0.9.0", - "spki 0.6.0", - "zeroize", -] - -[[package]] -name = "pkcs8" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" -dependencies = [ - "der 0.4.5", - "pem-rfc7468 0.2.3", - "spki 0.4.1", - "zeroize", -] - [[package]] name = "pkcs8" -version = "0.9.0" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" dependencies = [ - "der 0.6.1", - "spki 0.6.0", + "der", + "pem-rfc7468", + "spki", + "zeroize", ] [[package]] @@ -7454,15 +6054,6 @@ dependencies = [ "windows-sys 0.42.0", ] -[[package]] -name = "portable-atomic" -version = "0.3.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e30165d31df606f5726b090ec7592c308a0eaf61721ff64c9a3018e344a8753e" -dependencies = [ - "portable-atomic 1.3.1", -] - [[package]] name = "portable-atomic" version = "1.3.1" @@ -7822,22 +6413,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "658fa1faf7a4cc5f057c9ee5ef560f717ad9d8dc66d975267f709624d6e1ab88" -[[package]] -name = "quanta" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e31331286705f455e56cca62e0e717158474ff02b7936c1fa596d983f4ae27" -dependencies = [ - "crossbeam-utils", - "libc", - "mach", - "once_cell", - "raw-cpuid", - "wasi 0.10.2+wasi-snapshot-preview1", - "web-sys", - "winapi", -] - [[package]] name = "quanta" version = "0.11.1" @@ -7870,16 +6445,6 @@ dependencies = [ "serde", ] -[[package]] -name = "quick-xml" -version = "0.28.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce5e73202a820a31f8a0ee32ada5e21029c81fd9e3ebf668a40832e4219d9d1" -dependencies = [ - "memchr", - "serde", -] - [[package]] name = "quickcheck" version = "1.0.3" @@ -7964,7 +6529,6 @@ dependencies = [ "libc", "rand_chacha 0.3.1", "rand_core 0.6.4", - "serde", ] [[package]] @@ -8003,7 +6567,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom 0.2.10", - "serde", ] [[package]] @@ -8219,37 +6782,6 @@ dependencies = [ "bytecheck", ] -[[package]] -name = "reqsign" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a16a222894949f891cdfcb0c2c63913a975689fa7f7162d01d85df7837506ab8" -dependencies = [ - "anyhow", - "async-trait", - "base64 0.21.2", - "chrono", - "form_urlencoded", - "hex", - "hmac", - "home", - "http", - "jsonwebtoken", - "log", - "once_cell", - "percent-encoding", - "quick-xml 0.28.2", - "rand 0.8.5", - "reqwest", - "rsa", - "rust-ini", - "serde", - "serde_json", - "sha1", - "sha2 0.10.7", - "tokio", -] - [[package]] name = "reqwest" version = "0.11.18" @@ -8276,7 +6808,6 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustls 0.21.0", - "rustls-native-certs 0.6.2", "rustls-pemfile 1.0.1", "serde", "serde_json", @@ -8411,37 +6942,6 @@ dependencies = [ "xmlparser", ] -[[package]] -name = "rsa" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55a77d189da1fee555ad95b7e50e7457d91c0e089ec68ca69ad2989413bbdab4" -dependencies = [ - "byteorder", - "digest 0.10.7", - "num-bigint-dig", - "num-integer", - "num-iter", - "num-traits", - "pkcs1", - "pkcs8 0.9.0", - "rand_core 0.6.4", - "sha2 0.10.7", - "signature 2.1.0", - "subtle", - "zeroize", -] - -[[package]] -name = "rust-ini" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df" -dependencies = [ - "cfg-if", - "ordered-multimap", -] - [[package]] name = "rust_decimal" version = "1.29.1" @@ -8460,12 +6960,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - [[package]] name = "rustc-hash" version = "1.1.0" @@ -8661,15 +7155,6 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" -[[package]] -name = "safe_arch" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62a7484307bd40f8f7ccbacccac730108f2cae119a3b11c74485b48aa9ea650f" -dependencies = [ - "bytemuck", -] - [[package]] name = "same-file" version = "1.0.6" @@ -8811,12 +7296,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -[[package]] -name = "seq-macro" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6b44e8fc93a14e66336d230954dda83d18b4605ccace8fe09bc7514a71ad0bc" - [[package]] name = "serde" version = "1.0.164" @@ -9158,9 +7637,9 @@ version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfecc059e81632eef1dd9b79e22fc28b8fe69b30d3357512a77a0ad8ee3c782" dependencies = [ - "pkcs8 0.7.6", + "pkcs8", "rand_core 0.6.4", - "signature 1.6.4", + "signature", "zeroize", ] @@ -9170,29 +7649,6 @@ version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" -[[package]] -name = "signature" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" -dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", -] - -[[package]] -name = "simba" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0b7840f121a46d63066ee7a99fc81dcabbc6105e437cae43528cea199b5a05f" -dependencies = [ - "approx", - "num-complex", - "num-traits", - "paste", - "wide", -] - [[package]] name = "similar" version = "2.2.1" @@ -9219,18 +7675,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a30f10c911c0355f80f1c2faa8096efc4a58cdf8590b954d5b395efa071c711" -[[package]] -name = "simple_asn1" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" -dependencies = [ - "num-bigint", - "num-traits", - "thiserror", - "time", -] - [[package]] name = "siphasher" version = "0.3.10" @@ -9301,7 +7745,6 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0656e7e3ffb70f6c39b3c2a86332bb74aa3c679da781642590f3c1118c5045" dependencies = [ - "backtrace", "doc-comment", "futures-core", "pin-project", @@ -9367,38 +7810,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" dependencies = [ - "der 0.4.5", -] - -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der 0.6.1", -] - -[[package]] -name = "sqlparser" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355dc4d4b6207ca8a3434fc587db0a8016130a574dbcdbfb93d7f7b5bc5b211a" -dependencies = [ - "log", - "sqlparser_derive", -] - -[[package]] -name = "sqlparser_derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55fe75cb4a364c7f7ae06c7dbbc8d84bddd85d6cdf9975963c3935bc1991761e" -dependencies = [ - "proc-macro2 1.0.60", - "quote 1.0.28", - "syn 1.0.109", + "der", ] [[package]] @@ -9407,37 +7819,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "statrs" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d08e5e1748192713cc281da8b16924fb46be7b0c2431854eadc785823e5696e" -dependencies = [ - "approx", - "lazy_static", - "nalgebra", - "num-traits", - "rand 0.8.5", -] - -[[package]] -name = "store-api" -version = "0.2.0" -dependencies = [ - "async-trait", - "bytes 1.4.0", - "common-base", - "common-error", - "common-query", - "common-recordbatch", - "common-time", - "datatypes", - "derive_builder", - "futures 0.3.28", - "serde", - "snafu", -] - [[package]] name = "str-buf" version = "1.0.6" @@ -9528,9 +7909,6 @@ name = "strum" version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" -dependencies = [ - "strum_macros", -] [[package]] name = "strum_macros" @@ -9635,38 +8013,6 @@ dependencies = [ "nom", ] -[[package]] -name = "table" -version = "0.2.0" -dependencies = [ - "anymap", - "async-trait", - "chrono", - "common-base", - "common-catalog", - "common-error", - "common-procedure", - "common-query", - "common-recordbatch", - "common-telemetry", - "common-time", - "datafusion", - "datafusion-common", - "datafusion-expr", - "datafusion-physical-expr", - "datatypes", - "derive_builder", - "futures 0.3.28", - "humantime", - "humantime-serde", - "parquet-format-async-temp", - "paste", - "serde", - "snafu", - "store-api", - "tokio", -] - [[package]] name = "take_mut" version = "0.2.2" @@ -9806,39 +8152,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "threadpool" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" -dependencies = [ - "num_cpus", -] - -[[package]] -name = "thrift" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b82ca8f46f95b3ce96081fe3dd89160fdea970c254bb72925255d1b62aae692e" -dependencies = [ - "byteorder", - "integer-encoding", - "log", - "ordered-float 1.1.1", - "threadpool", -] - -[[package]] -name = "thrift" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e54bc85fc7faa8bc175c4bab5b92ba8d9a3ce893d0e9f42cc455c8ab16a9e09" -dependencies = [ - "byteorder", - "integer-encoding", - "ordered-float 2.10.0", -] - [[package]] name = "tikv-jemalloc-sys" version = "0.5.2+5.3.0-patched" @@ -10289,17 +8602,6 @@ dependencies = [ "tracing-core 0.2.0", ] -[[package]] -name = "tracing-appender" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d48f71a791638519505cefafe162606f706c25592e4bde4d97600c0195312e" -dependencies = [ - "crossbeam-channel", - "time", - "tracing-subscriber", -] - [[package]] name = "tracing-attributes" version = "0.1.23" @@ -10311,24 +8613,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "tracing-bunyan-formatter" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25a348912d4e90923cb93343691d3be97e3409607363706c400fc935bb032fb0" -dependencies = [ - "ahash 0.8.2", - "gethostname", - "log", - "serde", - "serde_json", - "time", - "tracing 0.1.37", - "tracing-core 0.1.30", - "tracing-log", - "tracing-subscriber", -] - [[package]] name = "tracing-core" version = "0.1.30" @@ -10402,20 +8686,6 @@ dependencies = [ "tracing-core 0.1.30", ] -[[package]] -name = "tracing-opentelemetry" -version = "0.17.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbbe89715c1dbbb790059e2565353978564924ee85017b5fff365c872ff6721f" -dependencies = [ - "once_cell", - "opentelemetry", - "tracing 0.1.37", - "tracing-core 0.1.30", - "tracing-log", - "tracing-subscriber", -] - [[package]] name = "tracing-serde" version = "0.1.3" @@ -10439,7 +8709,6 @@ dependencies = [ "serde", "serde_json", "sharded-slab", - "smallvec", "thread_local", "tracing 0.1.37", "tracing-core 0.1.30", @@ -10752,7 +9021,7 @@ version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1ee6bfd0a27bf614353809a035cf6880b74239ec6c5e39a7b2860ca16809137" dependencies = [ - "num-rational 0.3.2", + "num-rational", "num-traits", "typenum", ] @@ -10899,7 +9168,6 @@ dependencies = [ "chrono", "cidr-utils", "clap 4.1.14", - "client", "codecs", "colored", "console-subscriber", @@ -10922,7 +9190,7 @@ dependencies = [ "glob", "goauth", "governor", - "greptimedb-client-rust", + "greptimedb-client", "grok", "h2", "hash_hasher", @@ -10948,10 +9216,10 @@ dependencies = [ "listenfd", "logfmt", "loki-logproto", - "lru 0.10.0", + "lru", "maxminddb", "md-5", - "metrics 0.21.0", + "metrics", "metrics-tracing-context", "mlua", "mongodb", @@ -10963,7 +9231,7 @@ dependencies = [ "num-format", "number_prefix", "once_cell", - "opendal 0.37.0", + "opendal", "openssl", "openssl-probe", "openssl-src", @@ -11090,9 +9358,9 @@ dependencies = [ "futures 0.3.28", "hdrhistogram", "memmap2", - "metrics 0.21.0", + "metrics", "metrics-tracing-context", - "metrics-util 0.15.0", + "metrics-util", "num-traits", "once_cell", "pin-project", @@ -11128,7 +9396,7 @@ dependencies = [ "derivative", "futures 0.3.28", "indexmap", - "metrics 0.21.0", + "metrics", "nom", "ordered-float 3.7.0", "paste", @@ -11228,9 +9496,9 @@ dependencies = [ "http", "hyper-proxy", "indexmap", - "metrics 0.21.0", + "metrics", "metrics-tracing-context", - "metrics-util 0.15.0", + "metrics-util", "mlua", "ndarray", "ndarray-stats", @@ -11245,7 +9513,7 @@ dependencies = [ "prost", "prost-build", "prost-types", - "quanta 0.11.1", + "quanta", "quickcheck", "quickcheck_macros", "rand 0.8.5", @@ -11536,12 +9804,6 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -[[package]] -name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -11703,16 +9965,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "wide" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40018623e2dba2602a9790faba8d33f2ebdebf4b86561b83928db735f8784728" -dependencies = [ - "bytemuck", - "safe_arch", -] - [[package]] name = "widestring" version = "0.4.3" @@ -11991,15 +10243,6 @@ version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d25c75bf9ea12c4040a97f829154768bbbce366287e2dc044af160cd79a13fd" -[[package]] -name = "xz2" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388c44dc09d76f1536602ead6d325eb532f5c122f17782bd57fb47baeeb767e2" -dependencies = [ - "lzma-sys", -] - [[package]] name = "yaml-rust" version = "0.4.5" diff --git a/Cargo.toml b/Cargo.toml index dc3dfde84eac6..50410695f6732 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -226,7 +226,7 @@ hex = { version = "0.4.3", default-features = false, optional = true } sha2 = { version = "0.10.7", default-features = false, optional = true } # GreptimeDB -greptimedb-client = { git = "https://github.com/GreptimeTeam/greptimedb-client-rust.git", rev = "48121652b8e6dfb95abefcf342808a4e78d024b4", package = "greptimedb-client-rust", optional = true } +greptimedb-client = { git = "https://github.com/GreptimeTeam/greptimedb-client-rust.git", rev = "0841134b004cfcf228af038b2b338dccaf743644", optional = true } # VRL Lang vrl = { package = "vrl", version = "0.4.0", features = ["cli", "test"] } diff --git a/src/sinks/greptimedb/mod.rs b/src/sinks/greptimedb/mod.rs index f7d91f7d040e5..6525fb8389e05 100644 --- a/src/sinks/greptimedb/mod.rs +++ b/src/sinks/greptimedb/mod.rs @@ -1,10 +1,30 @@ +//! `GreptimeDB` sink for vector. +//! +//! This sink writes Vector's metric data into +//! [GreptimeDB](https://github.com/greptimeteam/greptimedb), a cloud-native +//! time-series database. It uses GreptimeDB's [gRPC +//! API](https://docs.greptime.com/user-guide/write-data/grpc) and GreptimeDB's +//! [rust client](https://github.com/GreptimeTeam/greptimedb-client-rust). +//! +//! This sink transforms metrics into GreptimeDB table using following rules: +//! +//! - Table name: `{namespace}_{metric_name}`. If the metric doesn't have a +//! namespace, we will use metric_name for table name. +//! - Timestamp: timestamp is stored as a column called `ts`. +//! - Tags: metric tags are stored as string columns with its name as column +//! name +//! - Counter and Gauge: the value of counter and gauge are stored in a column +//! called `val` +//! - Set: the number of set items is stored in a column called `val`. +//! - Distribution, Histogram and Summary, Sketch: Statistical attributes like +//! `sum`, `count`, "max", "min", quantiles and buckets are stored as columns. +//! use futures_util::FutureExt; use greptimedb_client::Client; use tower::ServiceBuilder; use vector_common::sensitive_string::SensitiveString; use vector_config::configurable_component; use vector_core::config::{AcknowledgementsConfig, Input}; -use vector_core::tls::TlsConfig; use crate::config::{SinkConfig, SinkContext}; use crate::sinks::util::{BatchConfig, SinkBatchSettings}; @@ -31,23 +51,47 @@ impl SinkBatchSettings for GreptimeDBDefaultBatchSettings { const TIMEOUT_SECS: f64 = 1.0; } +fn default_dbname() -> String { + greptimedb_client::DEFAULT_SCHEMA_NAME.to_string() +} + /// Configuration items for GreptimeDB -#[configurable_component(sink("greptimedb"))] +#[configurable_component(sink("greptimedb", "Ingest metrics data into GreptimeDB."))] #[derive(Clone, Debug, Default)] #[serde(deny_unknown_fields)] pub struct GreptimeDBConfig { - /// The database name to connect + /// The GreptimeDB [database](database) name to connect. + /// + /// Default to `public`, the default database of GreptimeDB. + /// + /// Database can be created via `create database` statement on + /// GreptimeDB. If you are using GreptimeCloud, use `dbname` from the + /// connection information of your instance. + /// + /// [database]: https://docs.greptime.com/user-guide/concepts/key-concepts#database #[configurable(metadata(docs::examples = "public"))] - #[serde(default)] - pub dbname: Option, - /// The host and port of greptimedb grpc service + #[serde(default = "default_dbname")] + pub dbname: String, + /// The host and port of GreptimeDB gRPC service. + /// + /// This sink uses GreptimeDB's gRPC interface for data ingestion. By + /// default, GreptimeDB listens to port 4001 for gRPC protocol. + /// + /// The address _must_ include a port. #[configurable(metadata(docs::examples = "example.com:4001"))] + #[configurable(metadata( + docs::examples = "1nge17d2r3ns.ap-southeast-1.aws.greptime.cloud:4001" + ))] pub endpoint: String, - /// The username of greptimedb + /// The username for your GreptimeDB instance. + /// + /// This is required if your instance has authentication enabled. #[configurable(metadata(docs::examples = "username"))] #[serde(default)] pub username: Option, - /// The password of greptimedb + /// The password for your GreptimeDB instance. + /// + /// This is required if your instance has authentication enabled. #[configurable(metadata(docs::examples = "password"))] #[serde(default)] pub password: Option, @@ -67,13 +111,11 @@ pub struct GreptimeDBConfig { skip_serializing_if = "crate::serde::skip_serializing_if_default" )] pub acknowledgements: AcknowledgementsConfig, - - #[configurable(derived)] - pub tls: Option, } impl_generate_config_from_default!(GreptimeDBConfig); +#[typetag::serde(name = "greptimedb")] #[async_trait::async_trait] impl SinkConfig for GreptimeDBConfig { async fn build(&self, _cx: SinkContext) -> crate::Result<(VectorSink, Healthcheck)> { diff --git a/src/sinks/greptimedb/request_builder.rs b/src/sinks/greptimedb/request_builder.rs index 861cfbf5c5077..1fd42c7ccd288 100644 --- a/src/sinks/greptimedb/request_builder.rs +++ b/src/sinks/greptimedb/request_builder.rs @@ -117,7 +117,6 @@ fn encode_distribution(samples: &[Sample], columns: &mut Vec) { { columns.push(f64_field("min", stats.min)); columns.push(f64_field("max", stats.max)); - columns.push(f64_field("median", stats.median)); columns.push(f64_field("avg", stats.avg)); columns.push(f64_field("sum", stats.sum)); columns.push(f64_field("count", stats.count as f64)); @@ -266,11 +265,10 @@ mod tests { }, ); let insert = metric_to_insert_request(metric); - assert_eq!(insert.columns.len(), 12); + assert_eq!(insert.columns.len(), 11); assert_eq!(get_column(&insert.columns, "max"), 3.0); assert_eq!(get_column(&insert.columns, "min"), 1.0); - assert_eq!(get_column(&insert.columns, "median"), 2.0); assert_eq!(get_column(&insert.columns, "avg"), 2.0); assert_eq!(get_column(&insert.columns, "sum"), 16.0); assert_eq!(get_column(&insert.columns, "count"), 8.0); diff --git a/src/sinks/greptimedb/service.rs b/src/sinks/greptimedb/service.rs index b28eac0a30eba..630f2ee415d6e 100644 --- a/src/sinks/greptimedb/service.rs +++ b/src/sinks/greptimedb/service.rs @@ -6,7 +6,7 @@ use futures_util::future::BoxFuture; use greptimedb_client::api::v1::auth_header::AuthScheme; use greptimedb_client::api::v1::*; -use greptimedb_client::{Client, Database, Error as GreptimeError, DEFAULT_SCHEMA_NAME}; +use greptimedb_client::{Client, Database, Error as GreptimeError}; use tower::Service; use vector_common::finalization::{EventFinalizers, EventStatus, Finalizable}; use vector_common::internal_event::CountByteSize; @@ -28,8 +28,8 @@ impl RetryLogic for GreptimeDBRetryLogic { type Response = GreptimeDBBatchOutput; type Error = GreptimeError; - fn is_retriable_error(&self, _error: &Self::Error) -> bool { - true + fn is_retriable_error(&self, error: &Self::Error) -> bool { + error.is_retriable() } } @@ -110,10 +110,7 @@ pub struct GreptimeDBService { impl GreptimeDBService { pub fn new(config: &GreptimeDBConfig) -> Self { let grpc_client = Client::with_urls(vec![&config.endpoint]); - let mut client = Database::new_with_dbname( - config.dbname.as_deref().unwrap_or(DEFAULT_SCHEMA_NAME), - grpc_client, - ); + let mut client = Database::new_with_dbname(&config.dbname, grpc_client); if let (Some(username), Some(password)) = (&config.username, &config.password) { client.set_auth(AuthScheme::Basic(Basic { @@ -122,6 +119,8 @@ impl GreptimeDBService { })) }; + // TODO: tls configuration + GreptimeDBService { client: Arc::new(client), } From 156a35ec8b553fa52b1d137ac7941033ba64fceb Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Mon, 26 Jun 2023 16:47:34 +0800 Subject: [PATCH 27/34] docs: update cue files --- .github/actions/spelling/allow.txt | 1 + LICENSE-3rdparty.csv | 2 +- src/sinks/greptimedb/mod.rs | 2 +- .../components/sinks/base/greptimedb.cue | 137 +++++------------- .../reference/components/sinks/greptimedb.cue | 90 ++++++++++++ website/cue/reference/services/greptimedb.cue | 10 ++ website/cue/reference/urls.cue | 3 + 7 files changed, 146 insertions(+), 99 deletions(-) create mode 100644 website/cue/reference/components/sinks/greptimedb.cue create mode 100644 website/cue/reference/services/greptimedb.cue diff --git a/.github/actions/spelling/allow.txt b/.github/actions/spelling/allow.txt index c37cb395d4754..0de11a253fb46 100644 --- a/.github/actions/spelling/allow.txt +++ b/.github/actions/spelling/allow.txt @@ -296,6 +296,7 @@ gql grafana graphiql greptime +greptimecloud greptimedb gvisor gws diff --git a/LICENSE-3rdparty.csv b/LICENSE-3rdparty.csv index 71104fde06065..85ba6da85148f 100644 --- a/LICENSE-3rdparty.csv +++ b/LICENSE-3rdparty.csv @@ -216,7 +216,7 @@ graphql_client,https://github.com/graphql-rust/graphql-client,Apache-2.0 OR MIT, graphql_client_codegen,https://github.com/graphql-rust/graphql-client,Apache-2.0 OR MIT,Tom Houlé graphql_query_derive,https://github.com/graphql-rust/graphql-client,Apache-2.0 OR MIT,Tom Houlé greptime-proto,https://github.com/GreptimeTeam/greptime-proto,Apache-2.0,The greptime-proto Authors -greptimedb-client-rust,https://github.com/GreptimeTeam/greptimedb-client-rust,Apache-2.0,The greptimedb-client-rust Authors +greptimedb-client,https://github.com/GreptimeTeam/greptimedb-client-rust,Apache-2.0,The greptimedb-client Authors grok,https://github.com/daschl/grok,Apache-2.0,Michael Nitschinger h2,https://github.com/hyperium/h2,MIT,"Carl Lerche , Sean McArthur " hash_hasher,https://github.com/Fraser999/Hash-Hasher,Apache-2.0 OR MIT,Fraser Hutchison diff --git a/src/sinks/greptimedb/mod.rs b/src/sinks/greptimedb/mod.rs index 6525fb8389e05..4cee71e1ddade 100644 --- a/src/sinks/greptimedb/mod.rs +++ b/src/sinks/greptimedb/mod.rs @@ -60,7 +60,7 @@ fn default_dbname() -> String { #[derive(Clone, Debug, Default)] #[serde(deny_unknown_fields)] pub struct GreptimeDBConfig { - /// The GreptimeDB [database](database) name to connect. + /// The GreptimeDB [database][database] name to connect. /// /// Default to `public`, the default database of GreptimeDB. /// diff --git a/website/cue/reference/components/sinks/base/greptimedb.cue b/website/cue/reference/components/sinks/base/greptimedb.cue index b0e5147b20e42..ad1a70001f596 100644 --- a/website/cue/reference/components/sinks/base/greptimedb.cue +++ b/website/cue/reference/components/sinks/base/greptimedb.cue @@ -60,20 +60,44 @@ base: components: sinks: greptimedb: configuration: { } } dbname: { - description: "The database name to connect" - required: false - type: string: examples: [ - "public", - ] + description: """ + The GreptimeDB [database][database] name to connect. + + Default to `public`, the default database of GreptimeDB. + + Database can be created via `create database` statement on + GreptimeDB. If you are using GreptimeCloud, use `dbname` from the + connection information of your instance. + + [database]: https://docs.greptime.com/user-guide/concepts/key-concepts#database + """ + required: false + type: string: { + default: "public" + examples: [ + "public", + ] + } } endpoint: { - description: "The host and port of greptimedb grpc service" - required: true - type: string: examples: ["example.com:4001"] + description: """ + The host and port of GreptimeDB gRPC service. + + This sink uses GreptimeDB's gRPC interface for data ingestion. By + default, GreptimeDB listens to port 4001 for gRPC protocol. + + The address _must_ include a port. + """ + required: true + type: string: examples: ["example.com:4001", "1nge17d2r3ns.ap-southeast-1.aws.greptime.cloud:4001"] } password: { - description: "The password of greptimedb" - required: false + description: """ + The password for your GreptimeDB instance. + + This is required if your instance has authentication enabled. + """ + required: false type: string: examples: ["password"] } request: { @@ -219,94 +243,13 @@ base: components: sinks: greptimedb: configuration: { } } } - tls: { - description: "TLS configuration." - required: false - type: object: options: { - alpn_protocols: { - description: """ - Sets the list of supported ALPN protocols. - - Declare the supported ALPN protocols, which are used during negotiation with peer. They are prioritized in the order - that they are defined. - """ - required: false - type: array: items: type: string: examples: ["h2"] - } - ca_file: { - description: """ - Absolute path to an additional CA certificate file. - - The certificate must be in the DER or PEM (X.509) format. Additionally, the certificate can be provided as an inline string in PEM format. - """ - required: false - type: string: examples: ["/path/to/certificate_authority.crt"] - } - crt_file: { - description: """ - Absolute path to a certificate file used to identify this server. - - The certificate must be in DER, PEM (X.509), or PKCS#12 format. Additionally, the certificate can be provided as - an inline string in PEM format. - - If this is set, and is not a PKCS#12 archive, `key_file` must also be set. - """ - required: false - type: string: examples: ["/path/to/host_certificate.crt"] - } - key_file: { - description: """ - Absolute path to a private key file used to identify this server. - - The key must be in DER or PEM (PKCS#8) format. Additionally, the key can be provided as an inline string in PEM format. - """ - required: false - type: string: examples: ["/path/to/host_certificate.key"] - } - key_pass: { - description: """ - Passphrase used to unlock the encrypted key file. - - This has no effect unless `key_file` is set. - """ - required: false - type: string: examples: ["${KEY_PASS_ENV_VAR}", "PassWord1"] - } - verify_certificate: { - description: """ - Enables certificate verification. - - If enabled, certificates must not be expired and must be issued by a trusted - issuer. This verification operates in a hierarchical manner, checking that the leaf certificate (the - certificate presented by the client/server) is not only valid, but that the issuer of that certificate is also valid, and - so on until the verification process reaches a root certificate. - - Relevant for both incoming and outgoing connections. - - Do NOT set this to `false` unless you understand the risks of not verifying the validity of certificates. - """ - required: false - type: bool: {} - } - verify_hostname: { - description: """ - Enables hostname verification. - - If enabled, the hostname used to connect to the remote host must be present in the TLS certificate presented by - the remote host, either as the Common Name or as an entry in the Subject Alternative Name extension. - - Only relevant for outgoing connections. - - Do NOT set this to `false` unless you understand the risks of not verifying the remote hostname. - """ - required: false - type: bool: {} - } - } - } username: { - description: "The username of greptimedb" - required: false + description: """ + The username for your GreptimeDB instance. + + This is required if your instance has authentication enabled. + """ + required: false type: string: examples: ["username"] } } diff --git a/website/cue/reference/components/sinks/greptimedb.cue b/website/cue/reference/components/sinks/greptimedb.cue new file mode 100644 index 0000000000000..d538538bb432e --- /dev/null +++ b/website/cue/reference/components/sinks/greptimedb.cue @@ -0,0 +1,90 @@ +package metadata + +components: sinks: greptimedb: { + title: "GreptimeDB" + + classes: { + commonly_used: true + delivery: "at_least_once" + development: "beta" + egress_method: "batch" + service_providers: ["GreptimeDB"] + stateful: false + } + + features: { + auto_generated: true + acknowledgements: true + healthcheck: enabled: true + send: { + batch: { + enabled: true + common: false + max_bytes: 10_000_000 + timeout_secs: 1.0 + } + compression: enabled: false + encoding: { + enabled: true + codec: enabled: false + } + request: { + enabled: true + headers: false + } + tls: { + enabled: true + can_verify_certificate: false + can_verify_hostname: true + enabled_default: false + enabled_by_scheme: false + } + to: { + service: services.greptimedb + + interface: { + socket: { + api: { + title: "GreptimeDB gRPC API" + url: urls.greptimedb_grpc + } + direction: "outgoing" + protocols: ["http"] + ssl: "optional" + } + } + } + } + } + + support: { + requirements: [] + warnings: [] + notices: [] + } + + configuration: base.components.sinks.greptimedb.configuration + + input: { + logs: false + metrics: { + counter: true + distribution: true + gauge: true + histogram: true + set: true + summary: true + } + traces: false + } + + how_it_works: { + setup: { + title: "Setup" + body: """ + 1. Start your own [GreptimeDB](\(urls.greptimedb)) or create an instance on [GreptimeCloud](\(urls.greptimecloud)). + 2. Configure gRPC endpoint(host:port) and optional dbname and authentication information. + """ + } + } +} diff --git a/website/cue/reference/services/greptimedb.cue b/website/cue/reference/services/greptimedb.cue new file mode 100644 index 0000000000000..e152397da7307 --- /dev/null +++ b/website/cue/reference/services/greptimedb.cue @@ -0,0 +1,10 @@ +package metadata + +services: greptimedb: { + name: "GreptimeDB" + thing: "a \(name) database" + url: urls.greptimedb + versions: null + + description: "[GreptimeDB](\(urls.greptimedb)) is an open-source cloud-native time-series database. It combines time-series and analytic workload into one database, and allows query via both SQL and PromQL. GreptimeDB works seamlessly with modern infrastructure like Kubernetes and object storage. It's also available on [Cloud](\(urls.greptimecloud))." +} diff --git a/website/cue/reference/urls.cue b/website/cue/reference/urls.cue index 0e3560392c108..c3a8309f8dbd5 100644 --- a/website/cue/reference/urls.cue +++ b/website/cue/reference/urls.cue @@ -235,6 +235,9 @@ urls: { graphql: "https://graphql.org" graphql_playground: "\(github)/graphql/graphql-playground" graphviz: "https://graphviz.org/" + greptimecloud: "https://greptime.cloud" + greptimedb: "https://github.com/greptimeteam/greptimedb" + greptimedb_grpc: "https://docs.greptime.com/" grok: "https://grokdebug.herokuapp.com/" grok_debugger: "https://grokdebug.herokuapp.com/" grok_patterns: "\(github)/daschl/grok/tree/master/patterns" From 3cdeb510222f2aebf950285bc8d7d74aefb5e721 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Sat, 1 Jul 2023 18:15:10 +0800 Subject: [PATCH 28/34] feat: add some tlsconfig support for custom ca and client cert --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/sinks/greptimedb/mod.rs | 10 ++- src/sinks/greptimedb/service.rs | 54 +++++++++--- src/sinks/greptimedb/sink.rs | 7 +- .../components/sinks/base/greptimedb.cue | 85 +++++++++++++++++++ 6 files changed, 137 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e9631b7f4b1d1..7ac7cd2a18250 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3567,7 +3567,7 @@ dependencies = [ [[package]] name = "greptimedb-client" version = "0.1.0" -source = "git+https://github.com/GreptimeTeam/greptimedb-client-rust.git?rev=0841134b004cfcf228af038b2b338dccaf743644#0841134b004cfcf228af038b2b338dccaf743644" +source = "git+https://github.com/GreptimeTeam/greptimedb-client-rust.git?rev=bc32362adf0df17a41a95bae4221d6d8f1775656#bc32362adf0df17a41a95bae4221d6d8f1775656" dependencies = [ "dashmap", "enum_dispatch", diff --git a/Cargo.toml b/Cargo.toml index 50410695f6732..fc8a51cc0dd5c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -226,7 +226,7 @@ hex = { version = "0.4.3", default-features = false, optional = true } sha2 = { version = "0.10.7", default-features = false, optional = true } # GreptimeDB -greptimedb-client = { git = "https://github.com/GreptimeTeam/greptimedb-client-rust.git", rev = "0841134b004cfcf228af038b2b338dccaf743644", optional = true } +greptimedb-client = { git = "https://github.com/GreptimeTeam/greptimedb-client-rust.git", rev = "bc32362adf0df17a41a95bae4221d6d8f1775656", optional = true } # VRL Lang vrl = { package = "vrl", version = "0.4.0", features = ["cli", "test"] } diff --git a/src/sinks/greptimedb/mod.rs b/src/sinks/greptimedb/mod.rs index 4cee71e1ddade..3848e98e49a2d 100644 --- a/src/sinks/greptimedb/mod.rs +++ b/src/sinks/greptimedb/mod.rs @@ -25,10 +25,9 @@ use tower::ServiceBuilder; use vector_common::sensitive_string::SensitiveString; use vector_config::configurable_component; use vector_core::config::{AcknowledgementsConfig, Input}; +use vector_core::tls::TlsConfig; -use crate::config::{SinkConfig, SinkContext}; -use crate::sinks::util::{BatchConfig, SinkBatchSettings}; -use crate::sinks::{Healthcheck, VectorSink}; +use crate::sinks::prelude::*; use self::service::GreptimeDBRetryLogic; @@ -111,6 +110,9 @@ pub struct GreptimeDBConfig { skip_serializing_if = "crate::serde::skip_serializing_if_default" )] pub acknowledgements: AcknowledgementsConfig, + + #[configurable(derived)] + pub tls: Option, } impl_generate_config_from_default!(GreptimeDBConfig); @@ -122,7 +124,7 @@ impl SinkConfig for GreptimeDBConfig { let request_settings = self.request.unwrap_with(&TowerRequestConfig::default()); let service = ServiceBuilder::new() .settings(request_settings, GreptimeDBRetryLogic) - .service(service::GreptimeDBService::new(self)); + .service(service::GreptimeDBService::try_new(self)?); let sink = sink::GreptimeDBSink { service, batch_settings: self.batch.into_batcher_settings()?, diff --git a/src/sinks/greptimedb/service.rs b/src/sinks/greptimedb/service.rs index 630f2ee415d6e..ec1ac80b60806 100644 --- a/src/sinks/greptimedb/service.rs +++ b/src/sinks/greptimedb/service.rs @@ -3,19 +3,14 @@ use std::sync::Arc; use std::task::Poll; use futures_util::future::BoxFuture; - use greptimedb_client::api::v1::auth_header::AuthScheme; use greptimedb_client::api::v1::*; +use greptimedb_client::channel_manager::*; use greptimedb_client::{Client, Database, Error as GreptimeError}; use tower::Service; -use vector_common::finalization::{EventFinalizers, EventStatus, Finalizable}; -use vector_common::internal_event::CountByteSize; -use vector_common::request_metadata::{MetaDescriptive, RequestMetadata}; use vector_core::event::Metric; -use vector_core::stream::DriverResponse; -use crate::sinks::prelude::RetryLogic; -use crate::sinks::util::metadata::RequestMetadataBuilder; +use crate::sinks::prelude::*; use super::batch::GreptimeDBBatchSizer; use super::request_builder::metric_to_insert_request; @@ -108,8 +103,20 @@ pub struct GreptimeDBService { } impl GreptimeDBService { - pub fn new(config: &GreptimeDBConfig) -> Self { - let grpc_client = Client::with_urls(vec![&config.endpoint]); + pub fn try_new(config: &GreptimeDBConfig) -> crate::Result { + let grpc_client = if let Some(tls_config) = &config.tls { + let channel_config = ChannelConfig { + client_tls: Self::try_from_tls_config(tls_config), + ..Default::default() + }; + Client::with_manager_and_urls( + ChannelManager::with_tls_config(channel_config).map_err(Box::new)?, + vec![&config.endpoint], + ) + } else { + Client::with_urls(vec![&config.endpoint]) + }; + let mut client = Database::new_with_dbname(&config.dbname, grpc_client); if let (Some(username), Some(password)) = (&config.username, &config.password) { @@ -119,10 +126,33 @@ impl GreptimeDBService { })) }; - // TODO: tls configuration - - GreptimeDBService { + Ok(GreptimeDBService { client: Arc::new(client), + }) + } + + fn try_from_tls_config(tls_config: &TlsConfig) -> Option { + if let Some(ca_path) = tls_config.ca_file.as_ref() { + let cert_path = tls_config.crt_file.as_ref().expect( + "Client cert file is required for greptimedb sink when custom CA specified", + ); + let key_path = tls_config + .key_file + .as_ref() + .expect("Client key file is required for greptimedb sink when custom CA specified"); + if tls_config.key_pass.is_some() { + warn!( + message = "TLS key file with password is not supported by greptimedb client at the moment." + ); + } + + Some(ClientTlsOption { + server_ca_cert_path: ca_path.clone(), + client_key_path: key_path.clone(), + client_cert_path: cert_path.clone(), + }) + } else { + None } } } diff --git a/src/sinks/greptimedb/sink.rs b/src/sinks/greptimedb/sink.rs index fe1856e0611f3..2b28e50755248 100644 --- a/src/sinks/greptimedb/sink.rs +++ b/src/sinks/greptimedb/sink.rs @@ -2,14 +2,11 @@ use async_trait::async_trait; use futures::StreamExt; use futures_util::stream::BoxStream; -use vector_core::event::{Event, Metric, MetricValue}; -use vector_core::sink::StreamSink; -use vector_core::stream::BatcherSettings; +use vector_core::event::{Metric, MetricValue}; +use crate::sinks::prelude::*; use crate::sinks::util::buffer::metrics::MetricNormalize; use crate::sinks::util::buffer::metrics::MetricSet; -use crate::sinks::util::service::Svc; -use crate::sinks::util::SinkBuilderExt; use super::batch::GreptimeDBBatchSizer; use super::service::{GreptimeDBRequest, GreptimeDBRetryLogic, GreptimeDBService}; diff --git a/website/cue/reference/components/sinks/base/greptimedb.cue b/website/cue/reference/components/sinks/base/greptimedb.cue index ad1a70001f596..6f25208e64bad 100644 --- a/website/cue/reference/components/sinks/base/greptimedb.cue +++ b/website/cue/reference/components/sinks/base/greptimedb.cue @@ -243,6 +243,91 @@ base: components: sinks: greptimedb: configuration: { } } } + tls: { + description: "TLS configuration." + required: false + type: object: options: { + alpn_protocols: { + description: """ + Sets the list of supported ALPN protocols. + + Declare the supported ALPN protocols, which are used during negotiation with peer. They are prioritized in the order + that they are defined. + """ + required: false + type: array: items: type: string: examples: ["h2"] + } + ca_file: { + description: """ + Absolute path to an additional CA certificate file. + + The certificate must be in the DER or PEM (X.509) format. Additionally, the certificate can be provided as an inline string in PEM format. + """ + required: false + type: string: examples: ["/path/to/certificate_authority.crt"] + } + crt_file: { + description: """ + Absolute path to a certificate file used to identify this server. + + The certificate must be in DER, PEM (X.509), or PKCS#12 format. Additionally, the certificate can be provided as + an inline string in PEM format. + + If this is set, and is not a PKCS#12 archive, `key_file` must also be set. + """ + required: false + type: string: examples: ["/path/to/host_certificate.crt"] + } + key_file: { + description: """ + Absolute path to a private key file used to identify this server. + + The key must be in DER or PEM (PKCS#8) format. Additionally, the key can be provided as an inline string in PEM format. + """ + required: false + type: string: examples: ["/path/to/host_certificate.key"] + } + key_pass: { + description: """ + Passphrase used to unlock the encrypted key file. + + This has no effect unless `key_file` is set. + """ + required: false + type: string: examples: ["${KEY_PASS_ENV_VAR}", "PassWord1"] + } + verify_certificate: { + description: """ + Enables certificate verification. + + If enabled, certificates must not be expired and must be issued by a trusted + issuer. This verification operates in a hierarchical manner, checking that the leaf certificate (the + certificate presented by the client/server) is not only valid, but that the issuer of that certificate is also valid, and + so on until the verification process reaches a root certificate. + + Relevant for both incoming and outgoing connections. + + Do NOT set this to `false` unless you understand the risks of not verifying the validity of certificates. + """ + required: false + type: bool: {} + } + verify_hostname: { + description: """ + Enables hostname verification. + + If enabled, the hostname used to connect to the remote host must be present in the TLS certificate presented by + the remote host, either as the Common Name or as an entry in the Subject Alternative Name extension. + + Only relevant for outgoing connections. + + Do NOT set this to `false` unless you understand the risks of not verifying the remote hostname. + """ + required: false + type: bool: {} + } + } + } username: { description: """ The username for your GreptimeDB instance. From 930f97d27bdfe7b3ec9c8784dbe57b62dccb51c1 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Sat, 1 Jul 2023 18:19:16 +0800 Subject: [PATCH 29/34] docs: add greptime.md for website --- .../reference/configuration/sinks/greptimedb.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 website/content/en/docs/reference/configuration/sinks/greptimedb.md diff --git a/website/content/en/docs/reference/configuration/sinks/greptimedb.md b/website/content/en/docs/reference/configuration/sinks/greptimedb.md new file mode 100644 index 0000000000000..57aebf227d2f4 --- /dev/null +++ b/website/content/en/docs/reference/configuration/sinks/greptimedb.md @@ -0,0 +1,14 @@ +--- +title: GreptimeDB +description: Writes metric data to [GreptimeDB](https://github.com/greptimeteam/greptimedb) +kind: sink +layout: component +tags: ["greptimedb", "component", "sink", "storage", "time-series", "metrics"] +--- + +{{/* +This doc is generated using: + +1. The template in layouts/docs/component.html +2. The relevant CUE data in cue/reference/components/... +*/}} From d590c7b8860f7ed8b66e82abb4aa65caf14a1d86 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Sat, 1 Jul 2023 19:22:45 +0800 Subject: [PATCH 30/34] refactor: adopt latest master changes --- src/sinks/greptimedb/integration_tests.rs | 2 +- src/sinks/greptimedb/service.rs | 25 +++++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/sinks/greptimedb/integration_tests.rs b/src/sinks/greptimedb/integration_tests.rs index 165394a8a496b..598c49e1b1e23 100644 --- a/src/sinks/greptimedb/integration_tests.rs +++ b/src/sinks/greptimedb/integration_tests.rs @@ -24,7 +24,7 @@ async fn test_greptimedb_sink() { ); let (config, _) = load_sink::(&cfg).unwrap(); - let (sink, _hc) = config.build(SinkContext::new_test()).await.unwrap(); + let (sink, _hc) = config.build(SinkContext::default()).await.unwrap(); let query_client = query_client(); diff --git a/src/sinks/greptimedb/service.rs b/src/sinks/greptimedb/service.rs index ec1ac80b60806..831a285c2382d 100644 --- a/src/sinks/greptimedb/service.rs +++ b/src/sinks/greptimedb/service.rs @@ -46,7 +46,9 @@ impl GreptimeDBRequest { for mut metric in metrics.into_iter() { finalizers.merge(metric.take_finalizers()); estimated_request_size += sizer.estimated_size_of(&metric); - request_metadata_builder.track_event(&metric); + + request_metadata_builder.track_event(metric.clone()); + items.push(metric_to_insert_request(metric)); } @@ -68,15 +70,19 @@ impl Finalizable for GreptimeDBRequest { } impl MetaDescriptive for GreptimeDBRequest { - fn get_metadata(&self) -> RequestMetadata { - self.metadata + fn get_metadata(&self) -> &RequestMetadata { + &self.metadata + } + + fn metadata_mut(&mut self) -> &mut RequestMetadata { + &mut self.metadata } } #[derive(Debug)] pub struct GreptimeDBBatchOutput { - item_count: u32, - metadata: RequestMetadata, + pub item_count: u32, + pub metadata: RequestMetadata, } impl DriverResponse for GreptimeDBBatchOutput { @@ -84,11 +90,8 @@ impl DriverResponse for GreptimeDBBatchOutput { EventStatus::Delivered } - fn events_sent(&self) -> CountByteSize { - CountByteSize( - self.item_count as usize, - self.metadata.events_estimated_json_encoded_byte_size(), - ) + fn events_sent(&self) -> &GroupedCountByteSize { + self.metadata.events_estimated_json_encoded_byte_size() } fn bytes_sent(&self) -> Option { @@ -171,7 +174,7 @@ impl Service for GreptimeDBService { let client = Arc::clone(&self.client); Box::pin(async move { - let metadata = req.get_metadata(); + let metadata = req.get_metadata().clone(); let result = client.insert(req.items).await?; Ok(GreptimeDBBatchOutput { From 7cde10750df446e2dce9209b693a897b26a2bdc2 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Mon, 3 Jul 2023 22:06:20 +0800 Subject: [PATCH 31/34] fix: avoid panic for tlsconfig error --- src/sinks/greptimedb/mod.rs | 9 +++++++++ src/sinks/greptimedb/service.rs | 22 ++++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/sinks/greptimedb/mod.rs b/src/sinks/greptimedb/mod.rs index 3848e98e49a2d..c581768445430 100644 --- a/src/sinks/greptimedb/mod.rs +++ b/src/sinks/greptimedb/mod.rs @@ -21,6 +21,7 @@ //! use futures_util::FutureExt; use greptimedb_client::Client; +use snafu::Snafu; use tower::ServiceBuilder; use vector_common::sensitive_string::SensitiveString; use vector_config::configurable_component; @@ -149,6 +150,14 @@ fn healthcheck(config: &GreptimeDBConfig) -> crate::Result { Ok(async move { client.health_check().await.map_err(|error| error.into()) }.boxed()) } +#[derive(Debug, Snafu)] +pub enum GreptimeDBConfigError { + #[snafu(display("greptimedb TLS Config Error: missing key"))] + TlsMissingKey, + #[snafu(display("greptimedb TLS Config Error: missing cert"))] + TlsMissingCert, +} + #[cfg(test)] mod tests { use indoc::indoc; diff --git a/src/sinks/greptimedb/service.rs b/src/sinks/greptimedb/service.rs index 831a285c2382d..099bd14ec9092 100644 --- a/src/sinks/greptimedb/service.rs +++ b/src/sinks/greptimedb/service.rs @@ -14,7 +14,7 @@ use crate::sinks::prelude::*; use super::batch::GreptimeDBBatchSizer; use super::request_builder::metric_to_insert_request; -use super::GreptimeDBConfig; +use super::{GreptimeDBConfig, GreptimeDBConfigError}; #[derive(Clone, Default)] pub(super) struct GreptimeDBRetryLogic; @@ -109,7 +109,7 @@ impl GreptimeDBService { pub fn try_new(config: &GreptimeDBConfig) -> crate::Result { let grpc_client = if let Some(tls_config) = &config.tls { let channel_config = ChannelConfig { - client_tls: Self::try_from_tls_config(tls_config), + client_tls: Self::try_from_tls_config(tls_config)?, ..Default::default() }; Client::with_manager_and_urls( @@ -134,28 +134,30 @@ impl GreptimeDBService { }) } - fn try_from_tls_config(tls_config: &TlsConfig) -> Option { + fn try_from_tls_config(tls_config: &TlsConfig) -> crate::Result> { if let Some(ca_path) = tls_config.ca_file.as_ref() { - let cert_path = tls_config.crt_file.as_ref().expect( - "Client cert file is required for greptimedb sink when custom CA specified", - ); + let cert_path = tls_config + .crt_file + .as_ref() + .ok_or(GreptimeDBConfigError::TlsMissingCert)?; let key_path = tls_config .key_file .as_ref() - .expect("Client key file is required for greptimedb sink when custom CA specified"); + .ok_or(GreptimeDBConfigError::TlsMissingKey)?; + if tls_config.key_pass.is_some() { warn!( message = "TLS key file with password is not supported by greptimedb client at the moment." ); } - Some(ClientTlsOption { + Ok(Some(ClientTlsOption { server_ca_cert_path: ca_path.clone(), client_key_path: key_path.clone(), client_cert_path: cert_path.clone(), - }) + })) } else { - None + Ok(None) } } } From 2968854ab9832fb375b73f674d5670958a87329c Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Sat, 8 Jul 2023 16:33:42 +0800 Subject: [PATCH 32/34] Apply suggestions from code review Co-authored-by: Doug Smith --- src/sinks/greptimedb/mod.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/sinks/greptimedb/mod.rs b/src/sinks/greptimedb/mod.rs index c581768445430..af0588e34b12b 100644 --- a/src/sinks/greptimedb/mod.rs +++ b/src/sinks/greptimedb/mod.rs @@ -19,22 +19,14 @@ //! - Distribution, Histogram and Summary, Sketch: Statistical attributes like //! `sum`, `count`, "max", "min", quantiles and buckets are stored as columns. //! -use futures_util::FutureExt; use greptimedb_client::Client; use snafu::Snafu; -use tower::ServiceBuilder; use vector_common::sensitive_string::SensitiveString; -use vector_config::configurable_component; -use vector_core::config::{AcknowledgementsConfig, Input}; -use vector_core::tls::TlsConfig; use crate::sinks::prelude::*; use self::service::GreptimeDBRetryLogic; -use super::prelude::ServiceBuilderExt; -use super::util::TowerRequestConfig; - mod batch; #[cfg(all(test, feature = "greptimedb-integration-tests"))] mod integration_tests; @@ -57,7 +49,8 @@ fn default_dbname() -> String { /// Configuration items for GreptimeDB #[configurable_component(sink("greptimedb", "Ingest metrics data into GreptimeDB."))] -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Derivative)] +#[derivative(Default)] #[serde(deny_unknown_fields)] pub struct GreptimeDBConfig { /// The GreptimeDB [database][database] name to connect. @@ -70,6 +63,7 @@ pub struct GreptimeDBConfig { /// /// [database]: https://docs.greptime.com/user-guide/concepts/key-concepts#database #[configurable(metadata(docs::examples = "public"))] + #[derivative(Default(value = "default_dbname()"))] #[serde(default = "default_dbname")] pub dbname: String, /// The host and port of GreptimeDB gRPC service. From 289f4a8b44afdcb75a9d5aeb9aaf7bffac38f096 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Sat, 8 Jul 2023 17:10:11 +0800 Subject: [PATCH 33/34] Update src/sinks/greptimedb/service.rs Co-authored-by: Doug Smith --- src/sinks/greptimedb/service.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/sinks/greptimedb/service.rs b/src/sinks/greptimedb/service.rs index 099bd14ec9092..ff7b558ee99f1 100644 --- a/src/sinks/greptimedb/service.rs +++ b/src/sinks/greptimedb/service.rs @@ -2,12 +2,10 @@ use std::num::NonZeroUsize; use std::sync::Arc; use std::task::Poll; -use futures_util::future::BoxFuture; use greptimedb_client::api::v1::auth_header::AuthScheme; use greptimedb_client::api::v1::*; use greptimedb_client::channel_manager::*; use greptimedb_client::{Client, Database, Error as GreptimeError}; -use tower::Service; use vector_core::event::Metric; use crate::sinks::prelude::*; From e247b683484ad3ace994c7a2bbca8f70543e8e7e Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Sat, 8 Jul 2023 17:36:37 +0800 Subject: [PATCH 34/34] refactor: address review issues --- src/sinks/greptimedb/batch.rs | 19 ++++-- src/sinks/greptimedb/request_builder.rs | 83 ++++++++++++++++++------- src/sinks/greptimedb/service.rs | 10 ++- 3 files changed, 82 insertions(+), 30 deletions(-) diff --git a/src/sinks/greptimedb/batch.rs b/src/sinks/greptimedb/batch.rs index ab85bf7ac9ee7..af4ef01096dfb 100644 --- a/src/sinks/greptimedb/batch.rs +++ b/src/sinks/greptimedb/batch.rs @@ -3,6 +3,13 @@ use vector_core::{ stream::batcher::limiter::ItemBatchSize, }; +use super::request_builder::{ + DISTRIBUTION_QUANTILES, DISTRIBUTION_STAT_FIELD_COUNT, SUMMARY_STAT_FIELD_COUNT, +}; + +const F64_BYTE_SIZE: usize = 8; +const I64_BYTE_SIZE: usize = 8; + #[derive(Default)] pub(super) struct GreptimeDBBatchSizer; @@ -20,14 +27,16 @@ impl GreptimeDBBatchSizer { .sum() }) .unwrap_or(0) + // timestamp + + I64_BYTE_SIZE + // value size match item.value() { - MetricValue::Counter { .. } | MetricValue::Gauge { .. } | MetricValue::Set { ..} => 8, - MetricValue::Distribution { .. } => 8 * 10, - MetricValue::AggregatedHistogram { buckets, .. } => 8 * (buckets.len() + 2), - MetricValue::AggregatedSummary { quantiles, .. } => 8 * (quantiles.len() + 2), - MetricValue::Sketch { .. } => 8 * 10, + MetricValue::Counter { .. } | MetricValue::Gauge { .. } | MetricValue::Set { ..} => F64_BYTE_SIZE, + MetricValue::Distribution { .. } => F64_BYTE_SIZE * (DISTRIBUTION_QUANTILES.len() + DISTRIBUTION_STAT_FIELD_COUNT), + MetricValue::AggregatedHistogram { buckets, .. } => F64_BYTE_SIZE * (buckets.len() + SUMMARY_STAT_FIELD_COUNT), + MetricValue::AggregatedSummary { quantiles, .. } => F64_BYTE_SIZE * (quantiles.len() + SUMMARY_STAT_FIELD_COUNT), + MetricValue::Sketch { .. } => F64_BYTE_SIZE * (DISTRIBUTION_QUANTILES.len() + DISTRIBUTION_STAT_FIELD_COUNT), } } } diff --git a/src/sinks/greptimedb/request_builder.rs b/src/sinks/greptimedb/request_builder.rs index 1fd42c7ccd288..06c92059c6f4e 100644 --- a/src/sinks/greptimedb/request_builder.rs +++ b/src/sinks/greptimedb/request_builder.rs @@ -7,6 +7,10 @@ use vector_core::metrics::AgentDDSketch; use crate::sinks::util::statistic::DistributionStatistic; +pub(super) const DISTRIBUTION_QUANTILES: [f64; 5] = [0.5, 0.75, 0.90, 0.95, 0.99]; +pub(super) const DISTRIBUTION_STAT_FIELD_COUNT: usize = 5; +pub(super) const SUMMARY_STAT_FIELD_COUNT: usize = 2; + fn f64_field(name: &str, value: f64) -> Column { Column { column_name: name.to_owned(), @@ -112,9 +116,7 @@ pub(super) fn metric_to_insert_request(metric: Metric) -> InsertRequest { } fn encode_distribution(samples: &[Sample], columns: &mut Vec) { - if let Some(stats) = - DistributionStatistic::from_samples(samples, &[0.5, 0.75, 0.90, 0.95, 0.99]) - { + if let Some(stats) = DistributionStatistic::from_samples(samples, &DISTRIBUTION_QUANTILES) { columns.push(f64_field("min", stats.min)); columns.push(f64_field("max", stats.max)); columns.push(f64_field("avg", stats.avg)); @@ -159,20 +161,11 @@ fn encode_sketch(sketch: &AgentDDSketch, columns: &mut Vec) { columns.push(f64_field("avg", avg)); } - if let Some(quantile) = sketch.quantile(0.5) { - columns.push(f64_field("p50", quantile)); - } - if let Some(quantile) = sketch.quantile(0.75) { - columns.push(f64_field("p75", quantile)); - } - if let Some(quantile) = sketch.quantile(0.90) { - columns.push(f64_field("p90", quantile)); - } - if let Some(quantile) = sketch.quantile(0.95) { - columns.push(f64_field("p95", quantile)); - } - if let Some(quantile) = sketch.quantile(0.99) { - columns.push(f64_field("p99", quantile)); + for q in DISTRIBUTION_QUANTILES { + if let Some(quantile) = sketch.quantile(q) { + let column_name = format!("p{:02}", q * 100f64); + columns.push(f64_field(&column_name, quantile)); + } } } @@ -265,7 +258,10 @@ mod tests { }, ); let insert = metric_to_insert_request(metric); - assert_eq!(insert.columns.len(), 11); + assert_eq!( + insert.columns.len(), + 1 + DISTRIBUTION_STAT_FIELD_COUNT + DISTRIBUTION_QUANTILES.len() + ); assert_eq!(get_column(&insert.columns, "max"), 3.0); assert_eq!(get_column(&insert.columns, "min"), 1.0); @@ -281,17 +277,22 @@ mod tests { #[test] fn test_histogram() { + let buckets = vector_core::buckets![1.0 => 1, 2.0 => 2, 3.0 => 1]; + let buckets_len = buckets.len(); let metric = Metric::new( "cpu_seconds_total", MetricKind::Incremental, MetricValue::AggregatedHistogram { - buckets: vector_core::buckets![1.0 => 1, 2.0 => 2, 3.0 => 1], + buckets, count: 4, sum: 8.0, }, ); let insert = metric_to_insert_request(metric); - assert_eq!(insert.columns.len(), 6); + assert_eq!( + insert.columns.len(), + 1 + SUMMARY_STAT_FIELD_COUNT + buckets_len + ); assert_eq!(get_column(&insert.columns, "b1"), 1.0); assert_eq!(get_column(&insert.columns, "b2"), 2.0); @@ -302,18 +303,23 @@ mod tests { #[test] fn test_summary() { + let quantiles = vector_core::quantiles![0.01 => 1.5, 0.5 => 2.0, 0.99 => 3.0]; + let quantiles_len = quantiles.len(); let metric = Metric::new( "cpu_seconds_total", MetricKind::Incremental, MetricValue::AggregatedSummary { - quantiles: vector_core::quantiles![0.01 => 1.5, 0.5 => 2.0, 0.99 => 3.0], + quantiles, count: 6, sum: 12.0, }, ); let insert = metric_to_insert_request(metric); - assert_eq!(insert.columns.len(), 6); + assert_eq!( + insert.columns.len(), + 1 + SUMMARY_STAT_FIELD_COUNT + quantiles_len + ); assert_eq!(get_column(&insert.columns, "p01"), 1.5); assert_eq!(get_column(&insert.columns, "p50"), 2.0); @@ -321,4 +327,37 @@ mod tests { assert_eq!(get_column(&insert.columns, "count"), 6.0); assert_eq!(get_column(&insert.columns, "sum"), 12.0); } + + #[test] + fn test_sketch() { + let mut sketch = AgentDDSketch::with_agent_defaults(); + let samples = 10; + for i in 0..samples { + sketch.insert(i as f64); + } + + let metric = Metric::new( + "cpu_seconds_total", + MetricKind::Incremental, + MetricValue::Sketch { + sketch: MetricSketch::AgentDDSketch(sketch), + }, + ); + + let insert = metric_to_insert_request(metric); + assert_eq!( + insert.columns.len(), + 1 + DISTRIBUTION_QUANTILES.len() + DISTRIBUTION_STAT_FIELD_COUNT + ); + + assert!(get_column(&insert.columns, "p50") <= 4.0); + assert!(get_column(&insert.columns, "p95") > 8.0); + assert!(get_column(&insert.columns, "p95") <= 9.0); + assert!(get_column(&insert.columns, "p99") > 8.0); + assert!(get_column(&insert.columns, "p99") <= 9.0); + assert_eq!(get_column(&insert.columns, "count"), samples as f64); + assert_eq!(get_column(&insert.columns, "sum"), 45.0); + assert_eq!(get_column(&insert.columns, "max"), 9.0); + assert_eq!(get_column(&insert.columns, "min"), 0.0); + } } diff --git a/src/sinks/greptimedb/service.rs b/src/sinks/greptimedb/service.rs index ff7b558ee99f1..2aab611af669e 100644 --- a/src/sinks/greptimedb/service.rs +++ b/src/sinks/greptimedb/service.rs @@ -143,9 +143,13 @@ impl GreptimeDBService { .as_ref() .ok_or(GreptimeDBConfigError::TlsMissingKey)?; - if tls_config.key_pass.is_some() { + if tls_config.key_pass.is_some() + || tls_config.alpn_protocols.is_some() + || tls_config.verify_certificate.is_some() + || tls_config.verify_hostname.is_some() + { warn!( - message = "TLS key file with password is not supported by greptimedb client at the moment." + message = "TlsConfig: key_pass, alpn_protocols, verify_certificate and verify_hostname are not supported by greptimedb client at the moment." ); } @@ -174,7 +178,7 @@ impl Service for GreptimeDBService { let client = Arc::clone(&self.client); Box::pin(async move { - let metadata = req.get_metadata().clone(); + let metadata = req.metadata; let result = client.insert(req.items).await?; Ok(GreptimeDBBatchOutput {