#general

Managing Data Lifecycles in Clickhouse

TLDR Alejandro needed help with data management in Clickhouse. Srikanth and vishal-signoz provided links and examples for implementing tag level TTL and data deletion.

Powered by Struct AI
12
4mo
Solved
Join the chat
May 11, 2023 (4 months ago)
Alejandro
Photo of md5-a8b7de0a2b191db78968c382f3454e26
Alejandro
08:36 PM
Looks I have not space at clickhouse:
Cannot reserve 1.00 MiB, not enough space

how can i drop my data from clickhouse since x days?
May 12, 2023 (4 months ago)
Alejandro
Photo of md5-a8b7de0a2b191db78968c382f3454e26
Alejandro
11:28 AM
Ahaa ok. I thought I have an option via SigNoz UI to clean data from determined date
11:29
Alejandro
11:29 AM
On the other hand, is a way to say for example application with tag service name helloworld keep traces from last 15 days ?
Srikanth
Photo of md5-ce04a9988e2fd758a659dc55be6f2543
Srikanth
03:35 PM
Yes, there is some form of tag level TTL, but there is no way to do it from UI.
May 14, 2023 (4 months ago)
Alejandro
Photo of md5-a8b7de0a2b191db78968c382f3454e26
Alejandro
05:06 PM
How can I do it ? Without the UI ?
May 15, 2023 (4 months ago)
Srikanth
Photo of md5-ce04a9988e2fd758a659dc55be6f2543
Srikanth
04:49 AM
through clickhouse command line
Alejandro
Photo of md5-a8b7de0a2b191db78968c382f3454e26
Alejandro
02:06 PM
can you share that command ?
Srikanth
Photo of md5-ce04a9988e2fd758a659dc55be6f2543
Srikanth
02:29 PM
I know it exists but haven’t tried it ourselves.
vishal-signoz
Photo of md5-f936d3e5743d23344d6c60813189716f
vishal-signoz
02:36 PM
Here’s an example Alejandro for the your case
CREATE TABLE events
(
    `event` String,
    `time` DateTime,
    `value` UInt64
)
ENGINE = MergeTree
ORDER BY (event, time)
TTL time + INTERVAL 1 MONTH DELETE WHERE event != 'error',
    time + INTERVAL 6 MONTH DELETE WHERE event = 'error'