elasticsearch-agent — субагент для GitHub Copilot: установка и функции
Субагент анализирует данные Elastic, чтобы искать причины ошибок, разбирать проблемы векторного поиска и предлагать меры по устранению угроз.
.github/agents/elasticsearch-observability.agent.mdЧто делает elasticsearch-agent
Субагент сопоставляет логи, метрики и APM-трейсы, чтобы искать причины сбоев и предлагать изменения в коде. Он также помогает писать и оптимизировать запросы ES|QL, настраивать индекс для векторного поиска и разбирать оповещения Elastic Security.
В конфигурации есть инструменты для чтения и редактирования файлов, выполнения команд и доступа к elastic-mcp/*. MCP-сервер подключается к Elastic через Kibana: перед запуском нужно подставить адрес Kibana и настроить секрет ELASTIC_API_KEY. Без этих значений доступ к данным Elastic не заработает.
Субагент может подготовить запрос для поиска P95-задержки, предложить настройки HNSW или исследовать ошибку сервиса по связанным данным. Установка для GitHub Copilot — файл .github/agents/elasticsearch-observability.agent.md.
Какие задачи решает
- найти причину HTTP 503 по логам, метрикам и APM-трейсам
- разобрать исключение Java по данным запроса
- переписать медленный запрос ES|QL
- настроить индекс для гибридного поиска с векторами
- суммировать данные по оповещению Elastic Security и предложить меры
Примеры запросов агенту
- Сопоставь логи, метрики и APM-трейсы сервиса
checkout-serviceс ошибкойHTTP 503и найди её причину. - Подготовь запрос ES|QL для расчёта P95-задержки трасс
POSTсервисаapi-gateway, в которых есть ошибка. - Разбери оповещение Elastic Security для
user_id: 'alice'и предложи шаги для проверки и устранения угрозы.
Как установить elasticsearch-agent
Вручную: положить файлы
.github/agents/elasticsearch-observability.agent.mdВручную: положить файлы
.claude/agents/elasticsearch-observability.mdДля всех проектов — ~/.claude/agents/. Claude делегирует задачу сам по полю description или по @-упоминанию. Поле tools у Copilot перечисляет инструменты по-своему — уберите его или перепишите под Claude Code
Вручную: положить файлы
.codex/agents/elasticsearch-observability.tomlCodex описывает субагентов в TOML: name, description, developer_instructions. Текст из Markdown перенесите в developer_instructions вручную. Для всех проектов — ~/.codex/agents/
Вручную: положить файлы
.cursor/agents/elasticsearch-observability.mdCursor понимает и .claude/agents/
По шагам, с командами для каждой платформы: Субагенты Claude Code: как создать, вызвать и не утопить контекст
Вопросы о elasticsearch-agent
Как установить elasticsearch-agent в GitHub Copilot?
Добавьте файл субагента по пути .github/agents/elasticsearch-observability.agent.md.
Что делает elasticsearch-agent?
Он анализирует данные Elastic для отладки кода, настройки поиска и разбора угроз безопасности. Также составляет и оптимизирует запросы ES|QL.
Что нужно настроить для подключения к Elastic?
Укажите адрес Kibana и настройте секрет ELASTIC_API_KEY. Сервер MCP использует их для авторизации и доступа к инструментам Elastic.
Исходный текст
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