DEV Community

Cover image for Service Uptime Monitor using Github Actions
Fahmi Noor Fiqri
Fahmi Noor Fiqri Subscriber

Posted on

2 2

Service Uptime Monitor using Github Actions

My Workflow

I've been working in a company for about 1 year now. We have a private cloud, but it's not very reliable. Sometimes our container will suddenly stopped or having our Gitlab EE unavailable, even in busy hour.

After today's daily stand up, one of my coworker said it will be fun to have a service to monitor our services, to tell when was the last time the DevOps team messed up the containers. Like in the "days without tricks meme."

So I think "why not?"

Here I have created a workflow to check for my service uptime, runs every 5 minutes on Github Actions. This action will execute a NodeJS app and updates a file to report latest up/downtime. This script will make a HTTP request to the service and save the HTTP status to a JSON file.

Submission Category:

Wacky Wildcards

Yaml File or Link to Code

name: Node.js CI

on:
  workflow_dispatch:
  schedule:
    - cron: "*/5 * * * *"

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js
      uses: actions/setup-node@v1
      with:
        node-version: 12.x
    - run: npm install
    - run: npm start
    - name: Commit and push if changed
      run: |
        git add .
        git diff
        git config --global user.email "github-action-bot@example.com"
        git config --global user.name "GitHub Action Bot"
        git commit -m "Updated incident" -a || echo "No changes to commit"
        git push
Enter fullscreen mode Exit fullscreen mode

GitHub logo fahminlb33 / statuspage-js

Monitor my squad container status

Additional Resources / Info

For the HTML I've used Matt Smith's countdown template from https://codepen.io/AllThingsSmitty/pen/JJavZN.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay