-
-
Notifications
You must be signed in to change notification settings - Fork 3
Document from_clickhouse #268
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
Open
mavam
wants to merge
17
commits into
main
Choose a base branch
from
topic/from-clickhouse
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,591
−117
Open
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3d81121
Document reading from data stores
mavam e950302
Use Excalidraw source for ClickHouse diagram
mavam 1a15e6b
Align ClickHouse docs with shared DB API
mavam d5e25fd
Add data-store guide to sidebar
mavam 626792e
Document ClickHouse uri support
mavam 2ac8913
Clarify ClickHouse URI database behavior
mavam 8d422bd
Update `from_clickhouse` docs
IyeOnline 3489aa7
Lead ClickHouse setup with Cloud
mavam b8d6d55
Address ClickHouse review feedback
mavam a93ae5d
Remove stale executor notes
mavam 801f548
Fix ClickHouse file source example
mavam adf68e8
Replace ClickHouse integration diagram
mavam fc5e66c
Improve ClickHouse integration docs
mavam 62d5553
Fix ClickHouse URI example source
mavam 4c09004
Separate ClickHouse TQL examples
mavam f9967c7
Tighten ClickHouse examples wording
mavam 1047ea8
Fix ClickHouse bool schema example
mavam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
src/content/docs/guides/collecting/read-from-data-stores.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| --- | ||
| title: Read from data stores | ||
|
mavam marked this conversation as resolved.
|
||
| --- | ||
|
|
||
| This guide shows you how to read from external data stores with TQL. You'll learn how to read full tables, push filters into SQL, inspect metadata, and stream new rows from MySQL. | ||
|
|
||
| Today, this guide focuses on <Op>from_mysql</Op> and <Op>from_clickhouse</Op>. | ||
| As Tenzir adds more data store integrations, the same patterns will apply. | ||
|
|
||
| ## Read a full table | ||
|
|
||
| Use `table=...` when you want to fetch all rows from a table. | ||
|
|
||
| Read a ClickHouse table: | ||
|
|
||
| ```tql | ||
| from_clickhouse table="security.events", | ||
| host="clickhouse.example.com", | ||
| password=secret("CLICKHOUSE_PASSWORD"), | ||
| tls=false | ||
| ``` | ||
|
|
||
| Or use a ClickHouse URI: | ||
|
|
||
| ```tql | ||
| from_clickhouse uri="clickhouse://default:secret@clickhouse.example.com:9000/security", | ||
| table="events", | ||
| tls=false | ||
| ``` | ||
|
|
||
| Read a MySQL table: | ||
|
|
||
| ```tql | ||
| from_mysql table="users", | ||
| host="mysql.example.com", | ||
| user="tenzir", | ||
| password=secret("MYSQL_PASSWORD"), | ||
| database="identity" | ||
| ``` | ||
|
|
||
| Use this mode when you want Tenzir to treat the table as the source of truth and | ||
| apply filtering later in the pipeline. | ||
|
|
||
| ## Push filters and projections into SQL | ||
|
|
||
| Use `sql=...` when the data store should do the filtering, sorting, or column | ||
| selection before Tenzir receives the rows. | ||
|
|
||
| Filter in ClickHouse: | ||
|
|
||
| ```tql | ||
| from_clickhouse sql="SELECT time, host, severity, message FROM events WHERE severity >= 3 ORDER BY time DESC", | ||
| host="clickhouse.example.com", | ||
| password=secret("CLICKHOUSE_PASSWORD"), | ||
| tls=false | ||
| ``` | ||
|
|
||
| Filter in MySQL: | ||
|
|
||
| ```tql | ||
| from_mysql sql="SELECT id, user, last_login FROM users WHERE active = 1 ORDER BY last_login DESC", | ||
| host="mysql.example.com", | ||
| user="tenzir", | ||
| password=secret("MYSQL_PASSWORD"), | ||
| database="identity" | ||
| ``` | ||
|
|
||
| This pattern reduces network traffic and lets you use the source system's query | ||
| planner and indexes. | ||
|
|
||
| ## Inspect metadata | ||
|
|
||
| Both operators can return metadata instead of table rows. | ||
|
|
||
| List ClickHouse tables in a database: | ||
|
|
||
| ```tql | ||
| from_clickhouse sql="SHOW TABLES FROM security", | ||
| host="clickhouse.example.com", | ||
| password=secret("CLICKHOUSE_PASSWORD"), | ||
| tls=false | ||
| ``` | ||
|
|
||
| Show the columns of a MySQL table: | ||
|
|
||
| ```tql | ||
| from_mysql table="users", | ||
| show="columns", | ||
| host="mysql.example.com", | ||
| user="tenzir", | ||
| password=secret("MYSQL_PASSWORD"), | ||
| database="identity" | ||
| ``` | ||
|
|
||
| Use metadata queries when you want to discover available tables, inspect a | ||
| schema, or validate assumptions before you run a larger pipeline. In | ||
| ClickHouse, prefer regular SQL such as `SHOW`, `DESCRIBE`, or queries against | ||
| system catalogs. | ||
|
|
||
| ## Poll for new rows from MySQL | ||
|
|
||
| MySQL supports a live polling mode for tables with a monotonically increasing | ||
| integer tracking column. | ||
|
|
||
| ```tql | ||
| from_mysql table="audit_log", | ||
| live=true, | ||
| tracking_column="id", | ||
| host="mysql.example.com", | ||
| user="tenzir", | ||
| password=secret("MYSQL_PASSWORD"), | ||
| database="security" | ||
| where severity == "high" | ||
| ``` | ||
|
|
||
| Use this mode when you want to turn a database table into a continuously polled | ||
| event source. | ||
|
|
||
| `from_clickhouse` does not currently provide a comparable live mode. It runs a | ||
| query, emits the result, and then finishes. | ||
|
|
||
| ## Shape rows after reading | ||
|
|
||
| Both operators produce structured events, so you can transform the result right | ||
| away. | ||
|
|
||
| ```tql | ||
| from_clickhouse sql="SELECT host, severity, message FROM events", | ||
| host="clickhouse.example.com", | ||
| password=secret("CLICKHOUSE_PASSWORD"), | ||
| tls=false | ||
| where severity >= 3 | ||
| message = message.to_upper() | ||
| ``` | ||
|
|
||
| This lets you treat database rows like any other event stream in Tenzir. | ||
|
|
||
| ## See also | ||
|
|
||
| - <Guide>collecting/read-from-message-brokers</Guide> | ||
| - <Guide>transformation/filter-and-select-data</Guide> | ||
| - <Guide>routing/send-to-destinations</Guide> | ||
| - <Op>from_clickhouse</Op> | ||
| - <Op>from_mysql</Op> | ||
| - <Integration>clickhouse</Integration> | ||
| - <Integration>mysql</Integration> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.