Your AI coding assistant can read your code. It can't see your production. Elastic Lens fixes that.
Every AI coding tool β Cursor, GitHub Copilot, Amp β operates in a vacuum. They can read your code, suggest refactors, and write tests. But they're completely blind to production:
- They don't know your function handles 18,000 requests/day
- They don't know it has a 2.3% error rate since last week's deployment
- They don't know the last Stripe SDK change caused a P1 outage
- They don't know there's a NullPointerException on line 139
The data already exists in Elasticsearch β APM transactions, error logs, deployment records, incident history. It's just not connected to where developers work.
Elastic Lens bridges production data in Elasticsearch with your coding environment through two interfaces, powered by a single Elasticsearch Agent Builder agent.
- CodeLens annotations β inline production metrics (π’π‘π΄) above every function
- Hover tooltips β deployment history, incident records, SLA status
- Diagnostics β warning/error squiggles on high error-rate functions
- Sidebar chat β conversational AI with streaming responses for deep-dive investigation
Agent Builder has a built-in MCP server β zero custom server code. Any MCP-compatible tool (Cursor, Claude Desktop, Amp, Codex) connects instantly:
- "Is it safe to refactor processPayment?" β data-backed risk profile
- "What's causing the errors?" β semantic search across error logs
- "Show me the deployment that broke this" β ES|QL with LOOKUP JOINs
One data layer. One agent. Two surfaces.
| Tool | Type | Description |
|---|---|---|
lens.get_function_metrics |
ES|QL | Call volume, error rate, latency with service metadata JOIN |
lens.get_risk_profile |
ES|QL | Full risk assessment with 3 LOOKUP JOINs (services, deployments, incidents) |
lens.search_errors |
Index Search | Semantic search (ELSER) across error logs |
lens.get_deployment_history |
ES|QL | Recent deployments for a service |
lens.get_service_overview |
ES|QL | Health overview of all functions in a service |
lens.monitor_after_deploy |
Workflow | Post-deployment monitoring with rollback recommendations |
The get_risk_profile tool chains three LOOKUP JOINs in a single ES|QL query β correlating APM metrics with service metadata, deployment history, and incident records:
FROM apm_transactions
| WHERE transaction.name == ?function_name
| STATS total_calls = COUNT(*), errors = SUM(is_error),
avg_latency_ms = AVG(transaction.duration.us) / 1000,
p99_latency_ms = PERCENTILE(transaction.duration.us, 99) / 1000
BY service.name
| LOOKUP JOIN services_lookup ON service.name
| LOOKUP JOIN deployments_lookup ON service.name
| LOOKUP JOIN incidents_lookup ON service.name
- Elastic Cloud account (free trial works)
- Node.js 18+
- uv (Python package manager)
- VS Code 1.85+
git clone https://github.com/SinghCoder/elastic-lens.git
cd elastic-lens
cp .env.sample .envEdit .env with your Elastic Cloud Serverless credentials:
ES_URL=https://your-project-id.es.us-central1.gcp.elastic.cloud
KIBANA_URL=https://your-project-id.kb.us-central1.gcp.elastic.cloud
ES_API_KEY=your-api-key
API_KEY=your-api-key| Variable | Where to get it |
|---|---|
ES_URL |
Elastic Cloud console β your project β Endpoints β Elasticsearch URL |
KIBANA_URL |
Same page β Endpoints β Kibana URL |
ES_API_KEY / API_KEY |
Kibana β Project settings β Management β API Keys β Create API key |
Tip: One API key works for both
ES_API_KEYandAPI_KEY. All scripts auto-load from.env.
cd elasticsearch
bash setup.shCreates 6 indices (2 standard + 4 lookup mode) and bulk-loads services, deployments, incidents, and endpoints.
cd ../scripts
uv run generate_data.pyGenerates ~100K APM transactions and ~5K correlated error logs across 30 days. processPayment has an elevated error rate since deploy v2.4.1 β the demo's "hero bug."
uv run verify_data.py # verify data looks correctcd ../agent-builder
bash setup.shRegisters all tools and the orchestrator agent via Kibana API.
Codex
~/.codex/config.toml:
[mcp_servers.elastic-lens]
url = "https://YOUR_KIBANA_URL/api/agent_builder/mcp"
http_headers = { "Authorization" = "ApiKey YOUR_API_KEY", "kbn-xsrf" = "true" }Cursor
~/.cursor/mcp.json:
{
"mcpServers": {
"elastic-lens": {
"command": "npx",
"args": ["mcp-remote", "https://YOUR_KIBANA_URL/api/agent_builder/mcp", "--header", "Authorization:ApiKey YOUR_API_KEY"]
}
}
}Claude Desktop
~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"elastic-lens": {
"command": "npx",
"args": ["mcp-remote", "https://YOUR_KIBANA_URL/api/agent_builder/mcp", "--header", "Authorization:ApiKey YOUR_API_KEY"]
}
}
}Amp
.ampmcp in project root:
{
"mcpServers": {
"elastic-lens": {
"command": "npx",
"args": ["mcp-remote", "https://YOUR_KIBANA_URL/api/agent_builder/mcp", "--header", "Authorization:ApiKey YOUR_API_KEY"]
}
}
}cd vscode-extension
npm install
npm run compilePress F5 in VS Code to launch the Extension Development Host.
Open sample-project/ in the dev window:
cp sample-project/.elastic-lens.sample.json sample-project/.elastic-lens.json
# Edit with your Kibana URL and API key (or set KIBANA_URL / API_KEY env vars)You should see:
- π΄ Red CodeLens on
processPaymentβ high error rate - π‘ Yellow CodeLens on
calculateTaxβ approaching SLA - π’ Green CodeLens on
getUser,validateCart, etc. - Hover any function for full risk profile with incidents and deployments
- Warning squiggles on
processPayment
In your AI tool (Cursor/Claude/Amp), try:
Is it safe to refactor processPayment in checkout-service?
elastic-lens/
βββ elasticsearch/ # Index mappings, lookup data, setup script
βββ scripts/ # Python data generation and verification
βββ agent-builder/ # Agent + tool definitions, setup script
βββ vscode-extension/ # VS Code extension (CodeLens, Hover, Diagnostics, Sidebar)
βββ sample-project/ # Demo e-commerce API with .elastic-lens.json
βββ assets/ # Architecture diagrams and images
βββ mcp-config.json # MCP client config template
MIT β see LICENSE



