Skip to content

Commit

Permalink
Bump to 0.1.12, update README
Browse files Browse the repository at this point in the history
  • Loading branch information
cpg314 committed Oct 27, 2024
1 parent 451cc95 commit 1a9a6f5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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
Expand All @@ -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.

Expand Down

0 comments on commit 1a9a6f5

Please sign in to comment.