Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

grpc: add clickhouse dest #354

Merged
merged 9 commits into from
Nov 6, 2024
Merged

Conversation

alltilla
Copy link
Member

@alltilla alltilla commented Oct 22, 2024

Example config:

log {
  source { example-msg-generator(); };
  destination {
    clickhouse(
      database("default")
      table("my_first_table")
      user("default")
      password("pw")
      schema(
        "user_id" UInt32 => $R_MSEC,
        "message" String => "$MSG",
        "timestamp" DateTime => "$R_UNIXTIME",
        "metric" Float32 => 3.14
      )
      workers(4)
      batch-lines(1000)
      batch-timeout(1000)
    );
  };
};

table creation in clickhouse:

CREATE TABLE my_first_table
(
    user_id UInt32,
    message String,
    timestamp DateTime,
    metric Float32
)
ENGINE = MergeTree
PRIMARY KEY (user_id, timestamp)

make sure to enable grpc in clickhouse:

/etc/clickhouse-server/config.d# cat grpc.xml 
<clickhouse>
        <grpc_port>9100</grpc_port>
        <grpc>
                <enable_ssl>false</enable_ssl>

                <!-- The following two files are used only if SSL is enabled -->
                <ssl_cert_file>/path/to/ssl_cert_file</ssl_cert_file>
                <ssl_key_file>/path/to/ssl_key_file</ssl_key_file>

                <!-- Whether server requests client for a certificate -->
                <ssl_require_client_auth>false</ssl_require_client_auth>

                <!-- The following file is used only if ssl_require_client_auth=true -->
                <ssl_ca_cert_file>/path/to/ssl_ca_cert_file</ssl_ca_cert_file>

                <!-- Default compression algorithm (applied if client doesn't specify another algorithm, see result_compression in QueryInfo).
                     Supported algorithms: none, deflate, gzip, stream_gzip -->
                <compression>deflate</compression>

                <!-- Default compression level (applied if client doesn't specify another level, see result_compression in QueryInfo).
                     Supported levels: none, low, medium, high -->
                <compression_level>medium</compression_level>

                <!-- Send/receive message size limits in bytes. -1 means unlimited -->
                <max_send_message_size>-1</max_send_message_size>
                <max_receive_message_size>-1</max_receive_message_size>

                <!-- Enable if you want to get detailed logs -->
                <verbose_logs>false</verbose_logs>
        </grpc>
</clickhouse>

For reviewers:

  • I think the column <-> type mapping needs at least a big manual testing round. I am not sure I did everything correctly.

Depends on #338

Copy link
Contributor

github-actions bot commented Oct 22, 2024

This Pull Request introduces config grammar changes

axoflow/9aa7142e84e7fe4ae29c65cc922fa2f9835f2516 -> alltilla/grpc-clickhouse

--- a/destination
+++ b/destination

+clickhouse(
+    auth(
+        adc(<empty>)
+        alts(
+            <empty>
+            target-service-accounts(
+                <empty>
+                <string>
+            )
+        )
+        insecure(<empty>)
+        tls(
+            <empty>
+            ca-file(<string>)
+            cert-file(<string>)
+            key-file(<string>)
+        )
+    )
+    batch-bytes(<positive-integer>)
+    batch-lines(<nonnegative-integer>)
+    batch-timeout(<positive-integer>)
+    channel-args(
+        <empty>
+        <string> => <number>
+        <string> => <string>
+    )
+    compression(<yesno>)
+    database(<string>)
+    disk-buffer(
+        capacity-bytes(<number>)
+        compaction(<yesno>)
+        dir(<string>)
+        disk-buf-size(<number>)
+        flow-control-window-bytes(<nonnegative-integer>)
+        flow-control-window-size(<nonnegative-integer>)
+        front-cache-size(<nonnegative-integer>)
+        mem-buf-length(<nonnegative-integer>)
+        mem-buf-size(<nonnegative-integer>)
+        prealloc(<yesno>)
+        qout-size(<nonnegative-integer>)
+        reliable(<yesno>)
+        truncate-size-ratio(<nonnegative-float>)
+    )
+    flags(
+        <empty>
+        <string>
+    )
+    frac-digits(<nonnegative-integer>)
+    headers(
+        <empty>
+        <string> => <template-content>
+        <string> => <template-reference>
+    )
+    hook-commands(
+        setup(<string>)
+        shutdown(<string>)
+        startup(<string>)
+        teardown(<string>)
+    )
+    internal(<yesno>)
+    keep-alive(
+        <empty>
+        max-pings-without-data(<nonnegative-integer>)
+        time(<nonnegative-integer>)
+        timeout(<nonnegative-integer>)
+    )
+    local-time-zone(<string>)
+    log-fifo-size(<positive-integer>)
+    on-error(<string>)
+    password(<string>)
+    persist-name(<string>)
+    protobuf-schema(<path> => <template-content-list>)
+    retries(<positive-integer>)
+    schema(
+        <empty>
+        <string> <string> => <template-content>
+        <string> => <template-content>
+    )
+    send-time-zone(<string>)
+    table(<string>)
+    template-escape(<yesno>)
+    throttle(<nonnegative-integer>)
+    time-reopen(<positive-integer>)
+    time-zone(<string>)
+    ts-format(<string>)
+    url(<string>)
+    user(<string>)
+    worker-partition-key(<template-content>)
+    workers(<positive-integer>)
+)

@OverOrion OverOrion self-requested a review October 22, 2024 15:08
@alltilla
Copy link
Member Author

rebased to main and fixed the copyright check

@alltilla alltilla force-pushed the grpc-clickhouse branch 3 times, most recently from b68d55d to e407a4b Compare October 27, 2024 09:19
Copy link
Contributor

@OverOrion OverOrion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, nice!

Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
This is needed, because these symbols collide with the ones
in syslog.h.

Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Based on:
https://clickhouse.com/docs/en/sql-reference/data-types

Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Copy link
Contributor

@OverOrion OverOrion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice! 🚀

@OverOrion OverOrion merged commit de7242d into axoflow:main Nov 6, 2024
38 of 39 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants