tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Generative AI > Google Gemini API > Log Anomaly Detection Agent

Log Anomaly Detection Agent

Author: Venkata Sudhakar

Application logs are the first line of defence for detecting production issues and security threats. ShopMax India's platform generates millions of log entries daily. An intelligent agent that summarises logs and surfaces anomalies - sudden error spikes, unusual login patterns, or API abuse - enables the ops team to act before customers are impacted.

This tutorial builds a Gemini ADK agent that analyses an hourly log summary, compares error rates and request volumes against baseline thresholds, and raises anomaly alerts with recommended investigation steps.

The below example shows a log anomaly detection agent for ShopMax India in a business context.


It gives the following output,

Log Anomaly Report - ShopMax India | 09:00 AM

Status: ACTION REQUIRED | 3 Anomalies Detected

[CRITICAL] BRUTE_FORCE_RISK
  312 failed logins vs baseline 20/hr (15.6x spike)
  Action: Enable rate limiting on login endpoint. Review IP blocklist.

[HIGH] ERROR_SPIKE
  Error rate 4.2% vs baseline 0.5% (8.4x normal)
  Top errors: DB connection timeout (892), Payment API 503 (128)
  Action: Check DB connection pool and Payment API health immediately.

[HIGH] LATENCY_SPIKE
  p99 latency 2100ms vs baseline 800ms (2.6x normal)
  Action: Investigate slow queries or DB resource contention.

The DB connection timeout errors and latency spike are likely related.
Resolve DB health first - this may fix both HIGH anomalies simultaneously.

ShopMax India can run this agent on an automated schedule every 15 minutes, feeding it aggregated log metrics from CloudWatch, Datadog, or Elastic. When CRITICAL anomalies are detected, the agent triggers a PagerDuty alert and posts a summary to the #incidents Slack channel, ensuring the on-call engineer has context before they even open their laptop.


 
  


  
bl  br