Skip to content

Optimizer: infer N_g from an external dataset #693

Description

@milindsrivastava1997

Goal

Provide the optimizer with real label-group cardinality N_g from an explicit external dataset, without contacting Prometheus.

Scope

  • Require a dataset input for the greedy optimizer CLI.
  • Define a canonical series-inventory format: one row per metric series, with metric and label columns.
  • For each profile key (metric, spatial_filter, grouping_labels), count distinct grouping-label tuples after applying the filter.
  • Treat an empty grouping-label set as N_g = 1.
  • Deduplicate raw samples by series identity if sample-level data is supported.
  • Pass the resulting count into CandidateConfig and use it for non-subpopulation-aware ingest/query costs.
  • Keep subpopulation-aware candidates at N_g = 1.
  • Fail clearly when the dataset does not cover a required profile; never interpret missing data as N_g = 0.
  • Keep the dataset loader separate from the optimizer core so an equivalent Prometheus-backed provider can be added later.

Tests

  • Distinct counts for empty, single-label, and multi-label groupings.
  • Spatial-filter handling.
  • Repeated samples do not inflate cardinality.
  • Missing profile coverage produces a clear error.
  • Offline CLI and in-memory test fixtures work without Prometheus.

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