Building Production Security Features with LangChain and LLMs

elastic · Tech · 2024 · source Agentic: yes · promotional bias: high · source-backed · extracted with prompt 0.5.5 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Generative AI features for security operations

Elastic Security needed to help security teams migrate from legacy SIEM workflows to AI-assisted security analytics by automating labor-intensive tasks such as query generation, data integration creation, attack description, and analyst assistance.

Constraints:

Architecture

Elastic Security used LangChain, LangGraph, and LangSmith to deliver three AI-driven security features. Elastic AI Assistant generates ES|QL queries from natural language using RAG and a LangGraph workflow backed by a modified Elasticsearch LangChain vector store component. Automatic Import uses LangGraph and LLMs to generate integration packages from sample data through stateful workflows. Attack Discovery uses context-aware reasoning to identify and describe attacks. LangSmith instruments the LLM flows for tracing, debugging, performance tracking, and cost estimation, while Elastic's open inference API plus LangChain chat-model integrations let customers bring their LLM of choice.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  security-user[Security user] --> elastic-ai-assistant[Elastic AI Assistant]
  security-user --> automatic-import[Automatic Import]
  security-user --> attack-discovery[Attack Discovery]
  elastic-ai-assistant --> esql-generation-graph[ESQL generation graph]
  esql-generation-graph --> rag-retriever[RAG retriever]
  rag-retriever --> elasticsearch-vector-store[Elasticsearch vector store]
  elasticsearch-vector-store --> elasticsearch-platform[Elasticsearch Platform]
  esql-generation-graph --> chosen-llm[Chosen LLM]
  chosen-llm --> open-inference-api[Open inference API]
  open-inference-api --> langchain-chat-model-ecosystem[LangChain chat model ecosystem]
  automatic-import --> automatic-import-graph[Automatic Import graph]
  automatic-import-graph --> chosen-llm
  attack-discovery --> chosen-llm
  esql-generation-graph --> langsmith[LangSmith]
  automatic-import-graph --> langsmith
  attack-discovery --> langsmith
  elasticsearch-platform --> elastic-observability[Elastic Observability]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Security user Analyst or security operator using Elastic AI features for threat hunting, detection, attack discovery, or data integration. Elastic AI Assistant, Automatic Import, Attack Discovery
Elastic AI Assistant Assistant feature that answers security questions and generates ES|QL queries from natural language. Security user, ESQL generation graph, Chosen LLM
ESQL generation graph LangGraph workflow that retrieves context and produces ES|QL query output. Elastic AI Assistant, RAG retriever, Elasticsearch vector store, Chosen LLM, LangSmith
RAG retriever Retrieval-augmented generation layer that supplies rich context to the LLM for query formulation. ESQL generation graph, Elasticsearch vector store
Elasticsearch vector store Modified native Elasticsearch LangChain vector-store component used to retrieve vectorized content. RAG retriever, Elasticsearch Platform
Elasticsearch Platform Search AI platform and data substrate used by Elastic Security's generative features. Elasticsearch vector store, Elastic Observability
Chosen LLM Customer-selected language model used by Elastic generative AI features. Elastic AI Assistant, ESQL generation graph, Open inference API, LangChain chat model ecosystem
Automatic Import Feature that generates integration packages from sample data. Security user, Automatic Import graph
Automatic Import graph LangGraph stateful workflow that powers automatic data integration generation. Automatic Import, Chosen LLM, LangSmith
Attack Discovery Feature that identifies and describes attacks using generative AI. Security user, Chosen LLM, LangSmith
LangSmith Tracing and observability layer for LLM request breakdown, debugging, performance tracking, and cost estimation. ESQL generation graph, Automatic Import graph, Attack Discovery
Open inference API Elastic API surface enabling customer LLM choice. Chosen LLM, LangChain chat model ecosystem
LangChain chat model ecosystem Provider ecosystem used with Elastic's open inference API to expand customer LLM options. Open inference API, Chosen LLM
Elastic Observability Elastic's observability offering for tracing LangChain applications through OpenTelemetry. Elasticsearch Platform

Data flow

For ES|QL query generation, a security user asks a natural-language question in Elastic AI Assistant. A LangGraph workflow retrieves vectorized context from Elasticsearch through a modified LangChain vector store, passes that context to the chosen LLM, and returns ES|QL. Automatic Import follows a separate LangGraph workflow that turns sample data into an integration package. LangSmith traces the resulting LLM requests and workflows so the team can debug, track performance, and estimate costs.

