Graylog MCP Server
Graylog MCP Server lets AI assistants search, analyze, cluster, and manage Graylog logs and related alerting/search configuration.
List and switch between configured Graylog connections.
Search logs with queries, filters, streams, time ranges, pagination, field selection, and exact/fuzzy matching.
Fetch messages surrounding a specific log entry.
Discover streams and distinct field values.
Run histograms, field aggregations, and field-over-time breakdowns; debug empty histogram queries.
Cluster similar log messages into Drain3 templates and list, delete, rename, export, or import template libraries.
Search events and inspect event definitions/notifications; README also documents write-gated alert/notification management.
Save, list, retrieve/execute, and delete reusable saved searches.
Provides direct access to Graylog logs with tools for searching, aggregating, analyzing, clustering, and managing logs, events, saved searches, and connections across multiple Graylog instances.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Graylog MCP Server show me error logs from the last hour"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
š Graylog MCP Server
An MCP server that gives AI assistants direct access to your Graylog logs -- search, aggregate, analyze, and cluster log data through natural language.
What It Does
This server exposes your Graylog instance(s) as MCP tools, so AI assistants like Claude, Cursor, and others can query logs on your behalf. Instead of context-switching to the Graylog UI, you describe what you're looking for and the assistant handles the rest.
33 tools covering:
Log search -- full-text and field-filtered queries with pagination, exact/fuzzy matching, and configurable field selection
Contextual analysis -- fetch surrounding messages around a specific log entry
Aggregations -- histograms, field statistics, and two-dimensional field-over-time breakdowns
Log clustering -- group similar messages into structural templates using Drain3, with persistent template libraries per connection
Events & alerting -- search events; read, create, update, enable/disable, delete and test event definitions and notifications (write-gated, secrets redacted)
Saved searches -- save, list, and reuse query configurations
Multi-connection -- switch between Graylog instances (e.g., nonprod vs prod) within one session
Stream & field discovery -- list streams, discover distinct field values
Related MCP server: log-mcp
Prerequisites
Node.js 18+
Graylog 6.xā7.x (tested on 6.2 and 7.1)
A Graylog API token (how to create one)
Installation
Via npx (recommended)
No installation needed. Configure your MCP client to run:
{
"mcpServers": {
"graylog": {
"command": "npx",
"args": ["graylog-mcp-server"]
}
}
}From source
git clone https://github.com/jagadeesh52423/graylog-mcp.git
cd graylog-mcp
npm installThen point your MCP client to the local entry point:
{
"mcpServers": {
"graylog": {
"command": "node",
"args": ["/absolute/path/to/graylog-mcp/src/index.js"]
}
}
}Run the tests with npm test (runs all test-*.js offline; no Graylog needed).
Configuration
Create ~/.graylog-mcp/config.json:
{
"connections": {
"nonprod": {
"baseUrl": "http://graylog-nonprod:9000",
"apiToken": "your_api_token",
"requireWriteConfirm": false
},
"prod": {
"baseUrl": "http://graylog-prod:9000",
"apiToken": "your_prod_api_token",
"defaultFields": ["timestamp", "message", "level", "source", "PODNAME"]
}
},
"defaultFields": ["timestamp", "gl2_message_id", "source", "env", "level", "message", "logger_name"]
}Option | Scope | Description |
| Root | Named Graylog instances, each with |
| Root | Global default fields returned in search results |
| Connection | Per-connection override (takes priority over global) |
| Connection | Write tools need |
If no defaultFields are set, all fields (*) are returned.
Override the config path with the GRAYLOG_CONFIG_PATH environment variable:
{
"mcpServers": {
"graylog": {
"command": "npx",
"args": ["graylog-mcp-server"],
"env": {
"GRAYLOG_CONFIG_PATH": "/path/to/custom/config.json"
}
}
}
}MCP Client Config Locations
Client | Config file |
Claude Code |
|
Cursor |
|
Claude Desktop (macOS) |
|
Usage
Once connected, talk to your AI assistant naturally. Some examples:
Connect to nonprod and show me error logs from the last hourWhat are the top error sources in production over the past 6 hours?Show me a histogram of level 3 errors over the past day, broken down by hourCluster the last 1000 error messages and show me the top patternsShow me the messages surrounding log ID 01KH5PDR893AZJQBYJJ87AQTW5Time Ranges
Relative: 30m, 1h, 2d, 1w, 3M, 1y
Absolute: provide from/to as ISO timestamps (2024-01-15T09:00:00Z) or Unix millis.
Default is 15 minutes if unspecified.
Available Tools
Connection Management
Tool | Description |
| List configured Graylog connections |
| Switch to a named connection |
Log Search
Tool | Description |
| Search logs with query, filters, time range, pagination |
| Get messages around a specific log entry by ID or timestamp |
| List available Graylog streams |
| Discover distinct values for a field (top N by count) |
Aggregations
Tool | Description |
| Time-bucketed message counts |
| Group by field with metrics (count, sum, avg, min, max) |
| Two-dimensional: field values over time intervals |
| Debug helper for empty histogram results |
Log Clustering
Tool | Description |
| Group similar messages into structural templates (Drain3) |
| List learned templates for the active connection |
| Remove a template |
| Give a template a human-readable label |
| Export template library as JSON |
| Bulk import templates (merge or replace) |
Templates are persisted at ~/.graylog-mcp/templates/<connection>.json and improve over time as more messages are clustered.
Events
Tool | Description |
| Search Graylog events with filters |
| List event definitions |
| List event notifications (secrets redacted) |
| Get one event definition by id |
| Get one notification by id (secrets redacted) |
| Create an alert; boilerplate defaulted, optional |
| Deep-merge a |
| Delete an alert |
| Enable (schedule) / disable (unschedule) an alert |
| Create a notification (Slack, Teams, email, HTTP, ...) |
| Deep-merge a |
| Delete a notification |
| Send a real test message through a notification |
āļø = writes to Graylog. On connections with requireWriteConfirm the call must include confirm: "yes"; without it the tool returns the method, path and (redacted) body it would send. dryRun never needs confirm ā for definitions it calls Graylog's /events/definitions/validate (which checks the config block only).
Minimal alert: { definition: { title, config: { query, streams, search_within_ms, execute_every_ms } }, threshold: { type: "count", operator: ">", value: 10 } }. config.streams is required on Graylog 7.
The threshold becomes config.series (count-) plus config.conditions.expression.
Secret redaction: notification reads replace webhook_url, api_key, api_secret, basic_auth and any key containing token/secret/password with "[REDACTED]", and credentials embedded in any URL (https://user:pass@host) become https://[REDACTED]@host. Updates merge onto the raw stored object, so secrets you don't patch keep their real values, and patch values containing "[REDACTED]" are ignored. Encrypted fields (basic_auth, api_secret) read back as { "is_set": true } rather than "[REDACTED]" and are changed with { "set_value": "..." }.
A 403 from these tools means the API token lacks eventdefinitions:* / eventnotifications:* permission, not that the tool is unsupported.
Saved Searches
Tool | Description |
| Save a query configuration for reuse |
| List all saved searches |
| Retrieve a saved search by name |
| Delete a saved search |
Project Structure
src/
āāā index.js Server bootstrap and request routing
āāā config.js Connection config and field defaults
āāā query.js Query building and Graylog API client
āāā tools.js Tool schema definitions (33 tools)
āāā timerange.js Flexible time range parsing
āāā aggregations.js Histogram, field stats, time-series
āāā events.js Graylog events API
āāā saved-searches.js Persistent saved search store
āāā clustering/
ā āāā index.js Strategy registry
ā āāā preprocess.js Message normalization and tokenization
ā āāā formatter.js Cluster response formatting
ā āāā template-store.js Per-connection template persistence
ā āāā strategies/
ā āāā drain3.js Drain3 log clustering algorithm
āāā tools/
āāā cluster-errors.js cluster_log_messages handler
āāā template-mgmt.js Template CRUD handlers
āāā event-admin.js Event definition/notification write toolsAdding a Clustering Algorithm
Create
src/clustering/strategies/<name>.jsimplementinghydrate,serialize, andcluster(seedrain3.js)Register it in
src/clustering/index.jsPass
algorithm: "<name>"tocluster_log_messages
License
Available Tools
23 toolscluster_log_messagesA
Cluster similar log messages into Drain3-style templates. Fetches messages with the same args as fetch_graylog_messages, then groups them by structural similarity. Templates are persisted per connection and reused across calls.
Inputs: to, from, field, query, +11 more.
debug_histogram_queryA
Debug helper to test if the histogram query finds any messages at all. Use this if histogram returns empty buckets.
Inputs: to, from, query, filters, +3 more.
delete_log_templateB
Delete a learned log template by ID.
Inputs: templateId (required).
delete_saved_searchB
Delete a saved search by name.
Inputs: name (required).
export_log_templatesA
Export all learned templates for the active connection as JSON.
Inputs: no named parameters.
fetch_graylog_messagesB
Fetch messages from the active Graylog connection. Use 'use_connection' first to select a connection.
Inputs: to, from, page, query, +7 more.
get_event_definitionsB
Get Graylog event definitions. Use 'use_connection' first to select a connection.
Inputs: page, query, perPage.
get_event_notificationsA
Get Graylog event notifications. Use 'use_connection' first to select a connection.
Inputs: page, perPage.
get_field_aggregationC
Aggregate log messages by field values with statistics. Get counts, sums, averages, etc. for field values.
Inputs: field (required), to, from, limit, +7 more.
get_field_time_aggregationC
Two-dimensional aggregation: field values over time. Shows how field values change over time intervals.
Inputs: field (required), to, from, limit, +6 more.
get_log_histogramC
Get a time-based histogram of log messages. Shows message counts over time intervals.
Inputs: to, from, query, filters, +6 more.
get_saved_searchB
Load and execute a saved search by name. Optional overrides can be provided to adjust the search at execution time.
Inputs: name (required), to, from, page, +2 more.
get_surrounding_messagesA
Get messages surrounding a specific message. Provide messageId (preferred) or messageTimestamp to identify the target message.
Inputs: limit, query, fields, filters, +5 more.
import_log_templatesB
Import templates into the active connection's library.
Inputs: templates (required), mode.
list_connectionsA
List all available Graylog connections configured in ~/.graylog-mcp/config.json
Inputs: no named parameters.
list_field_valuesA
List distinct values of a field with message counts. Useful for discovering available sources, environments, logger names, etc. Results are sorted by count descending.
Inputs: field (required), to, from, limit, +6 more.
list_log_templatesB
List learned log templates for the active connection.
Inputs: limit, sortBy, filterLabel.
list_saved_searchesB
List all saved searches.
Inputs: no named parameters.
list_streamsA
List all available Graylog streams in the active connection.
Inputs: no named parameters.
rename_log_templateB
Set or update a human-readable label for a template.
Inputs: label (required), templateId (required).
save_searchB
Save a named search query for later reuse. Saves query parameters so you don't have to re-type complex searches.
Inputs: name (required), to, from, query, +6 more.
search_eventsA
Search Graylog events and alerts. Use 'use_connection' first to select a connection.
Inputs: to, from, page, query, +6 more.
use_connectionA
Connect to a specific Graylog instance by name. Must be called before fetching messages.
Inputs: name (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
TDQS
Scored across 23 tools
Each tool targets a distinct resource or action, such as connections, streams, saved searches, event definitions, or log templates. Overlapping analysis tools like get_log_histogram and get_field_time_aggregation are clearly differentiated by their descriptions.
All tool names follow a consistent verb_noun pattern in snake_case, with verbs like list, get, fetch, save, delete, and rename. This makes the set predictable and easy to navigate.
23 tools is a substantial set, but it covers a broad range of Graylog functionality including connections, searches, events, analysis, and template management. The count is slightly heavy but each tool contributes to a cohesive workflow.
The tool surface provides strong coverage for log searching, analysis, saved searches, and log template CRUD operations. While event and stream management are read-only (no create/update/delete), the core log analysis lifecycle is well represented.
Related MCP Connectors
MCP server for AI dialogue using various LLM models via AceDataCloud
MCP server for OpenAI API (chat completions, image generation, embeddings) via AceDataCloud
Search your AI chat history (ChatGPT, Claude, Codex) from any MCP client. Remote, private, read-only
An MCP server that gives your AI access to the source code and docs of all public github repos
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceAn MCP server that connects Claude (or any MCP compatible client) to your existing log infrastructure. Query, summarize, and trace logs in plain English across GCP Cloud Logging, AWS CloudWatch, Azure Log Analytics, Grafana Loki, and Elasticsearch without writing filter expressions or leaving your editor.49 npm5MIT
- AlicenseAqualityDmaintenanceMCP server for log file analysis. Gives LLMs the ability to efficiently analyze large log files without loading them into context.7101MIT
- FlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI assistants to query and analyze logs from Grafana Loki using LogQL, supporting label discovery and keyword search.4-
- AlicenseAqualityDmaintenanceA read-only MCP server that gives AI assistants natural language access to Elasticsearch/Kibana logs for querying and analysis.71MIT