Schedule icon
Script icon
If icon
SlackIncomingWebhook icon
Log icon
Labels icon

Chroma Collection Distance Metric Validator

Audits Chroma vector database collections via REST API, validating HNSW distance space metrics before cosine/L2 mismatches corrupt RAG retrieval precision.

Categories
AIData

This blueprint monitors vector similarity search integrity across Chroma vector database clusters. Scheduled daily at 07:00 UTC, it audits collection metadata across all registered vector stores via the Chroma REST API, verifying that HNSW distance space metrics (cosine, l2, ip) align with production embedding models, and alerting AI platform engineers on Slack before distance formula mismatches corrupt semantic search accuracy.

How it works

  1. Scheduled Daily Trigger: The daily_collection_audit schedule trigger (io.kestra.plugin.core.trigger.Schedule) initiates the audit daily at 07:00 UTC.
  2. Chroma Metadata Ingestion: The audit_chroma_collections task (io.kestra.plugin.scripts.python.Script) queries /api/v1/collections, inspecting metadata for hnsw:space configuration across active vector stores.
  3. Metric Alignment Gate: The check_metric_mismatches flowable task (io.kestra.plugin.core.flow.If) evaluates whether any collection uses a distance metric differing from expected_distance_metric.
  4. Slack Alert Dispatch: When metric discrepancies are detected, notify_slack_metric_mismatch (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) delivers an incident briefing card to the AI engineering channel.
  5. Nominal Confirmation: When all collections conform to standard distance metrics, log_collections_nominal records confirmed status.
  6. Manifest Export: The export_collection_manifest task tags the execution with searchable status labels.

Architecture diagram

flowchart TD
    A[Schedule: Daily at 07:00 UTC] --> B[audit_chroma_collections: Query Chroma Collections API]
    B --> C{Distance Space Mismatch Detected?}
    C -- Yes --> D[notify_slack_metric_mismatch: Slack Webhook]
    C -- No --> E[log_collections_nominal: Log Nominal State]
    D --> F[export_collection_manifest: Execution Labels]
    E --> F

Use cases

  • Prevent Degraded Semantic Search Results: Catch collections mistakenly initialized with Euclidean L2 distance when dense embeddings require Cosine similarity.
  • Standardize Multi-Team Vector Ingestion: Enforce consistent distance space conventions across disparate machine learning models and engineering teams.
  • Audit Embeddings Dimension Uniformity: Verify that vector space metadata adheres to compliance standards prior to launching production LLM applications.

Inputs

Name Type Default Description
chroma_endpoint STRING http://chroma.internal:8000 Base REST API URL of the target Chroma vector database server.
expected_distance_metric STRING cosine Required HNSW distance space metric for vector collections (cosine, l2, or ip).
slack_channel STRING #ai-vector-store-alerts Slack channel destination for vector database configuration and distance metric alerts.

Expected outputs

  • {{ outputs.audit_chroma_collections.vars.total_collections_scanned }}: Total count of vector collections inspected.
  • {{ outputs.audit_chroma_collections.vars.mismatched_count }}: Count of collections failing distance metric validation.
  • {{ outputs.audit_chroma_collections.vars.has_distance_metric_mismatch }}: Boolean flag indicating if any misconfigured collections exist.
  • {{ outputs.audit_chroma_collections.outputFiles['chroma_audit_report.json'] }}: Structured JSON report detailing collection names and configured metrics.

Prerequisites

  • Chroma vector database server (v0.4.x+) accessible over local or VPC network.
  • Chroma authorization token (if token-based authentication is enabled).
  • Slack Incoming Webhook endpoint URL.

Secrets

  • CHROMA_AUTH_TOKEN: Bearer token for Chroma API authentication.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL.

Quick start

  1. Configure CHROMA_AUTH_TOKEN and SLACK_WEBHOOK_URL in your Kestra namespace secrets.
  2. Import this flow YAML into your Kestra workspace.
  3. Specify your internal Chroma server endpoint in chroma_endpoint.
  4. Click Execute in the UI to perform an immediate vector collection configuration audit.

Common pitfalls and troubleshooting

  • Default Distance Metric Behavior: If hnsw:space is omitted when creating a collection in Chroma, it defaults to l2; explicitly define metadata during initialization to prevent silent divergence.
  • In-Memory vs Persistent Chroma: When running Chroma in ephemeral in-memory mode, server restarts reset collections; ensure persistent storage mounts are verified.
  • Distance Formula Impact: Query scores returned by Cosine (1 - similarity) differ fundamentally from L2 distance (squared Euclidean length); downstream threshold filters will fail if spaces mismatch.

How to extend

  • Automate collection re-indexing or re-embedding workflows via LangChain or LlamaIndex scripts.
  • Track vector counts and index growth rates over time across collections.
  • Export collection metadata reports to MLflow or Weights & Biases model governance registries.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.