go-graphite / carbon-clickhouse

Graphite metrics receiver with ClickHouse as storage
MIT License
186 stars 48 forks source link

How to delete specific metrics #37

Closed G-regL closed 5 years ago

G-regL commented 5 years ago

Hi there,

I recently wanted to delete a set of metrics which I was no longer using because I had rewritten their path with carbon-c-relay (telegraf.foo.bar.baz became telegraf.foo.bam.baz), but I suddenly realized I don't know how to do that with Clickhouse as the Graphite backend.

With go-carbon or the stock Graphite tools, it's as simple as deleting folders/files on disk, but with Clickhouse I'm not sure how to do it.

I figured issuing some ALTER TABLE queries like below would clear out the metrics I didn't want, and any new ones would re-populate.

ALTER TABLE default.graphite_reverse DELETE Where like(Path,'%.telegraf');
ALTER TABLE default.graphite_index DELETE Where like(Path,'telegraf.%');

However, I now see that while graphite_reverse has the new data I'd expect to see, graphite_index doesn't have the entries required to query the system for the metrics in quesion.

I manually created some entries in graphite_index for a few of the levels, and those paths now work, but I can't very well do it for all of them, since I have no idea when new ones will show up.

INSERT INTO graphite_index
VALUES
    (toDate('1970-02-12'), 20001, 'telegraf.', toUInt32(now())),
    (toDate('1970-02-12'), 20002, 'telegraf.foo.', toUInt32(now())),
    (toDate('1970-02-12'), 20003, 'telegraf.foo.bam.', toUInt32(now())),
    (toDate('1970-02-12'), 20004, 'telegraf.foo.bam.baz.', toUInt32(now()))

Shouldn't carbon-clickhouse be re-populating the index with any new metrics seen, or have I just hit my first Graphite/Carbon/Clickhouse snag?

lomik commented 5 years ago

Shouldn't carbon-clickhouse be re-populating the index with any new metrics seen, or have I just hit my first Graphite/Carbon/Clickhouse snag?

Metric will be uploaded to clickhouse again after cache of index table is expired (12h by default). You can force cache cleanup with the USR1 signal

G-regL commented 5 years ago

Oh, OK!!

What are the implications of changing the index cache timeout to be higher or lower?

On Wed, Jun 5, 2019 at 3:52 PM Roman Lomonosov notifications@github.com wrote:

Shouldn't carbon-clickhouse be re-populating the index with any new metrics seen, or have I just hit my first Graphite/Carbon/Clickhouse snag?

Metric will be uploaded to clickhouse again after cache of index table is expired (12h by default). You can force cache cleanup with the USR1 signal

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lomik/carbon-clickhouse/issues/37?email_source=notifications&email_token=AEO24NSIP7BBRV5X4D5FEVLPZAKOTA5CNFSM4HT7ZI6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXA2K6I#issuecomment-499230073, or mute the thread https://github.com/notifications/unsubscribe-auth/AEO24NUN53PECLHL3JOKSFLPZAKOTANCNFSM4HT7ZI6A .