diff --git a/Cargo.toml b/Cargo.toml index def47f8..69944c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ch-grafana-cache" -version = "0.1.11" +version = "0.1.12" edition = "2021" license = "MIT OR Apache-2.0" diff --git a/README.md b/README.md index 4053d6c..aec1b0d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ # ch-grafana-cache -This utility is meant to be used with the [Clickhouse Grafana data source](https://grafana.com/grafana/plugins/grafana-clickhouse-datasource/). +This utility is meant to be used with the [Clickhouse Grafana data source](https://grafana.com/grafana/plugins/grafana-clickhouse-datasource/). It: -It extracts the SQL queries from a Grafana dashboard and sends them to a Clickhouse server for execution. The main use case is to perform caching of the responses, e.g. via [chproxy's caching feature](https://www.chproxy.org/configuration/caching/) or [Clickhouse's query cache](https://clickhouse.com/docs/en/operations/query-cache), to make the dashboards execute faster and with less load on the database servers. +- Extracts the SQL queries from a Grafana dashboard, and +- Sends them to a Clickhouse server for execution. + +The main use case is to perform caching of the responses, e.g. via [chproxy's caching feature](https://www.chproxy.org/configuration/caching/) or [Clickhouse's query cache](https://clickhouse.com/docs/en/operations/query-cache), to make the dashboards execute faster and with less load on the database servers. Variables are supported, even those depending on others. The tool runs over all combinations of variables. @@ -78,7 +81,7 @@ INFO ch_grafana_cache: Executing combination i=0 n_combinations=166 INFO ch_grafana_cache: Executed combination duration=178.932498ms size_mb=0.107275 ``` -## Verifying that `chproxy` caching works +### Verifying that `chproxy` caching works - Clear the `chproxy` cache. - Close the Grafana dashboard @@ -89,7 +92,23 @@ INFO ch_grafana_cache: Executed combination duration=178.932498ms size_mb=0.1072 If the dashboard gives cache misses, printing the cache key in chproxy ([here](https://github.com/ContentSquare/chproxy/blob/2d4c2bf185cb32bc127330b6f8d8614ba4ebbe61/cache/key.go#L86)) might allow understanding the difference between the cache queries and the Grafana ones. For example, a different HTTP compression setting will result in cache misses. -## Other solutions +## Installation + +- Get a precompiled binary or package from the [releases page](https://github.com/cpg314/ch-grafana-cache/releases); or +- Build yourself: + ``` + $ cargo make packages + ``` + +## Development + +``` +$ docker run --name clickhouse --rm -p 8123:8123 clickhouse/clickhouse-server:latest +$ # Install checkalot https://github.com/cpg314/checkalot +$ cargo checkalot +``` + +## Alternative solutions It does not seem possible to execute the queries without loading the Grafana front-end. For example, the [Grafana snapshot API](https://grafana.com/docs/grafana/latest/developers/http_api/snapshot/) states that it is meant to be called by the UI and requires the full dashboard payload.