You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs.logflare.com/docs/backends/clickhouse.mdx
+36-1Lines changed: 36 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ sidebar_position: 7
3
3
---
4
4
# ClickHouse
5
5
6
-
The ClickHouse backend is **ingest-only**to a ClickHouse [HTTP](https://clickhouse.com/docs/interfaces/http) endpoint.
6
+
The ClickHouse backend supports both **ingestion**and **querying** via a ClickHouse [HTTP](https://clickhouse.com/docs/interfaces/http) endpoint.
7
7
8
8
## Behavior and Configuration
9
9
@@ -50,3 +50,38 @@ The ingest table schema is as follows:
50
50
By default, the ClickHouse backends will utilize the [`MergeTree` engine](https://clickhouse.com/docs/engines/table-engines/mergetree-family/mergetree).
51
51
52
52
Note that when using ClickHouse Cloud, replication is handled automatically as mentioned in the [data replication documentaion](https://clickhouse.com/docs/engines/table-engines/mergetree-family/replication#creating-replicated-tables).
53
+
54
+
## Querying
55
+
56
+
ClickHouse backends support SQL querying through Logflare Endpoints and Alerts. The backend uses ClickHouse SQL dialect, which supports standard SQL features including:
57
+
58
+
- Common Table Expressions (CTEs) with `WITH` clauses
ClickHouse backends fully support [sandboxed queries](/concepts/endpoints#query-sandboxing) within Endpoints, allowing you to create secure, parameterized API endpoints where consumers can provide custom SQL while being restricted to pre-defined data subsets.
66
+
67
+
Example sandboxed ClickHouse endpoint:
68
+
69
+
```sql
70
+
WITH filtered_logs AS (
71
+
SELECT id, event_message, timestamp
72
+
FROM my_clickhouse_source
73
+
WHEREtimestamp> now() - interval 1 day
74
+
)
75
+
SELECT*FROM filtered_logs
76
+
```
77
+
78
+
Consumers can then query within the sandbox via the `sql=` parameter:
79
+
80
+
```sql
81
+
SELECT event_message, count(*) as count
82
+
FROM filtered_logs
83
+
GROUP BY event_message
84
+
ORDER BY count DESC
85
+
```
86
+
87
+
See the [Endpoints documentation](/concepts/endpoints) for more details on sandboxed queries and security features.
Copy file name to clipboardExpand all lines: docs/docs.logflare.com/docs/concepts/endpoints.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,10 @@ Parameters that do not match any that are declared in the SQL template will be i
59
59
60
60
You can create sandboxed queries by using a CTE within the query. It allows the Endpoint consumer to provide a custom SQL query through the `sql=` query parameter.
61
61
62
+
:::note
63
+
Sandboxed queries are supported for BigQuery and ClickHouse backends. PostgreSQL backends do not currently support this feature.
64
+
:::
65
+
62
66
For example, this sandboxed query creates a temporary result called `errors`, which limits the results to containing the `"ERROR"` string as well as being before the year `2020` .
0 commit comments