go-graphite / graphite-clickhouse

Graphite cluster backend with ClickHouse support
MIT License
213 stars 52 forks source link

Tags table not populating #18

Closed volfco closed 4 years ago

volfco commented 6 years ago

After getting tags correctly, I'm unable to populate the tags table using the command, nor get any results when directly talking to the api.

[root@core-clickhouse01 log]# curl http://127.0.0.1:9090/tags/autoComplete/tags?pretty=1&limit=100
[1] 4937
[root@core-clickhouse01 log]# clickhouse response status 404: Code: 46, e.displayText() = DB::Exception: Unknown table function WHERE, e.what() = DB::Exception
[root@core-clickhouse01 log]# graphite-clickhouse -tags
[root@core-clickhouse01 log]# clickhouse-client
ClickHouse client version 1.1.54380.
Connecting to localhost:9000.
Connected to ClickHouse server version 1.1.54380.

core-clickhouse01 :) select * from graphite_tag;

SELECT *
FROM graphite_tag 

┌───────Date─┬─Level─┬─Tag1─┬─Path─┬─IsLeaf─┬─Tags─┬────Version─┐
│ 2016-11-01 │     0 │      │      │      0 │ []   │ 1525973670 │
└────────────┴───────┴──────┴──────┴────────┴──────┴────────────┘
┌───────Date─┬─Level─┬─Tag1─┬─Path─┬─IsLeaf─┬─Tags─┬────Version─┐
│ 2016-11-01 │     0 │      │      │      0 │ []   │ 1525958477 │
└────────────┴───────┴──────┴──────┴────────┴──────┴────────────┘

2 rows in set. Elapsed: 10.025 sec. 

I'm feeding in tagged data

SELECT *
FROM graphite 
WHERE Path LIKE 'system.%'
LIMIT 10

┌─Path───────────────────────────────────────────┬─Value─┬───────Time─┬───────Date─┬──Timestamp─┐
│ system.core.count?host=core-dddev01&type=gauge │     1 │ 1525958330 │ 2018-05-10 │ 1525958354 │
│ system.core.count?host=core-dddev01&type=gauge │     1 │ 1525958350 │ 2018-05-10 │ 1525958369 │
│ system.core.count?host=core-dddev01&type=gauge │     1 │ 1525958360 │ 2018-05-10 │ 1525958389 │
│ system.core.count?host=core-dddev01&type=gauge │     1 │ 1525958380 │ 2018-05-10 │ 1525958414 │
│ system.core.count?host=core-dddev01&type=gauge │     1 │ 1525958410 │ 2018-05-10 │ 1525958444 │
│ system.core.count?host=core-dddev01&type=gauge │     1 │ 1525958450 │ 2018-05-10 │ 1525958479 │
│ system.core.count?host=core-dddev01&type=gauge │     1 │ 1525958480 │ 2018-05-10 │ 1525958519 │
│ system.core.count?host=core-dddev01&type=gauge │     1 │ 1525958530 │ 2018-05-10 │ 1525958564 │
│ system.core.count?host=core-dddev01&type=gauge │     1 │ 1525958590 │ 2018-05-10 │ 1525958614 │
│ system.core.count?host=core-dddev01&type=gauge │     1 │ 1525958630 │ 2018-05-10 │ 1525958669 │
└────────────────────────────────────────────────┴───────┴────────────┴────────────┴────────────┘

10 rows in set. Elapsed: 0.056 sec. Processed 24.58 thousand rows, 2.09 MB (442.29 thousand rows/s., 37.63 MB/s.) 

graphite-conifg.conf

[common]
listen = ":9090"
max-cpu = 1

[clickhouse]
url = "http://localhost:8123"
data-table = "graphite"
tree-table = "graphite_tree"
date-tree-table = ""
date-tree-table-version = 0
rollup-conf = "/etc/graphite-clickhouse/rollup.xml"
tag-table = "graphite_tag"
extra-prefix = ""
data-timeout = "1m0s"
tree-timeout = "1m0s"

[carbonlink]
server = ""
threads-per-request = 10
connect-timeout = "50ms"
query-timeout = "50ms"
total-timeout = "500ms"

[[logging]]
logger = ""
file = "/var/log/graphite-clickhouse.log"
level = "debug"
encoding = "mixed"
encoding-time = "iso8601"
encoding-duration = "seconds"

carbon-clickhouse.conf

[common]
metric-prefix = "carbon.ck-agents.{host}"
metric-endpoint = "local"
metric-interval = "30s"
max-cpu = 2

[logging]
file = "/var/log/carbon-clickhouse.log"
level = "debug"

[data]
path = "/var/local/carbon-clickhouse/data"
chunk-interval = "1s"
chunk-auto-interval = ""

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

[upload.graphite_tree]
type = "tree"
table = "graphite_tree"
date = "2016-11-01"
threads = 1
url = "http://localhost:8123/"
timeout = "1m0s"
cache-ttl = "12h0m0s"

[upload.graphite_tagged]
type = "tagged"
table = "graphite_tagged"
threads = 1
url = "http://localhost:8123/"
timeout = "1m0s"
cache-ttl = "12h0m0s"
[udp]
listen = ":2003"
enabled = true
[tcp]
listen = ":2003"
enabled = true

The data in question looks like this:

system.swap.total;host=core-dddev01;type=gauge 0 1525976850
system.swap.free;host=core-dddev01;type=gauge 0 1525976850
system.mem.usable;host=core-dddev01;type=gauge 630.55859375 1525976850
system.mem.pct_usable;host=core-dddev01;type=gauge 0.6871520032692537 1525976850

I think I have all my bases covered, so I must be missing something.

lomik commented 6 years ago

graphite-clickhouse has 2 different tags systems:

  1. graphite-compatible http://graphite.readthedocs.io/en/latest/tags.html . It uses tagged-table
  2. my own tag system (undocumented and only I use it). It allows you to add tags to existing metrics and access them via virtual subtrees. It uses tag-table

For graphite tagged metrics you need:

  1. In graphite-clickhouse replace tag-table = "graphite_tag" with
    tagged-table = "graphite_tagged"
  2. Remove table graphite_tag. You need only graphite_tagged table filled by carbon
  3. Don't run command graphite-clickhouse -tags
lomik commented 6 years ago

You can see the working preconfigured example here https://github.com/lomik/graphite-clickhouse-tldr