Tuesday, December 22, 2015

Workflow for setting up amazon metrics to be collected: 
1) Edit Billing preferences as shown: 
Image 
Notice that the AWS billing preferences provide three options:  
The first option is the one that we will be customizing for our customers hence this option is merely for validity check. 
The second option is the one that we are interested in because we can subscribe to CloudWatch then.  
The third option can also be used with automation and hence we set it up with a S3 bucket.  
Notice that the policy to be applied for a bucket named raja0034 S3 billing is as follows:  
{ 
  "Version": "2008-10-17", 
  "Id": "Policy1335892530063", 
  "Statement": [ 
    { 
      "Sid": "Stmt1335892150622", 
      "Effect": "Allow", 
      "Principal": { 
        "AWS": "arn:aws:iam::386209384616:root" 
      }, 
      "Action": [ 
        "s3:GetBucketAcl", 
        "s3:GetBucketPolicy" 
      ], 
      "Resource": "arn:aws:s3:::raja0034billing" 
    }, 
    { 
      "Sid": "Stmt1335892526596", 
      "Effect": "Allow", 
      "Principal": { 
        "AWS": "arn:aws:iam::386209384616:root" 
      }, 
      "Action": [ 
        "s3:PutObject" 
      ], 
      "Resource": "arn:aws:s3:::raja0034billing/*" 
    } 
  ] 
} 
For option 2) of selecting alarms and metrics, we have to set it up on CloudWatch which displays both ECS and EBS Metrics: 
Image 
Selected Metrics could then include: 
Image 
Note that the metrics are categorized by service. If you wanted EC2 and EBS specifically, you would change the region to the one where your instances are : 
Image 
Notice we have changed from East region to West. 
Then you would see the metrics that we want to grab statistics for which we will do periodically and save it in a database as time series data for historical information and query. 
#codingexercise
Void sizeOf1or0onlyRectangle (int [,] matrix, int row, int col, int startx, int starty, int x, int y, ref int size, dir)
{
If (x+1 < row && y +1 < col  && 
Matrix [x+1,y+1] = matrix [x, y] &&
Matrix [x, y+1] = matrix [x,y] &&
Matrix[x+1, y] = matrix [x, y] && dir == diagonal && all_elements_in_new_row_are_same(matrix, startx, starty, matrix[x,y]) && 
all_elements_in_new_col_are_same(matrix, startx, starty, matrix[x,y]))
sizeOf1or0onlyRectangle(matrix,row, col, x+1,y+1, ref size +(x+1)-startx + (y+1)-starty + 1, dir );
If ( y +1 < col  && 
Matrix [x,y+1] = matrix [x, y] && dir == horizontal && all_elements_in_new_row_are_same(matrix, startx, starty, matrix[x,y]))
 sizeOf1or0onlyRectangle(matrix,row, col, x,y+1, ref size +(y+1)-starty, dir );
If (x+1 < row && 
Matrix[x+1, y] = matrix [x, y] && dir==vertical && all_elements_in_new_col_are_same(matrix, startx, starty, matrix[x,y]))
 sizeOf1or0onlyRectangle(matrix,row, col, x+1,y, ref size +(x+1)-startx, dir);

}

No comments:

Post a Comment