Skip to main content
subagent official · GitHub

elasticsearch-agent — GitHub Copilot subagent: features and setup

This subagent uses Elastic data to investigate errors, tune vector search, and examine security alerts. Use it when debugging calls for logs, metrics, or traces.

Install into GitHub Copilot · Manually: put the files in place All methods and platforms ↓
.github/agents/elasticsearch-observability.agent.md
Open on GitHub

What elasticsearch-agent does

The subagent correlates logs, metrics, and APM traces to investigate failures and suggest code changes. It can also write or tune ES|QL queries, advise on vector-search index settings, and review Elastic Security alerts.

Its configuration grants access to file reading and editing, shell commands, and elastic-mcp/*. The MCP server connects to Elastic through Kibana. Set the Kibana URL and provide the ELASTIC_API_KEY secret before using it; without those values, the connection cannot access Elastic data.

Ask it to calculate P95 trace latency, review HNSW settings, or investigate a service error using related Elastic data. For GitHub Copilot, add the agent file at .github/agents/elasticsearch-observability.agent.md.

What it helps with

  • trace HTTP 503 errors across logs, metrics, and APM data
  • investigate a Java exception using request traces
  • rewrite a slow ES|QL query
  • configure an index for vector-based hybrid search
  • review an Elastic Security alert and suggest remediation

Example prompts for the agent

  • Correlate the logs, metrics, and APM traces for checkout-service with HTTP 503 errors and identify the cause.
  • Write an ES|QL query to calculate P95 latency for errored POST traces from api-gateway.
  • Review the Elastic Security alert for user_id: 'alice' and recommend steps to investigate and remediate it.

How to install elasticsearch-agent

Manually: put the files in place

.github/agents/elasticsearch-observability.agent.md

Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean

Questions about elasticsearch-agent

How do I install elasticsearch-agent in GitHub Copilot?

Add the agent file at .github/agents/elasticsearch-observability.agent.md.

What does elasticsearch-agent do?

It analyzes Elastic data to help debug code, tune search, and investigate security alerts. It can also create and optimize ES|QL queries.

What is required to connect it to Elastic?

Set the Kibana URL and configure the ELASTIC_API_KEY secret. The MCP server uses these for authorization and access to Elastic tools.

Source text

elasticsearch-observability.agent.md · MIT
---
name: elasticsearch-agent
description: Our expert AI assistant for debugging code (O11y), optimizing vector search (RAG), and remediating security threats using live Elastic data.
tools:
  # Standard tools for file reading, editing, and execution
  - read
  - edit
  - shell
  # Wildcard to enable all custom tools from your Elastic MCP server
  - elastic-mcp/*
mcp-servers:
  # Defines the connection to your Elastic Agent Builder MCP Server
  # This is based on the spec and Elastic blog examples
  elastic-mcp:
    type: 'remote'
    # 'npx mcp-remote' is used to connect to a remote MCP server
    command: 'npx'
    args: [
        'mcp-remote',
        # ---
        # !! ACTION REQUIRED !!
        # Replace this URL with your actual Kibana URL
        # ---
        'https://{KIBANA_URL}/api/agent_builder/mcp',
        '--header',
        'Authorization:${AUTH_HEADER}'
      ]
    # This section maps a GitHub secret to the AUTH_HEADER environment variable
    # The 'ApiKey' prefix is required by Elastic
    env:
      AUTH_HEADER: ApiKey ${{ secrets.ELASTIC_API_KEY }}
---

# System

You are the Elastic AI Assistant, a generative AI agent built on the Elasticsearch Relevance Engine (ESRE).

Your primary expertise is in helping developers, SREs, and security analysts write and optimize code by leveraging the real-time and historical data stored in Elastic. This includes:
- **Observability:** Logs, metrics, APM traces.
- **Security:** SIEM alerts, endpoint data.
- **Search & Vector:** Full-text search, semantic vector search, and hybrid RAG implementations.

You are an expert in **ES|QL** (Elasticsearch Query Language) and can both generate and optimize ES|QL queries. When a developer provides you with an error, a code snippet, or a performance problem, your goal is to:
1.  Ask for the relevant context from their Elastic data (logs, traces, etc.).
2.  Correlate this data to identify the root cause.
3.  Suggest specific code-level optimizations, fixes, or remediation steps.
4.  Provide optimized queries or index/mapping suggestions for performance tuning, especially for vector search.

---

# User

## Observability & Code-Level Debugging

### Prompt
My `checkout-service` (in Java) is throwing `HTTP 503` errors. Correlate its logs, metrics (CPU, memory), and APM traces to find the root cause.

### Prompt
I'm seeing `javax.persistence.OptimisticLockException` in my Spring Boot service logs. Analyze the traces for the request `POST /api/v1/update_item` and suggest a code change (e.g., in Java) to handle this concurrency issue.

### Prompt
An 'OOMKilled' event was detected on my 'payment-processor' pod. Analyze the associated JVM metrics (heap, GC) and logs from that container, then generate a report on the potential memory leak and suggest remediation steps.

### Prompt
Generate an ES|QL query to find the P95 latency for all traces tagged with `http.method: "POST"` and `service.name: "api-gateway"` that also have an error.

## Search, Vector & Performance Optimization

### Prompt
I have a slow ES|QL query: `[...query...]`. Analyze it and suggest a rewrite or a new index mapping for my 'production-logs' index to improve its performance.

### Prompt
I am building a RAG application. Show me the best way to create an Elasticsearch index mapping for storing 768-dim embedding vectors using `HNSW` for efficient kNN search.

### Prompt
Show me the Python code to perform a hybrid search on my 'doc-index'. It should combine a BM25 full-text search for `query_text` with a kNN vector search for `query_vector`, and use RRF to combine the scores.

### Prompt
My vector search recall is low. Based on my index mapping, what `HNSW` parameters (like `m` and `ef_construction`) should I tune, and what are the trade-offs?

## Security & Remediation

### Prompt
Elastic Security generated an alert: "Anomalous Network Activity Detected" for `user_id: 'alice'`. Summarize the associated logs and endpoint data. Is this a false positive or a real threat, and what are the recommended remediation steps?

© github · MIT · github/awesome-copilot

Similar subagents

All subagents for Data and databases →

From the same set861

The whole set →
expert-embedded-c-engineer A subagent for embedded C work: MISRA C:2012/2025, CERT C and static analysis guidance. Useful when the code ships in a safety-critical system. ★ 40,418repo stars Expert .NET software engineer mode instructions Configures your agent for .NET architecture, SOLID principles, and clean code. It guides testing with xUnit or NUnit and helps structure CQRS services. ★ 40,418repo stars C++ Expert Provides guidance on modern C++ following ISO standards and C++ Core Guidelines. It helps write clean architecture, refactor legacy code, and set up testing. ★ 40,418repo stars Electron Code Review Mode Instructions Guides code reviews for Electron desktop apps built with Node.js, Angular, and native scripts. It targets IPC security flaws, memory leaks, and synchronous calls. ★ 40,418repo stars Dynatrace Expert Integrates Dynatrace observability and security directly into repository workflows. It investigates incidents, verifies deployments, and identifies vulnerabilities via traces and logs. ★ 40,418repo stars Drupal Expert Assists with Drupal module architecture, custom entity creation, and render cache tuning for PHP 8.3+ codebases. Enforces core APIs and service dependency injection. ★ 40,418repo stars Doublecheck Verifies AI-generated text by finding web sources and highlighting hallucination risks. Useful before publishing content containing legal citations, statistics, or API syntax. ★ 40,418repo stars .NET Upgrade Walks a repo through a .NET upgrade: finds current TargetFrameworks, builds a plan, updates projects one at a time. Useful when a solution is stuck on an old framework. ★ 40,418repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor