Repository navigation
Conversation
|
Workflow [PR], commit [8c57720] Summary: ❌
AI ReviewSummaryPR #93833 adds opt-in Prometheus remote-write routing through database and table URL segments, with per-table authorization, an alterable opt-in setting, and Missing context / blind spots
Findings💡 Nits
Final VerdictStatus: ✅ Approve |
7223ad8 to
e923891
Compare
|
Hi @nikitamikhaylov, |
|
There is one failure reported by CI ( Thanks! |
|
Hello @niyue! We appreciate the idea and the contribution. I ask because we'd like to adopt this strategy across more than just the remote-write protocol, and eventually introduce it to both the remote-read protocol and the query-api. If the prefix were to be used as it is authored today, it would unfortunately break the query-api protocol, as the majority of query-api clients (Grafana for example) expect a full URL as configuration, and then will issue queries like The proposed design is similar to how other multi-tenant time-series databases route to specific tables/partitions/tenants/etc. You can find a similar design in VictoriaMetrics' URL format here. Please let us know if you're receptive to rewriting your proposed change. Thanks again for authoring it! |
… as prefix instead of suffix so that it is consistent with remote-read/query api design.
b35f15e to
f75f56c
Compare
|
Hi @JTCunning @nikitamikhaylov, Thanks a lot for the guidance, and that makes perfect sense. I’ve updated the implementation to use the This is my first contribution to ClickHouse, so I’m still learning the conventions, thanks for the patient guidance. Could you please take another look when you have a chance? Appreciate the feedback! |
Resolve trivial include conflict in `PrometheusRequestHandler.cpp`: keep both `Common/QueryScope.h` (from master) and `Common/StringUtils.h` (from the PR branch). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Thanks to @alexey-milovidov for updating the branch to the latest version @nikitamikhaylov, I’ve addressed the PR comments, could you please take another look and let me know if it’s good to go? Appreciated. |
…ting-remote-write
The master branch already includes `Common/StringUtils.h`; the merge from the PR branch produced a duplicate include. Drop the duplicate. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ting-remote-write
|
Merged latest master to refresh CI. The CI failures on commit
@groeneai, please investigate the failures above and confirm if anything else is needed from this PR. The fix for the stress-test crash is in #104905. |
|
@alexey-milovidov confirmed — both failures on 1. AST fuzzer (amd_debug, targeted) / (amd_debug, targeted, old_compatibility) — STID 4870-4f21
Fix in flight: #104812 by @vitlibar — Resubmit #2: Preserve parameter types in timeseries aggregate functions — OPEN, BLOCKED, last activity 2026-05-17 23:25 UTC. The fix restores the invariant that This PR touches only 2. Stress test (arm_debug) — The crash is the UBSan null deref in Fix in flight: #104905 by you — Fix UBSan null deref in StorageTimeSeries constructor — OPEN, BLOCKED, last activity 2026-05-18 01:21 UTC. Skips the This PR does not modify Nothing additional needed from this PR. Once #104812 and #104905 land, a fresh CI rerun should clear both. SQLancer TLP* failures on the same commit are tracked separately under the chronic SQLancer family (issue #105009 / ~85% master rate over 30 days). — monitoring under session |
…ting-remote-write
…ation `APIv1Impl::getImpl` threw `BAD_ARGUMENTS` for `/read` and `/query` requests on a handler with `enable_table_name_url_routing` before any authentication, so a protected handler answered 400 without running `authenticateUserByHTTP` (and skipped the session audit path). The write-only check now runs in `ReadImpl` / `QueryImpl` after authentication, and a test checks that wrong credentials get the normal authentication error. Addresses review: ClickHouse#93833 (comment) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ting-remote-write Conflicts in `StorageTimeSeries.cpp` and `TimeSeriesSettings.cpp`: keep the new deduplication cache settings from master and add `prometheus_remote_write_dynamic_routing_enabled` next to them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… Prometheus request URL `Poco::URI` throws `Poco::URISyntaxException` on an invalid escape such as `POST /default/%ZZ/write`, which was answered with HTTP 500, so remote-write senders would retry the bad request forever. Convert it to `BAD_ARGUMENTS` both where `HTMLForm` parses the request URI and where the routing path segments are decoded, and add a regression test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ication`: expect HTTP 401 A wrong password of the `default` user over HTTP basic authentication is reported as `REQUIRED_PASSWORD`, which is answered with HTTP 401, not 403. https://s3.amazonaws.com/clickhouse-test-reports/PRs/93833/54178ddee43fba9428ef73da0162f33c187091f5/pr/result_pr.json ClickHouse#93833 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=93833&sha=54178ddee43fba9428ef73da0162f33c187091f5&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. In |
|
Already fixed by #121590 (merged into
|
…` by `TimeSeries` version 8 The setting is persisted in the `TimeSeries` table metadata, so a table having it could not be attached by an older server supporting version 7 (`UNKNOWN_SETTING` instead of a clean version mismatch). Bump `TimeSeriesVersion::LATEST` to 8, as it was done for the deduplication caches in version 7: the setting is rejected by `checkTimeSeriesSettings` (on `CREATE` and `ALTER`) for tables of earlier versions, and `CREATE TABLE ... AS` drops it when the new table gets an earlier version. ClickHouse#93833 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged |
…ting-remote-write Master took `TimeSeries` version 8 for the "time ranges" target table and moved `TimeSeriesVersion.h` to `src/Parsers/Prometheus`, so the `prometheus_remote_write_dynamic_routing_enabled` setting now requires version 9 (`MIN_WITH_REMOTE_WRITE_DYNAMIC_ROUTING_SETTING = 9`, `LATEST = 9`). The docs, the setting description, the gtest and the stateless test are updated accordingly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The latest version is 9 after the merge with master, add version 8 to the list of supported versions checked by the test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… 400, report the write-only rejection as Prometheus JSON A table without `prometheus_remote_write_dynamic_routing_enabled` is a permanent configuration mistake, but `SUPPORT_IS_DISABLED` was mapped to HTTP 500 which remote-write senders retry for ever, so use `BAD_ARGUMENTS` (HTTP 400). The rejection of non-write requests to a routing `prometheus_api_v1` handler is moved into the `try` block of `QueryImpl` so it is reported in the Prometheus JSON error envelope. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ting-remote-write Master took `TimeSeries` versions 9 (UTC partition key of the recent samples table) and 10 (no external targets or `id_type` / `id_generator` for new tables), so the `prometheus_remote_write_dynamic_routing_enabled` setting now arrives with version 11: `MIN_WITH_REMOTE_WRITE_DYNAMIC_ROUTING_SETTING = 11`, `LATEST = 11`. The documentation, the gtest, `04612_timeseries_version_setting` and `05355_time_series_remote_write_dynamic_routing_version` are updated accordingly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…th-only routing, column grants - The `BAD_ARGUMENTS` error for a request target `Poco::URI` can't parse passes the URI through `maskSensitiveQueryParametersInURI` and no longer quotes the `Poco::URISyntaxException` message, which can contain a part of the query string with credentials. - `APIv1Impl::getImpl` parses the request target before `handleRequest`, so a malformed escape there is now reported as `BAD_ARGUMENTS` (HTTP 400) too, instead of HTTP 500. - `getRawPath` cuts off the query and the fragment first and recognizes the absolute form only at the beginning of the target, so a URL in a query parameter (e.g. `query_id`) can't select the table. - The `INSERT` privilege is checked before the table lookup only with dynamic routing, and only on the columns every remote-write request inserts (`metric_name`, `tags`, `samples`). A handler with a fixed table again relies on the column-level check of the `INSERT` itself, so column-scoped grants work. - The docs mention that the routing setting requires `TimeSeries` version 11 now. Integration tests cover all four cases. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
…ting-remote-write Master took `TimeSeries` version 11 for the buckets of samples, so the `prometheus_remote_write_dynamic_routing_enabled` setting now arrives with version 12 (`MIN_WITH_REMOTE_WRITE_DYNAMIC_ROUTING_SETTING = 12`, `LATEST = 12`). The docs, the setting description and the tests pinning the latest version are updated accordingly. In the query API handler, master moved the table lookup out of the `try` block; it is skipped when `enable_table_name_url_routing` is set, so such a request is still rejected by `rejectURLPathRoutingForNonWriteEndpoint` in the Prometheus JSON error envelope. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged |
|
🕵 Merged |
PromQL Compliance ReportBaseline: S3 master
Extended support (upstream engine tests): native-histogram exclusions: 149; excluded assertions: 248; upstream Note: Prometheus compliance score is unchanged vs baseline. |
# Conflicts: # tests/queries/0_stateless/05140_time_series_bucketed_samples_table.reference
The documentation of the `TimeSeries` table engine said the latest version is 11, while this pull request bumps `TimeSeriesVersion::LATEST` to 12. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
🕵 Merged The translation units changed here compile on the merged tree; I did not build a full binary or run the tests locally, so the new CI run is the verification. The previous |
This PR addresses #93831
Changelog category (leave one):
Changelog entry
Support dynamic table routing for Prometheus
remote-writebased on the request URL, allowing a single handler to ingest data into multiple TimeSeries tables while preserving backward compatibility with fixed-table configuration.Documentation entry for user-facing changes
Motivation
In large-scale observability deployments, users often maintain many TimeSeries tables with similar schemas but different retention or ownership.
The existing Prometheus
remote-writeintegration requires one handler per table, with the table name hard-coded inconfig.xml, making configuration and operations difficult to scale.This change allows routing the target TimeSeries table dynamically from the request URL, enabling a single
remote-writehandler to serve multiple tables while keeping the previous behavior unchanged by default.Parameters
enable_table_name_url_routing(handler option, default:false)When enabled, the handler expects URLs in the form
/{database}/{table}/...and extracts the target table from the first two path segments.prometheus_remote_write_dynamic_routing_enabled(TimeSeries table setting, default:false)Enables dynamic table routing for the specified TimeSeries table.
Requests targeting tables without this setting enabled will be rejected.
Example usage
Request example:
POST /{db_name}/{table_name}/writeEnable dynamic routing on the target TimeSeries table:
Note
Medium Risk
Adds request-path-driven table selection to the Prometheus
remote_writehandler and gates writes with a new per-table setting, so misconfiguration or unexpected URLs could redirect writes or cause new 4xx/5xx failures.Overview
Enables Prometheus
remote_writeto dynamically route writes to differentTimeSeriestables by extracting{database}/{table}from the request URL whenenable_table_name_url_routingis set on the handler.Dynamic routing is opt-in and additionally gated per target table via new
TimeSeriessettingprometheus_remote_write_dynamic_routing_enabled(defaultfalse); requests to tables without it error out. Docs and integration tests were updated with the required URL regex and validation coverage for both enabled/disabled cases.Reviewed by Cursor Bugbot for commit d0e4020. Bugbot is set up for automated code reviews on this repo. Configure here.
Workflow [PR]
Sync PR [sync-upstream/pr/93833]