-
Notifications
You must be signed in to change notification settings - Fork 3
Home
Lorenzo Mangani edited this page Apr 15, 2022
·
3 revisions

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 |
... | ... | ... |
Let's define a new metric bucket with a ClickHouse query feeding a gauge every minute
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