Send metrics of GitHub Actions to Datadog
on:
workflow_run:
workflows:
- '**'
types:
- completed
jobs:
actions-metrics:
runs-on: ubuntu-latest
steps:
- uses: yuya-takeyama/[email protected]
with:
github-token: ${{ secrets.OWNER_GITHUB_TOKEN }}
datadog-api-key: ${{ secrets.DATADOG_API_KEY }}
enable-workflow-metrics: 'true'
enable-billing-metrics: 'true'
enable-repository-workflows-billing-metrics: 'true'
You can collect billing metrics using schedule
event too:
on:
schedule:
- cron: '*/15 * * * *'
jobs:
actions-billing-metrics:
runs-on: ubuntu-latest
steps:
- uses: yuya-takeyama/[email protected]
with:
github-token: ${{ secrets.OWNER_GITHUB_TOKEN }}
datadog-api-key: ${{ secrets.DATADOG_API_KEY }}
enable-billing-metrics: 'true'
enable-repository-workflows-billing-metrics: 'true'
Name | Required | Default | Description |
---|---|---|---|
github-token |
false |
GitHub API token | |
datadog-api-key |
true |
Datadog API key | |
enable-workflow-metrics |
true |
Set "true" to send workflow metrics | |
enable-billing-metrics |
true |
Set "true" to send User/Organization billing metrics | |
enable-repository-workflows-billing-metrics |
true |
Set "true" to send Repository Workflows billing metrics |
It's required when enable-billing-metrics
or enable-repository-workflows-billing-metrics
is true.
secrets.GITHUB_TOKEN
doesn't work for it.
user
Details: https://docs.github.com/en/rest/reference/billing#get-github-actions-billing-for-a-user
repo
admin:org
Also, the token must be created by a user who has ownership for the organization.
Details:
- https://docs.github.com/en/rest/reference/billing#get-github-actions-billing-for-an-organization
- https://docs.github.com/en/rest/reference/actions#get-workflow-usage
github.actions.workflow_duration
github.actions.billing.total_minutes_used
github.actions.billing.total_paid_minutes_used
github.actions.billing.included_minutes
github.actions.billing.minutes_used_breakdown
github.actions.billing.repository_workflow_total_ms