Elasticsearch MCP Server + Grafana MCP Server

Intermediate1 hour
Use Cases

Common Use Cases

  • Centralized log viewing
  • Error rate tracking
  • Request tracing
  • Performance monitoring
Before You Begin

Prerequisites

  • Elasticsearch cluster with log data
  • Grafana instance
  • Logs shipped to Elasticsearch via Filebeat/Fluentd
Walkthrough

Step-by-Step Guide

1

Configure Elasticsearch Data Source

Add Elasticsearch as a Grafana data source via MCP.

2

Create Log Explorer Panel

Build a Grafana panel that queries Elasticsearch for log entries.

3

Add Metric Panels

Create panels showing error rates, response times, and request volumes.

async function createLogDashboard(indexPattern) {
  await grafana.createDashboard({
    title: "Application Logs",
    panels: [
      { title: "Log Stream", type: "logs", datasource: "Elasticsearch", target: { query: "*", index: indexPattern } },
      { title: "Error Rate", type: "timeseries", target: { query: "level:error", metric: "count", interval: "1m" } },
      { title: "Top Errors", type: "table", target: { query: "level:error", metric: "count", groupBy: "message.keyword", size: 10 } }
    ]
  });
}
4

Set Up Alerts

Configure alerts for error rate spikes and new error types.

Examples

Code Examples

typescript
Log Search
async function searchLogs(query, timeRange) {
  return await elasticsearch.search({
    index: "logs-*",
    body: { query: { bool: { must: [{ query_string: { query } }, { range: { "@timestamp": { gte: timeRange.from, lte: timeRange.to } } }] } } }
  });
}
Help

Troubleshooting

How do I handle large log volumes?+
Queries are slow on large indices+

Quick Info

DifficultyIntermediate
Time Estimate1 hour
Tools
Elasticsearch MCP ServerGrafana MCP Server

Need Integration Help?

Our team can implement this integration for you.

Get in Touch
CortexAgent Customer Service

Want to skip the form?

Our team is available to help you get started with CortexAgent.

This chat may be recorded for quality assurance. You can view our Privacy Policy.