go-graphite / carbon-clickhouse

Graphite metrics receiver with ClickHouse as storage
MIT License
187 stars 47 forks source link

Update existing old tables to new schema? #103

Closed nakermann1973 closed 2 years ago

nakermann1973 commented 2 years ago

I have an installation using the old-format table definitions. Is there a script to update these to the new table definitions?

dc9eea99adab :) desc data;                                                                                                                                                                                                       

DESCRIBE TABLE data                                                                                                                                                                                                              

┌─name──────┬─type────┬─default_type─┬─default_expression─┐                                                                                                                                                                      
│ Path      │ String  │              │                    │                                                                                                                                                                      
│ Value     │ Float64 │              │                    │                                                                                                                                                                      
│ Time      │ UInt32  │              │                    │                                                                                                                                                                      
│ Date      │ Date    │              │                    │                                                                                                                                                                      
│ Timestamp │ UInt32  │              │                    │                                                                                                                                                                      
└───────────┴─────────┴──────────────┴────────────────────┘                                                                                                                                                                      

5 rows in set. Elapsed: 0.025 sec.                                                                                                                                                                                               

dc9eea99adab :) desc metrics;                                                                                                                                                                                                    

DESCRIBE TABLE metrics

┌─name────┬─type───┬─default_type─┬─default_expression─┐
│ Date    │ Date   │              │                    │
│ Level   │ UInt32 │              │                    │
│ Path    │ String │              │                    │
│ Deleted │ UInt8  │              │                    │
│ Version │ UInt32 │              │                    │
└─────────┴────────┴──────────────┴────────────────────┘
Felixoid commented 2 years ago

Does it look like what you need? https://github.com/go-graphite/graphite-clickhouse/blob/master/doc/index-table.md#migrate-tree-table

nakermann1973 commented 2 years ago

Thanks - I hadn't looked in that repo for upgrade docs.

However, that script looks like it is migrating from a different schema (or I am really confused). My tables have tags as part of the metric names, for example:

> select Path from data where Path like 'netdata.snark.zfs%?%' limit 1;
netdata.snark.zfs.actual_hits.hits?_architecture=x86_64&_container=unknown&_container_detection=none&_is_parent=true&_kernel_version=5.4.72-gentoo-chris-3&_os_name=Gentoo&_os_version=unknown&_system_cores=12&_system_cpu_freq=3300000&_system_disk_space=49629747879936&_system_ram_total=33647013888&_virt_detection=none&_virtualization=none

I don't see those tags being dealt with in the sample script you linked

My graphite-clickhouse config contains:

data-table = "graphite.data"
# date-tree-table = "graphite.series"
# date-tree-table-version = 2
tree-table = "graphite.metrics"
# tagged-table = "graphite.tagged"

my carbon-clickhouse config contains:

[upload.graphite]
type = "points"
table = "graphite.data"
threads = 2
url = "http://clickhouse:8123/"
timeout = "1m0s"

[upload.graphite_tree]
type = "tree"
table = "graphite.metrics"
date = "2016-11-01"
threads = 2
url = "http://clickhouse:8123/"
timeout = "1m0s"
cache-ttl = "12h0m0s"
Felixoid commented 2 years ago

let's ask @lomik

nakermann1973 commented 2 years ago

@lomik - have you had a chance to think about this. Do you have any old scripts for migrating the previous table versions to newer schemas?

nakermann1973 commented 2 years ago

As it turns out, I was able to migrate using https://github.com/go-graphite/graphite-clickhouse/blob/master/doc/index-table.md#migrate-tree-table. My I was using 'tree' format tables