Analyze GCP Error Logs
Automatically fetch recent Google Cloud Platform error logs, group them by root cause using AI, and send a detailed HTML report to your team daily.
Onur EkenLast updated
March 11, 2026
Connectors used
Tags
Introduction
This workflow automatically analyzes Google Cloud Platform (GCP) log entries for errors over the past day and generates a detailed HTML report. It leverages the GCP logging API, authenticates with a service account, and uses an AI model to cluster error logs by root cause and provide actionable insights.
It performs the following tasks:
- Runs on a daily schedule at 9:20 AM Berlin time.
- Creates a JSON Web Token (JWT) to authenticate with the Google OAuth 2.0 system.
- Requests an access token using the generated JWT.
- Queries the GCP Logging API for error log entries from the past 24 hours filtered by severity.
- Sends the log entries to an AI model that analyzes and clusters errors by root cause, summarizes the data, identifies affected services, and offers recommendations.
- Processes the structured response from the AI and generates an HTML report with detailed tables and links to logs.
- Outputs a structured, easy-to-read report for developers and operations teams to identify and respond to issues.
What you need
- A GCP project with logging enabled.
- A service account JSON key with permissions to read logs and generate OAuth tokens.
- The private key and client email of the service account available as input.
- Access to the Needle platform with the ability to create scheduled workflows.
- An active Needle AI integration for the log analysis step.
How the flow works
Here is a breakdown of the nodes used in this workflow:
| Step | Component | Description |
|---|---|---|
| 1 | Scheduled trigger | Starts the workflow every day at 9:20 AM Europe/Berlin time. |
| 2 | JWT creation code | Parses your GCP service account key and builds a signed JWT for OAuth authentication. |
| 3 | OAuth token request | Sends the JWT to the Google OAuth token endpoint to get an access token. |
| 4 | Logs query request | Uses the access token to call the GCP Logging API and fetch error logs from the last 24 hours. |
| 5 | AI log analysis | Passes the raw error entries to an AI model to group logs, summarize patterns, and provide recommendations. |
| 6 | Report generation code | Takes the structured output along with raw stats to build an HTML report with error clusters and log links. |
| 7 | Sends the final HTML report directly via Gmail. |
AI Analysis Capabilities
The AI model is specially prompted to extract the following insights:
- Group logs by root cause.
- Summarize main error patterns.
- List affected services.
- Analyze error timing.
- Provide prioritized recommendations.
Output
At the end, you get a comprehensive HTML report detailing:
- Report date and total error count.
- Executive summary of main error patterns and affected services.
- A table of error clusters with descriptions, sample errors, affected services, and log links.
- Service-level error counts and top clusters.
- Timeline analysis describing error spikes.
- Prioritized recommendations for addressing the identified issues.
This report helps development and operations teams quickly understand error trends and root causes in their GCP environment.
Notes
- The service account provided must have sufficient permissions to read logs.
- The AI analysis depends on accurate and comprehensive logs; ensure your GCP logging configuration captures relevant error information.
- Be mindful of API quotas on GCP and Needle when running this workflow daily.
- Customize the AI prompt or report formatting to fit your team specific needs.
Want to showcase your own workflows?
Become a Needle workflow partner and turn your expertise into recurring revenue.