Threat Intel
Elastic ES|QL COMPLETION Enables In‑Query LLM Reasoning for Detection Triage
Elastic has added the COMPLETION command to ES|QL, allowing detection engineers to embed LLM inference directly into query logic. This eliminates the need for external SOAR or scripts to add contextual reasoning to behavioral rules. Defenders can now build smarter alert triage within a single query, using Elastic Cloud models or external LLM connectors.
What Happened
Elastic released the ES|QL COMPLETION command, a new query operator that injects LLM inference into ES|QL execution. The feature lets detection engineers add contextual reasoning to behavioral rules without leaving the query pipeline.
How It Works
The COMPLETION operator takes a prompt string field and returns the LLM’s response in a new field. Syntax: | COMPLETION result_field = prompt_field WITH { "inference_id": ".gp-llm-v2-completion" }. The inference model can be the built‑in Elastic Cloud model or an external provider via connectors to Azure OpenAI, Amazon Bedrock, OpenAI, or Google Vertex.
Practical Use
- Aggregate related events by host, user, or session.
- Build a context string from the aggregated fields.
- Pass the context to COMPLETION to generate a reasoned assessment.
- Filter or route alerts based on the LLM output.
Getting Started
Enable an Elastic Cloud subscription that includes LLM inference. If you prefer a custom model, configure the LLM connector per the official documentation. Then add the COMPLETION clause to your detection rule and test against known benign and malicious patterns.
Considerations
- LLM responses are probabilistic; validate outputs before automating actions.
- Monitor inference costs if using external providers.
- Ensure prompt construction avoids leaking sensitive data.