## Introduction
In fast-paced operational environments, keeping tabs on system uptime is crucial for ensuring reliability and maintaining trust with stakeholders. For operations teams at startups and growing businesses, automating system uptime monitoring and reporting can save manual effort, surface issues early, and provide consistent insights during weekly ops reviews.
This guide provides a step-by-step tutorial on building an automated workflow using n8n to track system uptime and compile weekly reports. We will integrate monitoring, data aggregation, and notification services like HTTP request nodes, Google Sheets, and Slack. The automation ensures your team receives a concise, actionable summary every week, aiding in decision making and incident response.
—
## Use Case and Problem Statement
Operations teams need to monitor multiple critical systems and services to ensure high availability. Manual tracking of uptime metrics across these systems is error-prone and time-consuming. By automating the collection, aggregation, and reporting of uptime data, teams can:
– Detect issues proactively
– Share consistent uptime metrics during weekly operations meetings
– Reduce manual reporting overhead
The solution benefits operations teams, SREs, and CTOs seeking to improve visibility and system reliability.
—
## Tools and Integrations
– **n8n:** Workflow automation platform to orchestrate fetching, storage, and reporting.
– **HTTP Request Node:** Ping or query system health endpoints/APIs to check service status.
– **Google Sheets:** Store uptime records for persistence and historical analysis.
– **Slack:** Post weekly summary reports for easy consumption by the team.
These tools combine to create a robust uptime tracking and reporting workflow.
—
## Overview of the Workflow
1. **Trigger:** Scheduled trigger node, set to run daily or at specific intervals.
2. **Health Check:** HTTP Request node pings each service endpoint or health API to check uptime.
3. **Data Processing:** Determine uptime status (up/down), log timestamp and status.
4. **Data Storage:** Append results to a Google Sheets spreadsheet capturing daily uptimes.
5. **Weekly Aggregation:** On a weekly trigger, fetch past week’s data from Google Sheets.
6. **Compile Report:** Summarize uptime percentages and flag downtime events.
7. **Notify Team:** Send formatted uptime report to a Slack channel.
—
## Step-by-Step Tutorial
### Step 1: Set Up n8n Environment
– Make sure you have n8n installed and running (self-hosted or cloud).
– Authenticate Google Sheets and Slack integrations in n8n.
### Step 2: Create Google Sheet for Uptime Records
– Create a new Google Sheet with columns:
  – Date (YYYY-MM-DD)
  – Service Name
  – Status (Up/Down)
  – Timestamp
– Share with the Google user connected to n8n.
### Step 3: Configure the Daily Trigger
– Add an **Interval Trigger** in n8n.
– Set it to daily at a fixed time (e.g., 9:00 AM).
### Step 4: Configure Health Check HTTP Request Node
– Add an **HTTP Request** node connected to the trigger.
– For each service to monitor, configure a GET request to its health endpoint:
  – Example: `https://api.example.com/health`
  – If monitoring multiple services, use a **SplitInBatches** node or multiple HTTP Request nodes.
– Define success criteria, e.g., response code 200 or specific JSON key indicating ‘healthy’.
### Step 5: Process the Response
– Add a **Function** node to evaluate HTTP responses.
– Determine if service is UP or DOWN:
  “`javascript
  items.forEach(item => {
    item.json.status = (item.json.httpCode === 200) ? ‘Up’ : ‘Down’;
    item.json.timestamp = new Date().toISOString();
  });
  return items;
  “`
– Customize based on your API’s response format.
### Step 6: Append Results to Google Sheets
– Connect a **Google Sheets** node.
– Set operation to “Append”.
– Map the data fields: Date, Service Name, Status, Timestamp.
### Step 7: Create Weekly Trigger and Data Aggregation
– Add another **Interval Trigger** node configured to trigger weekly (e.g., every Monday at 8:00 AM).
– Connect a **Google Sheets** node to “Read Rows” from the uptime record sheet.
– Filter rows for the last 7 days using a **Function** node.
### Step 8: Summarize Uptime Data
– Use a **Function** node to calculate uptime percentages per service:
  – Count of ‘Up’ statuses / total checks.
  – Identify any downtime events.
– Format the results into a message.
Example function snippet:
“`javascript
const services = {};
items.forEach(item => {
  const { ServiceName, Status } = item.json;
  if (!services[ServiceName]) {
    services[ServiceName] = { up: 0, total: 0 };
  }
  if (Status === ‘Up’) services[ServiceName].up++;
  services[ServiceName].total++;
});
let report = ‘Weekly System Uptime Report:\n’;
for (const [service, data] of Object.entries(services)) {
  const uptimePercent = ((data.up / data.total) * 100).toFixed(2);
  report += `- ${service}: ${uptimePercent}% uptime\n`;
}
return [{ json: { text: report } }];
“`
### Step 9: Send Report to Slack
– Add a **Slack** node to post a message to your operations channel.
– Configure the node with your Slack workspace credentials.
– Pass the formatted message from the previous step.
### Step 10: Test and Deploy
– Run the daily and weekly workflows manually to test data flow.
– Verify data appends correctly in Google Sheets.
– Verify Slack reports are posted with expected formatting.
—
## Common Pitfalls and Tips
– **API Rate Limits:** If you monitor many services or call APIs frequently, beware of hitting rate limits.
– **Timeouts:** Configure reasonable timeouts on HTTP Request nodes to prevent stuck workflows.
– **Error Handling:** Add error workflow branches or retry mechanisms for failed HTTP requests.
– **Data Consistency:** Ensure the Google Sheet is not edited manually during operations to avoid conflicts.
– **Timezone Awareness:** Normalize timestamps and schedule triggers based on your team’s timezone.
—
## Scaling and Adaptation
– **Add More Services:** Easily scale by adding more HTTP Request nodes or dynamically pulling service URLs from a config sheet.
– **Detailed Metrics:** Extend to capture response times or error codes.
– **Multiple Channels:** Post reports to email or other collaboration tools.
– **Alerting:** Add immediate Slack alerts for downtime alongside weekly summaries.
—
## Summary
By following this guide, operations teams can automate the tedious task of system uptime tracking and weekly reporting using n8n. The workflow provides a single source of truth for weekly uptime metrics, helping teams maintain high operational standards and swiftly react to reliability issues. This approach saves time, reduces manual errors, and scales as your infrastructure grows.
—
## Bonus Tip
To improve metrics accuracy, consider integrating with dedicated monitoring APIs (like Pingdom or UptimeRobot) instead of direct service pings. They provide richer data like downtime reasons and historical uptime, which can be pulled into the n8n workflow to augment your reports.