Skip to content

Instantly share code, notes, and snippets.

@ajbeach2
Created May 14, 2019 12:17
Show Gist options
  • Save ajbeach2/988e342e2e9bbaee47f48500a44ad614 to your computer and use it in GitHub Desktop.
Save ajbeach2/988e342e2e9bbaee47f48500a44ad614 to your computer and use it in GitHub Desktop.
Cloudwatch Metric Example Golang
params := &cloudwatch.PutMetricDataInput{
MetricData: []*cloudwatch.MetricDatum{
{
MetricName: aws.String(name),
Dimensions: []*cloudwatch.Dimension{
{
Name: aws.String("HandlerMetrics"),
Value: aws.String(w.Name),
},
},
Timestamp: aws.Time(time.Now()),
Unit: aws.String(unit),
Value: aws.Float64(metric),
},
{
MetricName: aws.String("HandlerInvocations"),
Dimensions: []*cloudwatch.Dimension{
{
Name: aws.String("HandlerMetrics"),
Value: aws.String(w.Name),
},
},
Timestamp: aws.Time(time.Now()),
Unit: aws.String("Count"),
Value: aws.Float64(1),
},
},
Namespace: aws.String("SqsWorker"),
}
_, err := w.metrics.PutMetricData(params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment