-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add ClickHouse driver to sql inputs/outputs plugins #9671
Conversation
Thanks so much for the pull request! |
!signed-cla |
Looks like new artifacts were built from this PR. Get them here!Artifact URLs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thanks for adding this driver @nahsi!
@nahsi one additional request, can you please also prepare a pull-request for |
@nahsi and another request: Please add a test-case, i.e. a docker instance where you can import the example tables. Take a look at the postgres and mysql tests in the repo. |
@nahsi any chance you add a test-case for this database type? |
@srebhan I will try to do it this weekend, very sorry for the delay 🙇🏼 |
@srebhan to use clickhouse-go I had to use With just I'm not sure if it is OK since I don't know golang and I know clickhouse only from OPS point of view :) But it works. Maybe it would be better to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work @nahsi, nice code and test! I have one suggestion regarding the special insert of clickhouse. My intention there is to prepare for other drivers that require special treatment by directly switch to a switch
statement. What do you think?
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
📦 Looks like new artifacts were built from this PR. Expand this list to get them here! 🐯Artifact URLs |
@nahsi any update on this PR? |
Sorry, I will do it this week. |
@srebhan I've commited your suggestions, ready for another review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nahsi thanks for the update. There are some minor formatting issues, but nothing too big.
🥳 This pull request decreases the Telegraf binary size by -1.74 % for linux amd64 (new size: 134.1 MB, nightly size 136.5 MB) 📦 Looks like new artifacts were built from this PR. Expand this list to get them here ! 🐯Artifact URLs |
@srebhan I've commited the changes you suggested. Please have a look again when you have time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nahsi perfect thank you for your contribution!
Looks good to me.
Maybe I'm doing something wrong, but I'm getting this error
Using following telegraf config [[outputs.sql]]
driver = "clickhouse"
data_source_name = "clickhouse://user:password@example.com:9000/database"
[outputs.sql.convert]
integer = "Int64"
text = "String"
timestamp = "DateTime"
defaultvalue = "String"
unsigned = "UInt64"
bool = "Uint8" However, from the same server I'm able to connect to clickhouse using cli clickhouse-client --user user --password password --host example.com --database database I've checked credentials several times, they are the same in both cases. UPD data_source_name = "tcp://example.com:9000?username=user&password=password&database=database" Now connection works. |
Got another error now
Clickhouse log message2022.02.14 06:07:46.082356 [ 2196388 ] {1ff9aa5d-c0c5-4322-8b15-5e94806715ef} TCPHandler: Code: 62. DB::Exception: Syntax error: failed at position 72 ('UInt64'): UInt64,"inactive" Int64 UInt64,"vmalloc_chunk" Int64 UInt64,"sreclaimable" Int64 UInt64,"swap_cached" Int64 UInt64,"used" Int64 UInt64,"huge_pages_free" Int64 U. Expected one of: DEFAULT, MATERIALIZED, ALIAS, NOT, NULL, COMMENT, CODEC, TTL, token, Comma, ClosingRoundBracket. (SYNTAX_ERROR), Stack trace (when copying this message, always include the lines below):
ClickHouse version 22.1.3.7 |
I think the cause of the problem is here, when value type is [outputs.sql.convert]
integer = "BIGINT"
unsigned = "UNSIGNED" but it would be better setting [outputs.sql.convert]
integer = "INT"
unsigned = "INT UNSIGNED" in the first place, because now Also, I've noticed that |
@crabvk can you please open an Issue for your issue ;-) instead of putting the information next to this PR!? |
its worked for me:
|
Hi. What exactly interests you in telegrapr configuration? Something is
wrong with CH?
вт, 21 февр. 2023 г., 10:31 zentkhv ***@***.***>:
… Can you please show you full telegraf config from you project?
—
Reply to this email directly, view it on GitHub
<#9671 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALVWTURPGFZEAX3ZYF7AVZTWYQZINANCNFSM5CWWKZJA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
HI!
Im trying to send metrics to clickhouse by telegraf with you part config example, but geting an error:
[agent] Failed to connect to [outputs.sql], retrying in 15s, error was 'driver: bad connection'
Add my full config.
I thought your full config will help me to solve my problem.
Вторник, 21 февраля 2023, 15:00 +10:00 от Okaho ***@***.***>:
Hi. What exactly interests you in telegrapr configuration? Something is
wrong with CH?
вт, 21 февр. 2023 г., 10:31 zentkhv ***@***.***>:
> Can you please show you full telegraf config from you project?
>
> —
> Reply to this email directly, view it on GitHub
> < #9671 (comment) >,
> or unsubscribe
> < https://github.com/notifications/unsubscribe-auth/ALVWTURPGFZEAX3ZYF7AVZTWYQZINANCNFSM5CWWKZJA >
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
—
Reply to this email directly, view it on GitHub , or unsubscribe .
You are receiving this because you commented. Message ID: <influxdata/telegraf/pull/9671/c1437859685 @ github . com>
|
/etc/telegraf/telegraf.conf
/etc/telegraf/telegraf.d/ping-telegraf.conf
ClickHouse:
|
@zentkhv, did you succeed? |
@Okaho , How did you understand which fields need to be added to the clickhouse table structure? |
My tables were created by telegraf, the above structures are given as an example. I suggest deleting the tables. The telegraf version is very important, i have 1.24.0 |
@Okaho , thank you very much! Finally I managed to write the data. I have a telegraph version 1.25.0, it writes both to a pre-created table, and can create its own. |
Great, very glad it worked out for you! |
Help me set up a route to send data to different systems. Using "routing plugin" https://www.influxdata.com/blog/telegraf-best-practices/ data stops going to both output plugin. |
I am using telegraf 1.29.4 and ClickHouse 24.1.5.6, while everything works great I have problem that metrics are written slow and after a while buffer is full and metrics are dropped. 2024-02-21T09:31:04+01:00 D! [outputs.sql] Wrote batch of 1000 metrics in 6.234639174s This should probably be in ms and not in seconds. Can someone please help with this issue? |
Please use the slack of forums to get support and not comment on closed PRs. If sending 1000 metrics is slow, then consider getting a network trace to see what part of the request is taking a long time, as most of the time the output spends is using the network. |
Required for all PRs:
Added ClickHouse to sql input drivers (using clickhouse-go)
Since there are no changes to plugin code, I'm not sure there is a need to add tests.