Concourse resource for placing an AWS CloudWatch metric.
Example use:
record the rate that scheduled jobs fail, so that alerts can be raised
The resource is a wrapper around the AWS CLI for CloudWatch put-metric-data.
namespace
: Required
Namespace under which to put the metric. Should not start withAWS/
.metric
: Required
The name of the metric to put.aws_access_key_id
: Optional
The AWS access key to use when putting the metric.aws_secret_access_key
: Optional
The AWS secret key to use when putting the metric.aws_region
: Optional
The AWS region for the credentials.
AWS credentials and region configuration above are optional, and override a Concourse instance using AWS credentials from IAM instance profiles.
The AWS credentials used should have the Cloudwatch_PutMetricData
policy attached.
Put a single metric to CloudWatch, on the given namespace, metric name and dimensions.
All params
are optional.
dimensions
: Optional
up to seven key-value pairs to set as dimensions. The dimensions of resource metadataBUILD_JOB_NAME
,BUILD_PIPELINE_NAME
andBUILD_TEAM_NAME
are always set as dimensions.value
: Optional
double to place as a metric, typically1
or0
. Default1
.unit
: Optional
unit to assign to the value. DefaultNone
.
resource_types:
- name: cloudwatch-metrics
type: docker-image
source:
repository: ghcr.io/idrop/cloudwatch-metrics/cloudwatch-metrics
tag: 0.2
resources:
- name: smoketest-fails
type: cloudwatch-metrics
source:
aws_region: eu-west-2
aws_access_key_id: ((aws_access_key_id))
aws_secret_access_key: ((aws_secret_access_key))
namespace: SmokeTest
metric: Failure
jobs:
- name: smoketest-prod
plan:
........
on_failure:
put: smoketest-fails
If the smoketest-prod
job fails, the CloudWatch metric Failure
would be put on namespace SmokeTest
with value 1
and a timestamp of now.
The dimensions set on the metric, given a concourse team named main
, pipeline named test-pipeline
and job of smoketest-prod
, would be:
- build_team_name:
main
- build_pipeline_name:
test-pipeline
- build_job_name:
smoketest-prod
Create an AWS access key and secret, and attach a Cloudwatch_PutMetricData
policy.
Start up the Concourse services locally using the quick-start.
Then set the test pipeline with:
fly set-pipeline -t main -p test -c test/test-pipeline.yaml -v aws_access_key_id=<your aws access key> -v aws_secret_access_key=<your access key secret>
Now run the some-test
job, which should fail and send a metric to AWS CloudWatch.