Quick Overview
This workflow runs on a recurring schedule to check an API’s rate-limit status via HTTP, calculates usage and severity, sends Slack and Gmail alerts when thresholds are breached, and logs each check to Google Sheets for tracking.
How it works
- Runs on a schedule trigger at a fixed interval.
- Calls the API rate-limit status endpoint via an HTTP request using a bearer token header.
- Parses the response to normalize rate-limit fields and calculates used quota, remaining quota, usage percentage, and reset time.
- Assigns a severity level (Normal, Warning, High, Critical) and flags whether usage is at or above the alert threshold.
- When the threshold is breached, posts either a critical or warning message to the configured Slack channel based on severity.
- Emails the on-call address via Gmail and appends the check results to a Google Sheets “Log” sheet.
Setup
- Update the HTTP request URL and replace the Authorization header value with your API’s rate-limit endpoint and bearer token (or configure an n8n HTTP Header Auth credential).
- Connect your Slack credentials and set the target channel ID(s) used for the alerts.
- Connect your Gmail credentials and set the on-call recipient email address.
- Connect your Google Sheets service account credentials and set the spreadsheet document ID and sheet name used for logging.
- Adjust the schedule interval and, if needed, tweak the severity and breach thresholds (currently alerts at 80% and marks critical at 95%).