Skip to content

quipper/github-actions-metrics-to-datadog-action

 
 

Repository files navigation

github-actions-metrics-to-datadog-action status

GitHub Actions metrics to Datadog

Send metrics of GitHub Actions to Datadog

Usage

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'

Collect billing metrics periodically

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'

Inputs

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

Required scopes for github-token

It's required when enable-billing-metrics or enable-repository-workflows-billing-metrics is true.

secrets.GITHUB_TOKEN doesn't work for it.

A repo belongs to a user

  • user

Details: https://docs.github.com/en/rest/reference/billing#get-github-actions-billing-for-a-user

A repo belongs to an organization

  • repo
  • admin:org

Also, the token must be created by a user who has ownership for the organization.

Details:

Metrics

Workflow metrics

  • github.actions.workflow_duration

Billing metrics

  • github.actions.billing.total_minutes_used
  • github.actions.billing.total_paid_minutes_used
  • github.actions.billing.included_minutes
  • github.actions.billing.minutes_used_breakdown

Repository workflows billing metrics

  • github.actions.billing.repository_workflow_total_ms

About

Send metrics of GitHub Actions to Datadog

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 98.3%
  • JavaScript 1.7%