Skip to content

aws-actions/action-cloudwatch-metrics

Amazon CloudWatch Metrics Github Action

GitHub Action Status codecov Dependabot Status

This action publishes a single metric to Amazon CloudWatch.

You can use this action to report workflow metrics, such as completed builds, build failures, build times, or any other metric.

Using Amazon CloudWatch, you can then setup a unified dashboard to monitor all your packages, and be alerted when builds fail.

To access AWS from a GitHub Action workflow, consider using configure-aws-credentials. This action simplifies setting AWS credentials correctly.

Example Workflow

jobs:
  build:
    runs-on: ubuntu-latest
    name: 'Build'
    steps:
    - name: Checkout repo
      uses: actions/checkout@v2
    - name: Build
      run: ./my-build-script.sh

    # Make sure the secrets are stored in you repo settings
    - name: Configure AWS Credentials
      uses: aws-actions/configure-aws-credentials@v1
      with:
        aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        aws-region: us-west-2
      if: always()  # Setup credentials even if the workflow failed
    - name: Log Build
      # replace TAG by the latest tag in the repository
      uses: ros-tooling/action-cloudwatch-metrics@TAG
      if: always()  # Need to run to log the workflow failure

CloudWatch Metrics format

By default, the action will push a metrics named 'Builds', with a value of 1 if the build succeeds, or 0 otherwise. The metrics dimensions are: github.event_name, github.ref, github.repository, github.workflow.

See GitHub actions context documentation for details about those values.

Inputs

metric-dimensions

The dimensions of the metric.

Defaults to:

    [
      { "Name": "github.event_name", "Value": "${{ github.event_name }}" },
      { "Name": "github.ref", "Value": "${{ github.ref }}" },
      { "Name": "github.repository", "Value": "${{ github.repository }}" }
    ]

metric-name

The name of the metric. Defaults to Builds.

metric-value

The value for the metric. Defaults to ${{ job.status }} == 'success'.

true and false are respectfully transformed to 1.0, and 0.0, in order to enable boolean values to be passed as metrics.

namespace

The namespace for the metric data. Defaults to ActionCloudWatchMetrics.

To avoid conflicts with AWS service namespaces, you should not specify a namespace that begins with AWS/.

About

[Unmaintained] Github Action to publish metrics to AWS CloudWatch

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published