This is an action to send metrics of GitHub Actions to Datadog on an event. It is inspired from yuya-takeyama/github-actions-metrics-to-datadog-action.
To collect the metrics when a workflow run is completed:
on:
workflow_run:
workflows:
- '**'
types:
- completed
jobs:
send:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: int128/datadog-actions-metrics@v1
with:
# create an API key in https://docs.datadoghq.com/account_management/api-app-keys/
datadog-api-key: ${{ secrets.DATADOG_API_KEY }}
For the developer experience, you can analyze the following metrics:
For the reliability, you can monitor the following metrics:
GITHUB_TOKEN
Here is an example of screenshot in Datadog.
For the self-hosted runners, you can monitor the following metrics for reliability and experience:
Here is an example of screenshot in Datadog.
You can analyze your development activity such as number of merged pull requests. It helps the continuous process improvement of your team.
To collect the metrics when a pull request is opened, closed or merged into main:
on:
pull_request:
types:
- opened
- closed
push:
branches:
- main
jobs:
send:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: int128/datadog-actions-metrics@v1
with:
# create an API key in https://docs.datadoghq.com/account_management/api-app-keys/
datadog-api-key: ${{ secrets.DATADOG_API_KEY }}
This action can handle the following events:
Other events are ignored.
This action sends the following metrics.
github.actions.workflow_run.total
github.actions.workflow_run.conclusion.{CONCLUSION}_total
CONCLUSION
fieldgithub.actions.workflow_run.conclusion.success_total
github.actions.workflow_run.conclusion.failure_total
github.actions.workflow_run.duration_second
github.actions.workflow_run.duration_second.distribution
It has the following tags:
repository_owner
repository_name
workflow_name
workflow_id
run_attempt
event
sender
sender_type
= either Bot
, User
or Organization
branch
default_branch
= true
or false
pull_request_number
conclusion
See also the actual metrics in the E2E test.
This action sends the following metrics if collect-job-metrics
is enabled.
github.actions.job.total
github.actions.job.conclusion.{CONCLUSION}_total
github.actions.job.conclusion.success_total
github.actions.job.conclusion.failure_total
github.actions.job.queued_duration_second
github.actions.job.queued_duration_second.distribution
github.actions.job.duration_second
github.actions.job.duration_second.distribution
github.actions.job.start_time_from_workflow_start_second
github.actions.job.start_time_from_workflow_start_second.distribution
github.actions.job.lost_communication_with_server_error_total
github.actions.job.received_shutdown_signal_error_total
It has the following tags:
repository_owner
repository_name
workflow_name
workflow_id
event
sender
sender_type
= either Bot
, User
or Organization
branch
default_branch
= true
or false
pull_request_number
job_name
job_id
conclusion
status
runs_on
ubuntu-latest
This action sends the following metrics if collect-step-metrics
is enabled.
github.actions.step.total
github.actions.step.conclusion.{CONCLUSION}_total
github.actions.step.conclusion.success_total
github.actions.step.conclusion.failure_total
github.actions.step.duration_second
github.actions.step.duration_second.distribution
github.actions.step.start_time_from_workflow_start_second
github.actions.step.start_time_from_workflow_start_second.distribution
It has the following tags:
repository_owner
repository_name
workflow_name
workflow_id
event
sender
sender_type
= either Bot
, User
or Organization
branch
default_branch
= true
or false
pull_request_number
job_name
job_id
step_name
step_number
= 1, 2, ...conclusion
status
runs_on
ubuntu-latest
To send the metrics of jobs and steps:
steps:
- uses: int128/datadog-actions-metrics@v1
with:
datadog-api-key: ${{ secrets.DATADOG_API_KEY }}
collect-job-metrics: true
collect-step-metrics: true
To send the metrics of jobs and steps on the default branch only:
steps:
- uses: int128/datadog-actions-metrics@v1
with:
datadog-api-key: ${{ secrets.DATADOG_API_KEY }}
collect-job-metrics: ${{ github.event.workflow_run.head_branch == github.event.repository.default_branch }}
collect-step-metrics: ${{ github.event.workflow_run.head_branch == github.event.repository.default_branch }}
This action calls GitHub REST API and GraphQL API to get jobs and steps of the current workflow run. Note that it may cause the rate exceeding error when too many workflows are run.
If the job or step metrics is enabled, this action requires the following permissions:
permissions:
actions: read
checks: read
contents: read
This action sends the gauge metrics by default. To send the distribution metrics instead of the gauge metrics,
steps:
- uses: int128/datadog-actions-metrics@v1
with:
datadog-api-key: ${{ secrets.DATADOG_API_KEY }}
prefer-distribution-workflow-run-metrics: true
collect-job-metrics: true
collect-step-metrics: true
prefer-distribution-job-metrics: true
prefer-distribution-step-metrics: true
Note that the distribution metrics may increase the custom metrics cost.
This action sends the following metrics on opened
type.
github.actions.pull_request_opened.total
github.actions.pull_request_opened.commits
github.actions.pull_request_opened.changed_files
github.actions.pull_request_opened.additions
github.actions.pull_request_opened.deletions
It has the following tags:
repository_owner
repository_name
sender
sender_type
= either Bot
, User
or Organization
user
pull_request_number
draft
= true
or false
base_ref
head_ref
This action sends the following metrics on closed
type.
github.actions.pull_request_closed.total
github.actions.pull_request_closed.since_opened_seconds
github.actions.pull_request_closed.since_first_authored_seconds
github.actions.pull_request_closed.since_first_committed_seconds
github.actions.pull_request_closed.commits
github.actions.pull_request_closed.changed_files
github.actions.pull_request_closed.additions
github.actions.pull_request_closed.deletions
It has the following tags:
repository_owner
repository_name
sender
sender_type
= either Bot
, User
or Organization
user
pull_request_number
draft
= true
or false
base_ref
head_ref
merged
= true
or false
requested_team
label
send-pull-request-labels
is setFor pull_request event, this action requires the following permissions:
permissions:
pull-requests: read
This action sends the following metrics.
github.actions.push.total
It has the following tags:
repository_owner
repository_name
sender
sender_type
= either Bot
, User
or Organization
ref
created
= true
or false
deleted
= true
or false
forced
= true
or false
default_branch
= true
or false
This action sends the following metrics:
github.actions.schedule.queued_workflow_run.total
It has the following tags:
repository_owner
repository_name
It is useful for monitoring self-hosted runners.
For schedule event, this action requires the following permissions:
permissions:
actions: read
This action always sends the following metrics of the built-in GITHUB_TOKEN
rate limit.
github.actions.api_rate_limit.remaining
github.actions.api_rate_limit.limit
It has the following tags:
repository_owner
repository_name
resource
= core
, search
and graphql
This does not affect the rate limit of GitHub API because it just calls /rate_limit
endpoint.
You can set the following inputs:
Name | Default | Description |
---|---|---|
github-token |
github.token |
GitHub token to get jobs and steps if needed |
github-token-rate-limit-metrics |
github.token |
GitHub token for rate limit metrics |
datadog-api-key |
- | Datadog API key. If not set, this action does not send metrics actually |
datadog-site |
- | Datadog Server name such as datadoghq.eu , ddog-gov.com , us3.datadoghq.com
|
datadog-tags |
- | Additional tags in the form of key:value in a multiline string |
metrics-patterns |
- | Filter the metrics by patterns in a multiline string |
send-pull-request-labels |
false |
Send pull request labels as Datadog tags |
collect-job-metrics |
false |
Collect job metrics |
collect-step-metrics |
false |
Collect step metrics |
prefer-distribution-workflow-run-metrics |
false |
If true, send the distribution metrics instead of gauge metrics |
prefer-distribution-job-metrics |
false |
If true, send the distribution metrics instead of gauge metrics |
prefer-distribution-step-metrics |
false |
If true, send the distribution metrics instead of gauge metrics |
If metrics-patterns
is set, this action sends the metrics filtered by the glob patterns.
The glob specification is same as the filters of workflow.
To include the specific metrics,
steps:
- uses: int128/datadog-actions-metrics@v1
with:
metrics-patterns: |
github.actions.workflow_run.*
github.actions.job.*
To exclude the specific metrics,
steps:
- uses: int128/datadog-actions-metrics@v1
with:
metrics-patterns: |
*
!github.actions.*.conclusion.*
If both include and exclude patterns are given, the later pattern has higher precedence.
To connect to Datadog API via a HTTPS proxy, set https_proxy
environment variable.
For example,
steps:
- uses: int128/datadog-actions-metrics@v1
with:
datadog-api-key: ${{ secrets.DATADOG_API_KEY }}
env:
https_proxy: http://proxy.example.com:8080
This is an open source software. Feel free to open issues and pull requests.