A Python exporter for collecting clickhouse tables sizes.
Project description
- Clickhouse table exporter
- Provided metrics
- Example output
- How to setup
- Dependencies
- How to run
- Roadmap
- Credits
Clickhouse table exporter
A Python exporter for collecting clickhouse tables sizes.
Provided metrics
All metrics have two default labes: database and table.
- clickhouse_table_exporter_table_size - size in bytes
- clickhouse_table_exporter_table_rows - rows in table
- clickhouse_table_exporter_table_days - difference between max_time and min_time of a table
- clickhouse_table_exporter_table_avg_day_size - size / the difference
Example output
$ curl -s 127.0.0.1:9001/ | egrep '^clickhouse_table_exporter_table.*foo'
clickhouse_table_exporter_table_size{database="foo",table="t1"} 71394.0
clickhouse_table_exporter_table_size{database="foo",table="t2"} 23827.0
clickhouse_table_exporter_table_rows{database="foo",table="t1"} 300.0
clickhouse_table_exporter_table_rows{database="foo",table="t2"} 100.0
clickhouse_table_exporter_table_days{database="foo",table="t1"} 11.0
clickhouse_table_exporter_table_days{database="foo",table="t2"} 11.0
clickhouse_table_exporter_table_avg_day_size{database="foo",table="t1"} 6237.17527149184
clickhouse_table_exporter_table_avg_day_size{database="foo",table="t2"} 2072.2592542634943
How to setup
All configuration is provided by environment variables
- CH_TE_POLL_INTERVAL - polling interval in seconds (default: 10)
- CH_TE_PORT - exporter port (default: 9001)
- CH_TE_DEBUG - enable debug logging
- CLICKHOUSE_HOST - a clickhouse instence host
- CLICKHOUSE_PORT - a clickhouse instence port, http port
- CLICKHOUSE_USER - user (is optionable)
- CLICKHOUSE_PASS - password (is optionable)
Dependencies
- clickhouse_connect
- prometheus_client
How to run
$ ./src/exporter.py
TODO: Make a pip package and docker container!
Dev env
$ CH_TE_DEBUG=1 ./develop/run.sh
Roadmap
- PIP package
- Docker image
- Github releases
Credits
- Thx for all cool guys and gals in this thread https://gist.github.com/sanchezzzhak/511fd140e8809857f8f1d84ddb937015
- How to write an exporter on Python https://trstringer.com/quick-and-easy-prometheus-exporter/
- Clickhouse connector https://clickhouse.com/docs/en/integrations/python
- How to deploy a Python package https://packaging.python.org/en/latest/tutorials/packaging-projects/
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file clickhouse_table_exporter-20230816.tar.gz
.
File metadata
- Download URL: clickhouse_table_exporter-20230816.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e75cb0e74a84f92ef5f05bfef1fed5feec190764b3aa3d16a5265189e3b062be |
|
MD5 | fd29ed64ac6def2c21ffbbab2366b761 |
|
BLAKE2b-256 | 366fc8c447871630d50066825afdd9b7526291c1512460c62a75462c2e5949cd |
File details
Details for the file clickhouse_table_exporter-20230816-py3-none-any.whl
.
File metadata
- Download URL: clickhouse_table_exporter-20230816-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 591c75f943f71243878e85f12f926aa34ec61804b158f54109c2ca1f94d88e4f |
|
MD5 | 9435a313635b4238f52537d9af335326 |
|
BLAKE2b-256 | c59017cdf3c299962dc1586a0b51328a439cea68d6e48da8800dcc87111f5303 |