-
Notifications
You must be signed in to change notification settings - Fork 3
Home
Lorenzo Mangani edited this page Apr 16, 2022
·
3 revisions
![](https://user-images.githubusercontent.com/1423657/153759243-d950b5fa-d2a7-49b7-894c-cfd9c9531f82.png)
The following example illustrates mapping of clickhouse
query columns to metric labels and values.
Let's use the following fictional my_index
table as our datasource:
datetime | status | group |
---|---|---|
1631825843 | FINISHED | default |
1631825844 | FAILED | default |
1631825845 | FINISHED | default |
1631825846 | FAILED | custom |
1631825847 | FINISHED | default |
... | ... | ... |
Using the queries array, define a clickhouse query to execute and associate it with metrics bucket g
- Place your tags first in the query, metrics last
- Choose a type: gauge, histogram, counter
- Set the refresh rate to match the query range (ie: 60s)
database_metrics: [{
"_info": "Custom Metrics from Clickhouse",
"name": "my_status", // must be unique
"help": "My Status",
"query": "SELECT status, group, count(*) as counter FROM my_index FINAL PREWHERE (datetime >= toDateTime(now()-60)) AND (datetime < toDateTime(now()) ) group by status, group",
"labels": ["status","group"], // must match columns
"counter_name": "counter",
"refresh": "60s", // Refesh takes unit sign: (ns, ms, s, m, h)
"type":"gauge" // gauge
}]
Connect to the configured /metrics
HTTP endpoint defined in your configuration and await data
# HELP my_count My Counter
# TYPE my_count gauge
my_count{status="FINISHED",group="default"} 10