Zing Forum

Reading

Agentic Microservices: An Intelligent Observability System Based on MCP and LangGraph

This project builds an intelligent observability agent using the MCP protocol and LangGraph, which can automatically analyze microservice logs and monitoring data to help developers quickly diagnose production environment issues. This article introduces its architectural design, core components, and typical application scenarios.

Agentic AIMCP协议LangGraph可观测性微服务智能代理Spring AI故障排查
Published 2026-05-23 03:45Recent activity 2026-05-23 03:52Estimated read 6 min
Agentic Microservices: An Intelligent Observability System Based on MCP and LangGraph
1

Section 01

Introduction / Main Floor: Agentic Microservices: An Intelligent Observability System Based on MCP and LangGraph

This project builds an intelligent observability agent using the MCP protocol and LangGraph, which can automatically analyze microservice logs and monitoring data to help developers quickly diagnose production environment issues. This article introduces its architectural design, core components, and typical application scenarios.

2

Section 02

Problem Background: Pain Points in Production Troubleshooting

In microservice architectures, engineers often need to answer the following questions:

  • Why is this request responding so slowly in the production environment?
  • What is the current heap memory usage?
  • What is the detailed stack trace of this error when calling the API?

The traditional workflow involves: opening Grafana to check metric trends, switching to Splunk or Graylog to query relevant logs, jumping back and forth between multiple systems, and manually correlating trace IDs of different services. This process is time-consuming and prone to missing key information.

The core insight of Agentic Microservices is: if these scattered data sources can be uniformly exposed to LLM, allowing AI to automatically perform correlation analysis, the efficiency of troubleshooting will be greatly improved.

3

Section 03

Architectural Design: Two-Layer Architecture of MCP + LangGraph

The project adopts a two-layer architecture:

4

Section 04

Layer 1: MCP Observability Server

The MCP (Model Context Protocol) server implemented based on Spring AI is responsible for reading aggregated logs and monitoring data. It uniformly encapsulates access to underlying data sources, including:

  • Monitoring data such as JVM heap memory size, request rate, GC metrics
  • Aggregated logs of distributed services
  • Cross-service correlation ID tracking

The value of the MCP protocol lies in standardizing the interaction interface between AI and external tools. Any MCP-compatible client can call this server without caring about the specific implementation of the underlying data storage.

5

Section 05

Layer 2: LangGraph Intelligent Agent

The observability-debug-agent built based on LangGraph is responsible for coordinating the analysis process:

  1. Receive the user's natural language query ("Why is the order service responding slowly?")
  2. Plan the data collection strategy and call the MCP server to obtain relevant metrics and logs
  3. Send the collected data to LLM (OpenAI API) for analysis
  4. Return structured diagnostic results and recommendations

LangGraph's graph structure allows defining complex multi-step workflows, and the agent can decide the next action based on intermediate results to achieve true autonomous analysis.

6

Section 06

Technology Stack Selection

The project's technology selection reflects best practices in cloud-native and AI engineering:

  • Java 21: Leverage modern features such as virtual threads
  • Spring AI: Simplify AI application development and provide MCP support
  • LangGraph: Build complex agent workflows
  • OpenAI API: LLM reasoning capabilities
  • Docker Desktop + Kubernetes: Local development and deployment
  • Grafana + Prometheus: Monitoring and visualization
  • Loki: Log aggregation

This technology combination balances the maturity of the enterprise-level Java ecosystem and the advancement of AI engineering frameworks.

7

Section 07

Typical Application Scenarios

The project documentation presents three core use cases:

8

Section 08

Scenario 1: Slow Request Analysis

When a user asks why a certain API is responding slowly, the agent automatically:

  1. Query the P95/P99 latency trend of the API
  2. Collect error logs from the same time period
  3. Correlate the call chain of upstream and downstream services
  4. Identify possible bottlenecks (slow database queries, downstream service timeouts, etc.)