-
Notifications
You must be signed in to change notification settings - Fork 54
IndexTable
Roman Lomonosov edited this page May 14, 2019
·
7 revisions
The index type table is used to look up metrics that match the query.
CREATE TABLE graphite_index (
Date Date,
Level UInt32,
Path String,
Version UInt32
) ENGINE = ReplacingMergeTree(Version)
PARTITION BY toYYYYMM(Date)
ORDER BY (Level, Path, Date);Where:
-
Date- date from received point. Or constant date for full metric list (1970-02-12by default) -
Level- metric name nesting level -
Version- time when the last point was received
Each metric spawns multiple entries in a table:
- daily
- daily with reversed Path and Level = 10000+OriginalLevel
- records with constant Date and Level = 20000+OriginalLevel for metric itself and all it parents
- record with constant Date, reversed Path and Level = 30000+OriginalLevel
For example, getting the metric lorem.ipsum.dolor.sit.amet adds the following entries to the table:
| Date | Level | Path | Version |
|---|---|---|---|
| 2019-05-14 | 5 | lorem.ipsum.dolor.sit.amet | 1557827619 |
| 2019-05-14 | 10005 | amet.sit.dolor.ipsum.lorem | 1557827619 |
| 1970-02-12 | 20001 | lorem. | 1557827619 |
| 1970-02-12 | 20002 | lorem.ipsum. | 1557827619 |
| 1970-02-12 | 20003 | lorem.ipsum.dolor. | 1557827619 |
| 1970-02-12 | 20004 | lorem.ipsum.dolor.sit. | 1557827619 |
| 1970-02-12 | 20005 | lorem.ipsum.dolor.sit.amet | 1557827619 |
| 1970-02-12 | 30005 | amet.sit.dolor.ipsum.lorem | 1557827619 |
-- direct Path and parents
INSERT INTO graphite_index (Date, Level, Path, Version)
SELECT
'1970-02-12',
Level,
Path,
Version
FROM graphite_tree;
-- reversed Path
INSERT INTO graphite_index (Date, Level, Path, Version)
SELECT
'1970-02-12',
Level,
arrayStringConcat(arrayMap(x->reverse(x), splitByChar('.', reverse(Path))), '.'),
Version
FROM graphite_tree
WHERE NOT Path LIKE '%.';
If you have not used series table and want to keep this behavior you should set index-use-daily = false in graphite-clickhouse config.