Monitoring, Security & Maintenance

This final article covers monitoring, security best practices, and maintenance strategies for Cloud AI agents.

Monitoring

Cloud Monitoring Setup

Track key metrics:

Logging

Local Development:

docker-compose logs -f support-agent-adk
docker-compose logs -f mcp-crm
docker-compose logs -f mcp-product-catalogue

Cloud:

# View logs
gcloud logging read "resource.type=cloud_run_revision" --limit 50

# Filter by service
gcloud logging read "resource.labels.service_name=agent-order-receiver"

Health Checks

All services expose /health endpoints:

curl https://agent-order-receiver-xxx.run.app/health

Debug Mode

Set DEBUG_HTTP=true to enable:

Security Best Practices

1. Secrets Management

2. Authentication

3. Network Security

4. Error Handling

Troubleshooting

Common Issues

1. Token Expired

2. MCP Call Fails

3. Permission Denied

4. CORS Errors

Maintenance

Regular Tasks

  1. Monitor Error Rates: Set up alerts for high error rates
  2. Review Logs: Check for authentication failures or unusual patterns
  3. Update Dependencies: Keep packages up to date
  4. Rotate Secrets: Regularly rotate service account keys
  5. Backup Data: Regular Firestore backups

Cost Optimization

Best Practices Summary

  1. Architecture: Microservices with clear separation of concerns
  2. Security: Token exchange pattern, proper authentication
  3. Protocol: Standardized MCP JSON-RPC 2.0 communication
  4. Deployment: Cloud-native with auto-scaling
  5. Monitoring: Comprehensive logging and metrics
  6. Maintenance: Regular updates and security checks

Conclusion

This series covered building, deploying, and maintaining production-ready AI agents in the cloud. Key takeaways:

For more details, refer to the implementation documentation and code examples throughout this series.