Skip to content

feat: ClickHouse-Grafana drop-in (clickhouse-dropin/) #336

Description

@milindsrivastava1997

Tracking issue for adding a clickhouse-dropin/ — a self-contained docker-compose that transparently accelerates an existing ClickHouse + Grafana stack, analogous to asap-dropin/ for Prometheus.

Design: ASAPQuery sits in front of ClickHouse, impersonating its HTTP interface. Grafana's ClickHouse datasource plugin points to ASAP instead of ClickHouse directly. Unsupported queries are forwarded to the real ClickHouse.


TODOs

  • Protocol / adapter gaps (blockers)

    • Fix endpoint URL mismatch — adapter exposes /clickhouse/query but Grafana plugins expect root /
    • Auth passthrough — forward X-ClickHouse-User / X-ClickHouse-Key headers (official plugin) and Basic Auth (Altinity plugin)
    • Thread database URL param through the adapter
    • Strip (or handle) FORMAT clauses appended by Grafana plugins before sketch execution
    • Set correct Content-Type: text/plain; charset=UTF-8 on responses
    • Respect time range from query (adapter currently always uses SystemTime::now())
    • Make adapter selectable from engine_config.yaml without editing main.rs
  • Data ingest (open design question — decision needed before implementation)

    • Option A: polling ingest — ASAP periodically SELECTs new rows from ClickHouse (no extra infra, needs new ingest driver)
    • Option B: Kafka tap — reuse existing Kafka ingest driver, but adds infra complexity for users
    • Option C: query-driven ingest — fetch historical data from ClickHouse lazily on first query observation
  • Query tracker for ClickHouse

    • Implement build_schema_from_clickhouse() using system.columns / information_schema.columns
    • Extend planner to parse SQL structure (identify time column, dimension columns, aggregated values)
    • Remove/relax the hard-coded Prometheus-only restriction in engine_config.rs
  • Deployment scaffold

    • Create clickhouse-dropin/ with docker-compose.yml, docker-compose.dev.yml, docker-compose.override.yml
    • .env (CLICKHOUSE_URL, CLICKHOUSE_DATABASE, CLICKHOUSE_USER, CLICKHOUSE_PASSWORD, ASAP port)
    • config/engine_config.yaml with backend.type: clickhouse
    • Grafana provisioning config for ClickHouse datasource
  • README

    • Prerequisites, networking modes, .env config
    • How to redirect Grafana datasource URL to ASAP
    • Verification steps
    • Differences from Prometheus dropin (SQL not PromQL, ingest path, query tracker limitations)
  • Testing

    • Verify adapter compatibility with official ClickHouse Grafana plugin (endpoint, auth, FORMAT, Content-Type)
    • Verify adapter compatibility with Altinity plugin
    • Integration test for forwarding path (unsupported query → real ClickHouse → response)

Suggested order: fix protocol gaps → resolve ingest design → deployment scaffold + README → query tracker extension

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions