Google's Agent-to-Agent (A2A) protocol is a powerful framework that enables AI agents to communicate and collaborate effectively. This project demonstrates how to implement A2A with comprehensive observability using Grafana, showcasing a health club service agent as an example.
A2AJava is the Java implementation of the Google A2A protocol you can check the project here .
The system can provides comprehensive visibility into agent interactions:
- Task Lifecycle: Track tasks from initiation to completion
- Real-time Status: Monitor active tasks and their current states
- Execution Metrics: Measure task duration, success rates, and failure patterns
- Task Dependencies: Visualize task chains and dependencies between agents
- Input Parameters: Monitor all parameters sent to agent tasks
- Parameter Validation: Track parameter validation success/failure rates
- Parameter Usage Patterns: Analyze common parameter combinations
- Type Safety: Monitor parameter type mismatches and conversion issues
- Request/Response Tracking: Complete visibility of all JSON-RPC messages
- Payload Analysis: Monitor request/response payload sizes and patterns
- Error Rates: Track RPC failures and error types
- Latency Metrics: Measure round-trip times for RPC calls
- Protocol Compliance: Ensure adherence to A2A protocol standards
The A2A protocol facilitates:
- Standardized Communication: Enables AI agents to expose their capabilities and interact using a common protocol
- Real-time Interaction: Supports streaming capabilities for live agent-to-agent communication
- Capability Discovery: Agents can dynamically discover and utilize each other's functions
- Scalable Architecture: Supports multiple agents working together in a distributed system
In a multi-agent system, observability is crucial for:
- Performance Monitoring: Track each agent's response times and throughput
- Behavior Analysis: Understand how agents interact and identify patterns
- Problem Detection: Quickly identify issues in agent communication
- Resource Optimization: Monitor resource usage and optimize agent deployment
This implementation showcases a Spring Boot-based health club service agent with real-time metrics streaming to Grafana dashboards, demonstrating how to build observable, intelligent services using the A2A protocol.
-
Health Club Service Management
- Gym appointment booking
- Squash court reservations
- Swimming session scheduling
- Fitness class registration
- Appointment cancellation and rescheduling
-
A2A Protocol Integration
- Real-time agent communication
- Streaming capabilities
- Agent card exposure via REST endpoints
-
Monitoring & Metrics
- Prometheus metrics integration
- Grafana dashboard visualization
- Real-time performance monitoring
- Method-level timing and tracking
- Java 23
- Spring Boot 3.2.4
- Micrometer (for metrics)
- Prometheus
- Grafana
- Google A2A Protocol
- WebSocket support
- Lombok
-
Clone the repository:
git clone https://github.com/vishalmysore/a2ajava-grafana.git
-
Navigate to the project directory:
cd a2ajava-grafana -
Build the project with Maven:
mvn clean install
-
Run the application:
mvn spring-boot:run
The application uses the following properties in application.properties:
spring.application.name=grafana-test
management.endpoints.web.exposure.include=prometheus
management.endpoint.prometheus.enabled=trueThe A2A agent is exposed through the AgentCardController at the well-known path. The service provides various health club-related actions that can be accessed through the A2A protocol.
-
Access the Agent Card
- The agent card is available at the well-known path configured in
AgentCardController - View the agent in the Google A2A client:
- The agent card is available at the well-known path configured in
-
Trigger Health Club Actions
- Book appointments using the A2A protocol
- View confirmations in the interface:
-
Monitor Activity
- Access Prometheus metrics at
/actuator/prometheus:
- View metrics in Grafana dashboards
- Track real-time performance data
- Access Prometheus metrics at
- RPC call counts
- Method duration timings
- Service performance metrics
- System health indicators
-
Access your Grafana dashboard
-
Import the provided dashboards:
-
Monitor your health club service metrics in real-time
Contributions are welcome! Please feel free to submit a Pull Request.