4 supporting quotes
“Elastic AI Assistant generates ES|QL leveraging retrieval augmented generation (RAG) to provide rich context to the chosen LLM”article, stated
“LangGraph, a controllable agent orchestration framework, powers the end-to-end generation workflow.”article, stated
“use the Elasticsearch Platform to retrieve the vectorized content necessary to formulate the query. Below is a screenshot of LangSmith visualizing a trace of the resulting ES|QL generation LangGraph. ![Example workflow: ES|QL query”article, stated
“Automatic Import leverages LangGraph to generate the resulting integration package. With the combination of LangGraph and LLMs, users are now able to simply and quickly build stateful workflows. Below is a visual representation of the graph that powers”article, stated

Why this architecture

Elastic used LangGraph because the workflows require context-aware reasoning, controllable stateful orchestration, and multi-step generation rather than simple one-shot prompting. RAG addresses the need for query-specific security context, LangSmith addresses the opacity of production LLM requests, and open inference plus LangChain's chat model ecosystem addresses enterprise model-choice requirements.

4 supporting quotes
“provide the necessary tools for building applications that require context-aware reasoning, such as: * Enhancing Elastic AI Assistant’s ability to understand and react to complex security scenarios and generate queries * Attack Discovery’s ability to”article, stated
“Without AI, adopting it required learning the details of the query syntax and its functions. We wanted to simplify this process by enabling Elastic AI Assistant to generate ES|QL queries from natural language questions. Facilitating ES|QL generation was one”article, stated
“enabling the Elastic Security team to debug issues, track performance, and estimate costs.”article, stated
“Elastic Security users have the freedom to integrate the solution’s generative AI features with their LLM of choice.”article, stated

Models used: Customer-selected LLMs · LangChain chat models · Large language models

Scale

Alternatives considered (roads not taken)

Require analysts to learn ES|QL manually

Rejected because: Elastic wanted to simplify ES|QL adoption by generating queries from natural-language questions.

“Without AI, adopting it required learning the details of the query syntax and its functions. We wanted to simplify this process by enabling Elastic AI Assistant to generate ES|QL queries from natural language questions. Facilitating ES|QL generation was one”article, stated
“enabling Elastic AI Assistant to generate ES|QL queries from natural language questions. Facilitating ES|QL generation was one of the first core use cases for the integration of LangChain. Elastic AI Assistant generates ES|QL leveraging [retrieval augmented”article, stated

One fixed LLM provider

Rejected because: Enterprise security users may need their own preferred model for cost, compliance, or capability reasons.

“Elastic Security users have the freedom to integrate the solution’s generative AI features with their LLM of choice.”article, stated
“ecosystem](https://js.langchain.com/v0.2/docs/integrations/chat/#features-natively-supported), the Elastic Security team is quickly expanding customer LLM options. Elastic Security is at the forefront of propelling security operations workflows with generative AI, using the Elasticsearch”article, stated

Ship LLM workflows without trace breakdowns

Rejected because: Production LLM applications need request-level visibility to debug issues, performance, and cost.

“detailed tracing and a complete breakdown of requests to large language models (LLMs), enabling the Elastic Security team to debug issues, track performance, and estimate costs. "Working with Elastic has been amazing in so”article, stated
“language models (LLMs), enabling the Elastic Security team to debug issues, track performance, and estimate costs. "Working with Elastic has been amazing in so many ways. Elastic AI Assistant for Security, powered by LangChain's standard”article, stated

Patterns

rag-retrieval (context-engineering)

Elastic AI Assistant uses retrieval over vectorized Elasticsearch content to ground ES|QL generation in relevant security context.

“leveraging retrieval augmented generation (RAG) to provide rich context to the chosen LLM”article, stated
“retrieve the vectorized content necessary to formulate the query.”article, stated

tool-use-orchestration (agent-architecture)

LangGraph orchestrates stateful security workflows for ES|QL generation and Automatic Import.

“LangGraph, a controllable agent orchestration framework, powers the end-to-end generation workflow.”article, stated
“users are now able to simply and quickly build stateful workflows.”article, stated

observability-tracing (operations)

Elastic uses LangSmith for LLM request breakdowns, debugging, performance tracking, and cost estimation.

“LangSmith offers detailed tracing and a complete breakdown of requests to large language models (LLMs)”article, stated
“Below is a screenshot of LangSmith visualizing a trace of the resulting ES|QL generation LangGraph.”article, stated

model-routing (model-operations)

Elastic's open inference API and LangChain chat-model ecosystem let users integrate their preferred LLM into the same features.

“freedom to integrate the solution’s generative AI features with their LLM of choice.”article, stated
“With Elastic’s open inference API and LangChain’s extensive chat model ecosystem”article, stated

structured-output-contract (output-control)

The ES|QL workflow turns free-form security questions into a specific query-language output.

“We wanted to simplify this process by enabling Elastic AI Assistant to generate ES|QL queries from natural language questions. Facilitating ES|QL generation was one of the first core use cases for the integration of LangChain.”article, stated
“Elastic AI Assistant generates ES|QL leveraging retrieval augmented generation (RAG) to provide rich context to the chosen LLM, enabling generation of a query based on the user’s input. [LangGraph](https://www.”article, stated

Tradeoffs

Use LangGraph for controllable workflows

Chose Stateful graph workflows for query generation and import generation over Simple sequential prompt chains.

Rationale: The source emphasizes context-aware reasoning, stateful workflows, and controllable agent orchestration.

“LangGraph, a controllable agent orchestration framework”article, stated
“Automatic Import Automatic Import leverages LangGraph to generate the resulting integration package. With the combination of LangGraph and LLMs, users are now able to simply and quickly build stateful workflows.”article, stated

Let customers choose LLMs

Chose Open inference API plus LangChain chat-model ecosystem over A single hardcoded model provider.

Rationale: Security customers can integrate generative features with the LLM provider that fits their requirements.

“LangChain Elastic Security users have the freedom to integrate the solution’s generative AI features with their LLM of choice. With Elastic’s open inference API and LangChain’s extensive chat model ecosystem,”article, stated
“ecosystem](https://js.langchain.com/v0.2/docs/integrations/chat/#features-natively-supported), the Elastic Security team is quickly expanding customer LLM options. Elastic Security is at the forefront of propelling security operations workflows with generative AI, using the Elasticsearch Platform”article, stated

Use Elastic search infrastructure inside the LangChain graph

Chose Modified Elasticsearch LangChain vector store over A separate retrieval backend disconnected from Elastic's platform.

Rationale: Using Elastic's own Search AI platform lets the generation workflow retrieve vectorized content needed for ES|QL formulation.

“Applying a modified version of the native Elasticsearch LangChain vector store component”article, stated
“use the Elasticsearch Platform to retrieve the vectorized content necessary to formulate the query.”article, stated

Gotchas (what bit them)

Security query languages impose a steep learning curve.

Root cause: Threat hunting and detection users otherwise need to learn ES|QL syntax and functions.

Resolution: Generate ES|QL from natural-language questions with RAG and LangGraph.

“adopting it required learning the details of the query syntax and its functions.”article, stated
“We wanted to simplify this process by enabling Elastic AI Assistant to generate ES|QL queries from natural language questions.”article, stated

Production LLM workflows are hard to debug without trace visibility.

Root cause: LLM requests span retrieval, graph execution, model calls, and generated query output.

Resolution: Instrument workflows with LangSmith to get request breakdowns, traces, performance tracking, and cost estimates.

“integration](https://www.elastic.co/elastic-agent) based on sample data LangSmith offers detailed tracing and a complete breakdown of requests to large language models (LLMs), enabling the Elastic Security team to debug issues, track performance, and estimate”article, stated
“requests to large language models (LLMs), enabling the Elastic Security team to debug issues, track performance, and estimate costs. "Working with Elastic has been amazing in so many ways. Elastic AI Assistant for Security, powered by LangChain's standard LLM”article, stated

The public case study gives limited failure or quality data.

Root cause: The article is a partner/product post and does not provide accuracy, latency, or detailed lessons-learned metrics.

Resolution: Treat the reported production/user outcome as directional and preserve promotional-bias metadata.

“This technical blog shares the engineering underpinnings of this work.”article, stated
“The release and timing of any features or functionality described in this post remain at Elastic's sole discretion.”article, stated

Evaluation

The source does not report a formal accuracy evaluation. It describes operational observability through LangSmith tracing, performance tracking, and cost estimation, plus production deployment to over 350 users. Elastic also points to Elastic Observability with OpenTelemetry for tracing LangChain applications.

Metrics: LangSmith trace breakdowns · Performance tracking · Cost estimation · Production user count · Application tracing · Logging · Metrics analysis

4 supporting quotes
“detailed tracing and a complete breakdown of requests to large language models (LLMs)”article, stated
“requests to large language models (LLMs), enabling the Elastic Security team to debug issues, track performance, and estimate costs. "Working with Elastic has been amazing in so many ways. Elastic AI Assistant for Security, powered by LangChain's standard LLM”article, stated
“Elastic AI Assistant for Security, powered by LangChain's standard LLM interfaces and instrumented using LangSmith, has successfully deployed to production, reaching over 350 users,” said Erick Friis, founding engineer at LangChain.”article, stated
“Elastic Observability harnesses the Elasticsearch Platform to deliver comprehensive LangChain tracing, along with end-to-end application tracing, logging, and metrics analysis. Discover how you can leverage [Elastic Observability with OpenTelemetry to trace your LangChain”article, stated

Outcomes

The only concrete scale claim in the source is production deployment reaching over 350 users; the post also states that three capabilities were released.

3 supporting quotes
“We’ve released three capabilities — Automatic Import, Attack Discovery, and [Elastic AI Assistant]”article, stated
“Elastic AI Assistant for Security, powered by LangChain's standard LLM interfaces and instrumented using LangSmith, has successfully deployed to production, reaching over 350 users,” said Erick Friis, founding engineer at LangChain.”article, stated
“Elastic Security users have the freedom to integrate the solution’s generative AI features with their LLM of choice.”article, stated