From 98bc63e6ef7f230edc94753b21f0cb1de18102d8 Mon Sep 17 00:00:00 2001 From: inokappa Date: Mon, 22 Dec 2014 23:19:46 +0000 Subject: [PATCH 1/3] Specifies the AWS Region in the environment variable. --- lib/tasseo/public/j/tasseo.js | 4 ++-- lib/tasseo/views/index.haml | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/tasseo/public/j/tasseo.js b/lib/tasseo/public/j/tasseo.js index 1e35762..3b281bd 100644 --- a/lib/tasseo/public/j/tasseo.js +++ b/lib/tasseo/public/j/tasseo.js @@ -357,10 +357,10 @@ TasseoLibratoDatasource.prototype = { /* AWSCloudWatch datasource */ -function TasseoAWSCloudWatchDatasource(accessKeyId, secretAccessKey, options) { +function TasseoAWSCloudWatchDatasource(accessKeyId, secretAccessKey, region, options) { this.options = _.extend({}, options); AWS.config.update({accessKeyId: accessKeyId, secretAccessKey: secretAccessKey}); - AWS.config.region = 'us-east-1'; + AWS.config.region = region ; this.client = new AWS.CloudWatch(); } diff --git a/lib/tasseo/views/index.haml b/lib/tasseo/views/index.haml index a3f90f0..3620598 100644 --- a/lib/tasseo/views/index.haml +++ b/lib/tasseo/views/index.haml @@ -53,13 +53,14 @@ var influxDbAuth = "#{ENV['INFLUXDB_AUTH']}"; var awsAccessKeyId = "#{ENV['AWS_ACCESS_KEY_ID']}"; var awsSecretAccessKey = "#{ENV['AWS_SECRET_ACCESS_KEY']}"; + var awsRegion = "#{ENV['AWS_REGION']}"; if (libratoAuth != "") { datasource = new TasseoLibratoDatasource(libratoAuth) } else if (influxDbUrl != "") { datasource = new TasseoInfluxDBDatasource(influxDbUrl, influxDbAuth) } else if (typeof usingCloudWatch != 'undefined' && usingCloudWatch) { - datasource = new TasseoAWSCloudWatchDatasource(awsAccessKeyId, awsSecretAccessKey) + datasource = new TasseoAWSCloudWatchDatasource(awsAccessKeyId, awsSecretAccessKey, awsRegion) } else { var graphiteOptions = {} if (typeof padnulls != 'undefined') graphiteOptions['padnulls'] = padnulls; From 7eb0d916d421d8491c35ce3ac777b55e8b8fab2f Mon Sep 17 00:00:00 2001 From: inokappa Date: Tue, 23 Dec 2014 00:03:42 +0000 Subject: [PATCH 2/3] modified document. --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 795f647..28c50dd 100644 --- a/README.md +++ b/README.md @@ -222,7 +222,15 @@ Is equivalent to the InfluxDB query `select available from disk_usage`. ### Amazon CloudWatch Tasseo can be configured to fetch metrics from [Amazon CloudWatch](http://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/Welcome.html) -instead of Graphite by setting the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables instead of `GRAPHITE_AUTH`. **As warned [here](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/browser-configuring.html)**, only use AWS IAM code credentials that have read only access to specific resources. These environment variables are used on the client and may be downloaded by anyone who happens to browse to your deployed dashboard. In addition, you will need to write `var usingCloudWatch = true;` in the metric configuration file. +instead of Graphite by setting the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` and `AWS_REGION` environment variables instead of `GRAPHITE_AUTH`. **As warned [here](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/browser-configuring.html)**, only use AWS IAM code credentials that have read only access to specific resources. These environment variables are used on the client and may be downloaded by anyone who happens to browse to your deployed dashboard. In addition, you will need to write `var usingCloudWatch = true;` in the metric configuration file. + +Sample execute: + +``` +export AWS_ACCESS_KEY_ID=AKxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +export AWS_REGION=us-east-1 +``` By default, metric values are aggregated, come in 1 minute segments (CloudWatch's minimum), and span the default Tasseo 5 minute period (these correspond to the fields: "Statistics", "Period", and "EndTime"/"StartTime"). These fields are documented further [here](http://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricStatistics.html). The fields "Namespace", "MetricName", "Dimensions", must be specified by the user. Although a target is required to be present, its value is irrelevant. An example for getting the Put latency off of a Kinesis Stream: From edb2a30a296a98c95e46f7c609e1e28b9a259d26 Mon Sep 17 00:00:00 2001 From: inokappa Date: Tue, 23 Dec 2014 00:15:19 +0000 Subject: [PATCH 3/3] modified document. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 28c50dd..a09399b 100644 --- a/README.md +++ b/README.md @@ -227,9 +227,9 @@ instead of Graphite by setting the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KE Sample execute: ``` -export AWS_ACCESS_KEY_ID=AKxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -export AWS_REGION=us-east-1 +export AWS_ACCESS_KEY_ID=${your_access_key} +export AWS_SECRET_ACCESS_KEY=${your_secret_access_key} +export AWS_REGION=${your_region} ``` By default, metric values are aggregated, come in 1 minute segments (CloudWatch's minimum), and span the default Tasseo 5 minute period (these correspond to the fields: "Statistics", "Period", and "EndTime"/"StartTime"). These fields are documented further [here](http://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetMetricStatistics.html). The fields "Namespace", "MetricName", "Dimensions", must be specified by the user. Although a target is required to be present, its value is irrelevant. An example for getting the Put latency off of a Kinesis Stream: