{"id":15684241,"url":"https://github.com/lmangani/clickheus","last_synced_at":"2025-05-07T15:49:20.979Z","repository":{"id":55902481,"uuid":"200023486","full_name":"lmangani/ClickHeus","owner":"lmangani","description":"Export ClickHouse recurring queries as Prometheus metrics","archived":false,"fork":false,"pushed_at":"2023-07-14T03:34:57.000Z","size":72,"stargazers_count":11,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-26T02:24:42.876Z","etag":null,"topics":["clickhouse","clickhouse-metrics","metrics","prometheus","query","recurring-jobs"],"latest_commit_sha":null,"homepage":"http://hepic.tel","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lmangani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-01T09:46:00.000Z","updated_at":"2024-07-23T06:48:57.000Z","dependencies_parsed_at":"2023-01-22T17:15:59.990Z","dependency_job_id":null,"html_url":"https://github.com/lmangani/ClickHeus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmangani%2FClickHeus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmangani%2FClickHeus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmangani%2FClickHeus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmangani%2FClickHeus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lmangani","download_url":"https://codeload.github.com/lmangani/ClickHeus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242986432,"owners_count":20217393,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clickhouse","clickhouse-metrics","metrics","prometheus","query","recurring-jobs"],"created_at":"2024-10-03T17:13:26.239Z","updated_at":"2025-03-11T06:31:00.719Z","avatar_url":"https://github.com/lmangani.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"⚠️ Active development has moved to [promcasa](https://github.com/metrico/promcasa)\n\n#   :clock2: *Click-Heus*\n\n#### ClickHouse Custom Metrics Exporter for Prometheus\n\n\u003cbr /\u003e\n\n\u003cimg src=\"https://user-images.githubusercontent.com/1423657/137605775-485de1af-20a1-47ae-933e-b91b9e08edb1.png\" width=500 /\u003e\n\n#### :star: ClickHeus Functionality\n\n- Execute recurring Clickhouse `queries`\n- Exctract mapped `labels` and `values`\n- Aggregate results using `metric buckets`\n- Publish as `prometheus` metrics\n\n---\n\n#### :page_facing_up:\tConfiguration\n\nClickheus acts according to the parameters configured in its `config.js` file.\n\n---\n\n\n#### :label: Usage Example\n\nThe following example illustrates mapping of `clickhouse` query columns to metric labels and values.\n\n##### 1) Choose a Clickhouse Datasource\nLet's use the following fictional `my_index` table as our datasource:\n\n|datetime  |status   |group   |\n|---|---|---|\n| 1631825843  | FINISHED  | default  |\n| 1631825844  | FAILED    | default  |\n| 1631825845  | FINISHED  | default  |\n| 1631825846  | FAILED    | custom   |\n| 1631825847  | FINISHED  | default  |\n| ...         | ...       | ...      |\n\n##### 2) Define a Metrics Bucket\nUsing the `prom_metrics` array, define and name new `bucket` and its definitions. \n- Type can be `gauge` or `histogram`\n- LabelNames should match the target tag columns\n```javascript\n  \"prom_metrics\": [{\n      \"name\": \"g\",\n      \"type\": \"gauge\",\n      \"settings\": {\n         \"name\": \"my_count\",\n         \"help\": \"My Counter\",\n         \"maxAgeSeconds\": 60,\n         \"labelNames\":[\n            \"status\",\n            \"group\"\n         ]\n      }\n  }]\n\n```\n\n##### 3) Define a Clickhouse Query\nUsing the `queries` array, define a `clickhouse` query to execute and associate it with metrics bucket `g`\n- Place your tags first in the query\n- Place your metric value last, and mark its position using the `counter_position` parameter _(count from 0)_.\n- Match the refresh rate in milliseconds to match the query range _(ie: 60 seconds)_\n```json\n  \"queries\":[{\n      \"name\": \"my_status\",\n      \"query\": \"SELECT status, group, count(*) FROM my_index FINAL PREWHERE (datetime \u003e= toDateTime(now()-60)) AND (datetime \u003c toDateTime(now()) ) group by status, group\",\n      \"counter_position\": 2,\n      \"refresh\": 60000,\n      \"metrics\":[\"g\"]\n  }]\n```\n\n##### 4) Output Metrics\nConnect to the configured `/metrics` HTTP endpoint defined in your configuration and await data\n```\n# HELP my_count My Counter\n# TYPE my_count gauge\nmy_count{status=\"FINISHED\",group=\"default\"} 10\n```\n\n\n---------\n\n### Credits\nThis project is sponsored by [QXIP BV](https://github.com/qxip) and [HEPIC](http://hepic.tel)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flmangani%2Fclickheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flmangani%2Fclickheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flmangani%2Fclickheus/lists"}