Design RAG-Assisted Kusto Query Generation
Turn an analyst's natural-language question into a grounded, authorized Kusto query with a safe preview path.
Problem statement
For this exercise, assume an observability product lets authenticated analysts ask a natural-language question about their own tenant's telemetry. The product returns a Kusto Query Language (KQL) query, a short explanation of the chosen tables and filters, and the schema or example-query references used to ground it.
The analyst may then explicitly request a small preview. The service must ask for clarification or decline when a request is ambiguous, outside the analyst's data access, or cannot be expressed as a bounded read-only query.
A typical question asks for event-time filtering and a grouped count or trend, such as errors by service during the last day; the output must use Kusto's tabular query pipeline rather than SQL.
The relevant Kusto tables, columns, types, tenant access rules, and approved example queries are versioned; different tenants may have different permitted views. Retrieved text and the model's output are untrusted.
An answer may name only objects authorized for that analyst, and a preview must execute only a server-validated query under the analyst's effective data scope, never on the model's authority.
Design the retrieval corpus and update path, grounding and generation flow, query validation, analyst clarification and preview contracts, and evaluation. The numbers below are practice assumptions, not reported interview constraints.
Building a Kusto engine, editing data, cross-tenant joins, and a general SQL assistant are outside scope.
What to build
- An authorized analyst can obtain a Kusto tabular-pipeline query and a concise explanation grounded in current, permitted schema and approved examples for a natural-language telemetry question.
- The analyst receives a clarification request or a reasoned refusal when intent, schema support, authorization, or query bounds are insufficient.
- After explicit analyst confirmation, the service can return a bounded preview of the exact validated query without broadening the analyst's effective access.
At scale
- For this exercise, assume 300 tenants, up to 200 approved telemetry tables or views per tenant, and 20,000 approved schema/example fragments across the service.
- For this exercise, expect a peak of 40 query-generation requests per second and a p95 of three seconds to return a query or clarification; preview execution has a separate ten-second deadline.
- For this exercise, cap each preview at a seven-day time window, 1,000 returned rows, and a tenant-specific resource budget; an over-budget query is declined before execution.
- For this exercise, publish approved schema changes to the derived retrieval index within two minutes. Every generation and preview must check current effective access and schema with their authoritative services before revealing an object or executing; fail closed when that check is unavailable. Revalidate an older generated query at preview time.