Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ stopped polluting the per-data-point attribute set with the
encoding string (which had broken the per-series snapshot cache
key).

- **Inference-YAML pattern coverage.** Expanded
`asap-query-engine/examples/promql/inference_config.yaml` (and the
SQL twin) with multi-quantile / wider-range / rate / increase /
topk entries; closes
[ASAPCollector PROGRESS.md follow-up #4](https://github.com/ProjectASAP/ASAPCollector/blob/main/PROGRESS.md#open-follow-ups-not-e2e-blockers)
("Inference config breadth"). New `tests/inference_yaml_pattern_coverage.rs`
pins each family's YAML → `find_query_config` → `query_statistic`
routing.

## All-five-sketch query path verification (2026-04-30)

Each sketch type now has a runtime-verified PromQL → backend path
Expand Down
155 changes: 155 additions & 0 deletions asap-query-engine/examples/promql/inference_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,163 @@ metrics:
- label_1
cleanup_policy:
name: read_based
# Each (query, aggregation_id) pair binds a PromQL pattern to a precompute
# plan. The exact-string match in `find_query_config` requires the request
# query to canonicalize to one of the listed strings — wider-range / wider-
# shape variants (e.g. `[2m]`, `[5m]`, `rate(...)`, multi-quantile) need
# their own entries here, otherwise the request falls through to capability
# matching and (failing that) the cold tier. See
# `tests/inference_yaml_pattern_coverage.rs` for the runtime contract.
queries:
# ── Spatial quantile (existing canonical pattern + multi-quantile) ─────
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: quantile by (label_0) (0.5, fake_metric)
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: quantile by (label_0) (0.9, fake_metric)
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: quantile by (label_0) (0.95, fake_metric)
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: quantile by (label_0) (0.99, fake_metric)
# ── quantile_over_time: multi-quantile × wider ranges ──────────────────
# Routes to `Statistic::Quantile`; supported by DDSketch / KLL accumulators.
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: quantile_over_time(0.5, fake_metric[1m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: quantile_over_time(0.9, fake_metric[1m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: quantile_over_time(0.95, fake_metric[1m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: quantile_over_time(0.99, fake_metric[1m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: quantile_over_time(0.5, fake_metric[2m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: quantile_over_time(0.9, fake_metric[2m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: quantile_over_time(0.95, fake_metric[2m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: quantile_over_time(0.99, fake_metric[2m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: quantile_over_time(0.5, fake_metric[5m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: quantile_over_time(0.9, fake_metric[5m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: quantile_over_time(0.95, fake_metric[5m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: quantile_over_time(0.99, fake_metric[5m])
# ── sum_over_time / count_over_time: wider ranges ──────────────────────
# Routes to `Statistic::Sum` / `Statistic::Count`; supported by DDSketch /
# CountSketch / CountMinSketch accumulators (no-key total-volume fallback).
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: sum_over_time(fake_metric[1m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: sum_over_time(fake_metric[2m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: sum_over_time(fake_metric[5m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: count_over_time(fake_metric[1m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: count_over_time(fake_metric[2m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: count_over_time(fake_metric[5m])
# ── rate / increase: delta-capable sketches ────────────────────────────
# Routes to `Statistic::Rate` / `Statistic::Increase`; supported by
# IncreaseAccumulator / MultipleIncreaseAccumulator. KLL has no delta and
# will return an error for these — pair this YAML with an Increase-typed
# streaming aggregation when serving rate/increase queries.
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: rate(fake_metric[1m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: rate(fake_metric[2m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: rate(fake_metric[5m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: increase(fake_metric[1m])
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: increase(fake_metric[5m])
# ── Cardinality / generic spatial aggregations ─────────────────────────
# `count` over an HLL-backed aggregation routes to `Statistic::Count`,
# which the HLL accumulator answers as a unique-cardinality estimate.
# `sum` / `avg` route to `Statistic::Sum` / `(Sum, Count)`.
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: count(fake_metric)
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: sum(fake_metric)
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: avg(fake_metric)
# ── Top-K (CountSketch heavy-hitter readout) ───────────────────────────
# `topk(N, …)` routes to `Statistic::Topk`; CountSketch's `query_statistic`
# returns the row-mean total when no key is supplied (limitation: per-key
# top-K enumeration needs a paired SetAggregator on the agent — tracked
# upstream).
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: topk(5, fake_metric)
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: topk(10, fake_metric)
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: topk(50, fake_metric)
63 changes: 63 additions & 0 deletions asap-query-engine/examples/sql/inference_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,37 @@ tables:
value_columns: [cpu_usage, memory_usage]
cleanup_policy:
name: read_based
# Each entry binds a SQL template (NOW()-based, structurally matched) to a
# precompute plan. SQL pattern matching is structural — incoming queries
# with absolute timestamps still match the NOW()-based template as long as
# aggregation, columns, GROUP BY, and the window duration agree. See
# `tests/inference_yaml_pattern_coverage.rs` for the runtime contract.
queries:
# ── Quantile family (cpu_usage, multi-quantile, single window) ─────────
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: |
SELECT datacenter, quantile(0.5)(cpu_usage) as p50
FROM metrics_table
GROUP BY datacenter
WHERE time BETWEEN DATEADD(s, -11, NOW()) AND DATEADD(s, -10, NOW())
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: |
SELECT datacenter, quantile(0.9)(cpu_usage) as p90
FROM metrics_table
GROUP BY datacenter
WHERE time BETWEEN DATEADD(s, -11, NOW()) AND DATEADD(s, -10, NOW())
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: |
SELECT datacenter, quantile(0.95)(cpu_usage) as p95
FROM metrics_table
GROUP BY datacenter
WHERE time BETWEEN DATEADD(s, -11, NOW()) AND DATEADD(s, -10, NOW())
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
Expand All @@ -14,3 +44,36 @@ queries:
FROM metrics_table
GROUP BY datacenter
WHERE time BETWEEN DATEADD(s, -11, NOW()) AND DATEADD(s, -10, NOW())
# ── Sum / Count / Avg over wider windows (cpu_usage) ───────────────────
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: |
SELECT datacenter, SUM(cpu_usage) as total
FROM metrics_table
GROUP BY datacenter
WHERE time BETWEEN DATEADD(s, -60, NOW()) AND NOW()
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: |
SELECT datacenter, SUM(cpu_usage) as total
FROM metrics_table
GROUP BY datacenter
WHERE time BETWEEN DATEADD(s, -300, NOW()) AND NOW()
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: |
SELECT datacenter, COUNT(cpu_usage) as samples
FROM metrics_table
GROUP BY datacenter
WHERE time BETWEEN DATEADD(s, -60, NOW()) AND NOW()
- aggregations:
- aggregation_id: 1
read_count_threshold: 1
query: |
SELECT datacenter, AVG(cpu_usage) as mean
FROM metrics_table
GROUP BY datacenter
WHERE time BETWEEN DATEADD(s, -60, NOW()) AND NOW()
Loading