Skip to main content
Glama
mshegolev

mshegolev/kibana-mcp

kibana_aggregate_logs

Read-onlyIdempotent

Group logs by field (e.g., level, service) and compute counts or metrics like avg, sum. Efficient aggregation without returning raw logs.

Instructions

Aggregate logs using a terms grouping and optional metric.

Wraps POST {ES_URL}/{index}/_search with size:0 (no hits returned) and a terms aggregation on group_by. This is the efficient way to get counts, averages, or sums grouped by a field value.

When more than 20 buckets are rendered in the text output, a truncation hint is appended — use the structured buckets field for the full list.

Examples: - Use when: "How many logs per log level in the last hour?" → index='logs-*', group_by='level', time_from='2026-04-18T09:00:00Z'. - Use when: "What is the average response time per service?" → group_by='service.keyword', metric='avg', metric_field='response_time_ms'. - Use when: "Top 10 HTTP status codes today." → group_by='http.response.status_code', size=10. - Don't use when: You need raw log content/messages — use kibana_search_logs which returns full _source objects. - Don't use when: You need time-series (histogram per interval) — that requires a date_histogram aggregation not supported here.

Returns: dict with total_documents / took_ms / buckets (list).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
indexYesElasticsearch index name or pattern (e.g. 'logs-*').
group_byYesField name for terms aggregation (e.g. 'level', 'service.keyword', 'http.response.status_code'). For text fields use the '.keyword' sub-field.
queryNoElasticsearch Query String Syntax filter applied before aggregation. Use '*' (default) to aggregate all documents, or narrow with e.g. 'service:api'.*
metricNoAggregation metric: 'count' (default, doc_count per bucket), 'avg', 'sum', 'min', 'max' (require metric_field).count
metric_fieldNoField to apply the metric on. Required when metric is 'avg', 'sum', 'min', or 'max'. Example: 'response_time_ms' for avg latency per service.
time_fieldNoName of the timestamp field.@timestamp
time_fromNoStart of time range. ISO-8601 or epoch-ms.
time_toNoEnd of time range. ISO-8601 or epoch-ms.
sizeNoNumber of terms buckets to return (1-100, default 10).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
total_documentsYes
took_msYes
indexYes
group_byYes
metricYes
metric_fieldYes
buckets_countYes
bucketsYes
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations declare readOnlyHint=true, destructiveHint=false, idempotentHint=true. The description adds that the tool wraps a POST request with size:0 (no hits), truncates output beyond 20 buckets with a hint, and returns a structured dict. It also notes efficiency for grouped stats, going beyond annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-organized into an opening summary, technical detail, examples with when-to-use sections, and return format. It uses bullet points and concise language without redundancy. Every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's 9 parameters, full schema coverage, explicit annotations, and output schema description ('total_documents, took_ms, buckets'), the description is complete. It covers all necessary context for an agent to invoke the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has 100% coverage with descriptions for all 9 parameters. The description further clarifies parameter roles through concrete examples (e.g., using time_from, group_by, metric_field), adding value beyond the schema. Baseline 3, plus 1 for enhanced semantics via examples.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific action: 'Aggregate logs using a terms grouping and optional metric.' It clearly identifies the resource (logs) and method (terms aggregation). The description distinguishes this tool from siblings by mentioning kibana_search_logs for raw logs and noting that date_histogram is not supported, making the purpose unmistakable.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit guidance is provided with multiple 'Use when' and 'Don't use when' examples. It names the alternative tool (kibana_search_logs) for raw logs and explains what aggregation type is not supported (date_histogram). This helps the agent decide correctly.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mshegolev/kibana-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server