Skip to content
Lorenzo Mangani edited this page Apr 16, 2022 · 3 revisions

PromCasa

🏷️ Usage Example

The following example illustrates mapping of clickhouse query columns to metric labels and values.

1) Choose a Clickhouse Datasource

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
... ... ...
2) Define a Metrics Bucket

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
}]
3) Output Metrics

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