Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #94 from inokappa/aws_region
Browse files Browse the repository at this point in the history
Added the ability to specify an environment variable the AWS Region
  • Loading branch information
obfuscurity committed Dec 23, 2014
2 parents 50800a6 + edb2a30 commit 2ed442f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=${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:

Expand Down
4 changes: 2 additions & 2 deletions lib/tasseo/public/j/tasseo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
3 changes: 2 additions & 1 deletion lib/tasseo/views/index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2ed442f

Please sign in to comment.