github.com/google/cloudprober@v0.11.3/docs/content/surfacers/cloudwatch.md (about) 1 --- 2 menu: 3 main: 4 parent: "Exporting Metrics (Surfacers)" 5 weight: 30 6 title: "Cloudwatch (AWS Cloud Monitoring)" 7 date: 2021-04-04T19:37:00+01:00 8 --- 9 Cloudprober can natively export metrics to AWS Cloudwatch using the cloudwatch [surfacer](/surfacers/overview). Adding the cloudwatch surfacer to cloudprover is as simple as adding the following stanza to the config: 10 11 ``` 12 surfacer { 13 type: CLOUDWATCH 14 } 15 ``` 16 17 ## Authentication 18 19 The cloudwatch surfacer uses the AWS Go SDK, and supports the [default credential chain](https://docs.aws.amazon.com/sdk-for-go/v2/developer-guide/configuring-sdk.html): 20 21 1. Environment variables. 22 2. Shared credentials file. 23 3. If your application uses an ECS task definition or RunTask API operation, IAM role for tasks. 24 4. If your application is running on an Amazon EC2 instance, IAM role for Amazon EC2. 25 26 ## Authorization 27 28 In order to permit cloudprober to publish metric data to cloudwatch, ensure the profile being used for authentication has the following permissions, where the "cloudwatch:namespace" is the [metric namespace](#metric-namespace) used by cloudprober. 29 30 If the default metric namespace is changed, also change the condition in the IAM policy below to match the same value. 31 32 ``` 33 { 34 "Version": "2012-10-17", 35 "Statement": [ 36 { 37 "Condition": { 38 "StringEqualsIgnoreCase": { 39 "cloudwatch:namespace": "cloudprober" 40 } 41 }, 42 "Action": [ 43 "cloudwatch:PutMetricData" 44 ], 45 "Resource": [ 46 "*" 47 ], 48 "Effect": "Allow", 49 "Sid": "PutMetrics" 50 } 51 ] 52 } 53 ``` 54 55 ## [Metric Namespace](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Namespace) 56 57 The metric namespace used to publish metrics to by default is set to `cloudprober`. This can be changed by expanding the surfacer configuration: 58 59 ``` 60 surfacer { 61 type: CLOUDWATCH 62 63 cloudwatch_surfacer { 64 namespace: "/cloudprober/website/probes" 65 } 66 } 67 ``` 68 69 Note: If the namespace is modified, also modify the [IAM policy condition](#authorization) for the namespace PutMetricData call. 70 71 ## Configuration Options 72 73 The full list of configuration options for the cloudwatch surfacer is: 74 75 ```protobuf 76 // The cloudwatch metric namespace 77 optional string namespace = 1 [default = "cloudprober"]; 78 79 // The cloudwatch resolution value, lowering this below 60 will incur 80 // additional charges as the metrics will be charged at a high resolution rate. 81 optional int64 resolution = 2 [default=60]; 82 ``` 83 84 (Source: https://github.com/google/cloudprober/blob/master/surfacers/cloudwatch/proto/config.proto) 85 86 ## Calculating the metric delta with Cloudwatch Metric Maths 87 88 The metrics produced by cloudprober are cumulative. Most services producing metrics into cloudwatch produce snapshot data whereby the metrics are recorded for a specific point in time. 89 90 In order to achieve a similar effect here, the [Cloudwatch Metric Maths](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/using-metric-math.html) RATE and PERIOD functions can be used to determine the delta values. 91 92 ``` 93 RATE(m1) * PERIOD(m1) 94 ``` 95 96 Whereby m1 is the metric id for the cloudprober metrics, for example: 97 98 ``` 99 namespace: cloudprober 100 metric name: latency 101 dst: google.com 102 ptype: http 103 probe: probe name 104 ```