Automatically monitor Github Actions Workflows using Cronitor.io and a simple Github Action.
-
Add a
CRONITOR_API_KEY
secret in your repo, copying your Cronitor API key from https://cronitor.io/app/settings/api
name: Cronitor Monitoring Relay
on:
workflow_run:
workflows: ['*']
types: [requested,completed]
jobs:
send-telemetry:
runs-on: ubuntu-latest
name: Send Telemetry
steps:
- name: Send execution details to the Cronitor for Github Actions agent
uses: cronitorio/monitor-github-actions@v7
with:
event: ${{ toJSON(github.event) }}
github_token: ${{ secrets.GITHUB_TOKEN }}
cronitor_key: ${{ secrets.CRONITOR_API_KEY }}
cronitor_group: actions
cronitor_notify: devops-alerts
Parameter name | Required | Description |
---|---|---|
event |
Yes | Triggering event (passed from github.event ) |
cronitor_key |
Yes | Your Cronitor API key |
github_token |
No | To relay workflow logs, pass your GITHUB_TOKEN |
cronitor_group |
No | Add monitors to a Cronitor group |
cronitor_notify |
No | A notification list to use for alerts |
Note: Log relay is coming soon.
By default, when you add the YAML for the Cronitor Monitoring Relay as an Action, it will be invoked automatically for every
workflow that runs in this repo. If you want to limit which workflows are monitored by Cronitor, you can specify those
directly in the on
clause of your Cronitor workflow yaml:
on:
workflow_run:
workflows: [job1,job2]
types: [requested,completed]
Alert recipients can be managed directly from this configuration file using the optional cronitor_notify
input.
Provide a notification list using its key, or specify a single recipient, e.g.
email:[email protected]
.
After adding the Cronitor Relay yaml, your workflows will appear on your Cronitor dashboard the first time they run. From the dashboard, you will be able to customize alert preferences, including:
- Be alerted only if a workflow persistently fails
- Be alerted if a workflow does not run or complete at least once in a given time span.
- Be alerted on workflow execution time and avoid surprise charges from Github.