Showing posts with label Monitoring. Show all posts
Showing posts with label Monitoring. Show all posts

Monday, January 13, 2014

AWS CloudTrail and Splunk for better Cloud IT Operations

In any Cloud IT operations, gaining visibility into user activities is important for achieving compliance and meeting the regulatory standards of the enterprise. For years in AWS, we used to solve this with a combination of tools for log collection, alerts and privileged Identity access management. At times, it becomes cumbersome to install and manage these tools and overall operation cost effectively on Amazon Cloud. Like any other company pioneering managed services in AWS infrastructure, Our Cloud operations was in touch with Amazon Cloud product team for years giving input in this area. As an outcome of this, we see a new product line called as AWS Cloud Trail launched last year.

AWS Cloud Trail provides a record of AWS API calls made on your AWS account. AWS CloudTrail can be used for Resource Life Cycle Tracking, Operational Troubleshooting, Compliance Aid, and Security Analytics on AWS cloud infrastructure by integrating with the analytics tools like Splunk, Loggly, Sumo logic and etc.

In this article we are going to explore topics like :

  • How AWS CloudTrail can be integrated with Splunk App for AWS ?
  • How can we use it to operate our managed services efficiently ( with sample use cases answering following questions)
    • How do i get to know when security groups or Network details are changed ?
    • How do i know when EC2 instances are launched, terminated etc ?
    • How do i know what activities are carried on the Amazon Elastic IP's ?
    • What activities and changes happened in the IAM policies over the period ?
    • What are the Rare errors related to AWS account activities that can be tracked ?
How AWS CloudTrail + Splunk Integration works ?



Currently CloudTrail logs API calls on the following AWS services and in future you can expect more services to be launched. The current list is as follows :
·      Elastic Compute Cloud (EC2)
·      Elastic Block Store (EBS)
·      Virtual Private Cloud (VPC)
·      Relational Database Service (RDS)
·      Identity and Access Management (IAM)
·      Security Token Service (STS)
·      Redshift
·      CloudTrail

AWS CloudTrail captures AWS API calls made by or on behalf of an AWS account. Once the API calls are logged on files, it delivers these log files to an Amazon S3 bucket that you specify. Each call detail is logged in JSON format. Usually the JSON file is zipped and delivered to the bucket. SNS notification can be enabled to operations team when the log file is delivered.
Sample format of the log file nomenclature is shown below:
https://s3-us-west-2.amazonaws.com/<bucket_name>/<prefix_name>/AWSLogs/<AccountID>/CloudTrail/
us-west-2/2013/10/25/<AccountID>_CloudTrail_us-west-2_2014-11-25T12:25Z_bPlKAoJtDqSWWlTT.json.gz
How to activate AWS CloudTrail ?
By default CloudTrail is not enabled in your AWS account. To activate follow the below steps
1. Open the CloudTrail console in the AWS Management console
2. Click Get Started
3. On the Turn on CloudTrail page, you will be presented with the option to create a new Amazon S3 bucket or using an existing Amazon S3 bucket. In this article, I have selected the option to create new S3 bucket and provided the Bucket name as cloudtraillogs-splunk as illustrated below.

4. If you need to configure SNS notification and other settings, Click the option “Advanced”. Once clicked, below options will be displayed and these options are optional and not mandatory. I have enabled the option of SNS notification for every log delivery to our operations team.
Log file prefix: Enter a prefix for the Amazon S3 bucket. It is usually not needed since AWS automatically prefixes path automatically. You can see that path when you select the “View log file location”. But if you want Pattern for identification you can go ahead with the prefix.
Select Yes or No to “Include global services”?  IAM and AWS STS are the global services so if you want to log activities of those services as well, please select “Yes”. It is recommend to Select them because you can review the actions of the IAM.
SNS notification for every log files delivery?  If you want delivery, please enter the SNS topic name. The entered topic will be created in the SNS service and you must subscribe to it. After Saving, Click Subscribe. Once it is done, the service is activated and the log files are generated.

5. You can also edit the CloudTrail configuration and Turn off CloudTrail using the console. The console is illustrated in the below screen Shot.

What is Splunk App for AWS ?
Splunk App for AWS is designed to take the data from the AWS CloudTrail and provide the results using built-in dashboards. It is provided as a plug-in. Operations / Managed Services team can view this app and monitor and review some activities efficiently.

What is interesting with Splunk App for AWS?
  • It gives important insights into security-related activity such as unauthorized access attempts, simultaneous logins from geographically disparate locations and frequent changes to access control privileges. You can ensure security and compliance with continuous monitoring and a full audit trail of user activity using the Splunk App.
  • It provides option to configure email alerts based on the schedule
  • It provides easy option to monitor events, generate reports and export the reports and Search for events.

Steps to Integrate Splunk with AWS Cloud Trail :

Stage 1: Installing Splunk on AWS:
In order to use the Splunk App for AWS for this article, we are using the Enterprise Splunk AMI for illustrating the use cases.
1. Launch an EC2 Linux instance and based on the choice of Operating system download the Enterprise Splunk from the link http://www.splunk.com/download?r=header
2. Install the Splunk Enterprise



3. Export the following environmental values and then start the Splunk service.
# export SPLUNK_HOME=/opt/splunk
# export PATH=$SPLUNK_HOME/bin:$PATH$
$ splunk start
Commands to Restart and Check Status are below.
$ splunk restart
$ splunk status
4. On successful start the Spunk will be listening on the port 8000. Access the Splunk using the link http://<EC2 Public DNS>:8000. The below screen will be presented

Stage 2: Installing and Configuring Splunk App for AWS:
Splunk App for AWS fetches the data from the Amazon S3 bucket and provides the report in the Splunk GUI. Following are the steps to integrate Splunk app plugin with AWS Cloud Trail
1. Download the Splunk App for AWS from the link http://apps.splunk.com/app/1274/
2. Log into Splunk Enterprise and select the Manage Apps from the App menu
3. Click Install app from the file button.
4. On the Upload a file screen and Browse to locate the downloaded [app].tar.gz file, click Open and Upload
5. Click Restart Splunk, confirm to restart.
6. After Splunk restarted, login again, you can find the below screen.
7.From Settings in the top right corner of the page Select Data input, In that you can see an option to add AWS CloudTrail Log settings.
8. Click Add new and you will be asked for the following mandatory details.
  • AWS Access key
  • AWS Secret key
  • AWS SQS name
  • AWS SQS region
SQS Creation for topics
In order to use Splunk App, CloudTrail logging should be configured to send SNS topic and that topic should point to the Amazon SQS queue. You can see cloudtrail-spunkalert SNS topic is subscribed to the SQS queue Cloud Trail’s endpoint.
SQS queue should be created manually with the proper permissions to process messages. We have created a queue named CloudTrail in SQS. Below screenshot details the CloudTrail SQS queue:
The above step completes the configuration.

What we can monitor and review using CloudTrail + Splunk ?
The Splunk App for AWS has built in dashboard with lot of options to review Network Actions, IAM Actions, EC2 options etc. Now lets go through some of the common review activities the IT operations/ Managed Services team can perform using the AWS CloudTrail and Splunk Integration:
Case 1: Reviewing AWS Security Group related activities using AWS CloudTrail and Splunk:
From the above Screen shots , we can infer that a new Security group was created and authorized. The Audit details pertaining to Security group + additional details like IAM User, AWS Account, Source IP address and Time stamp of this activity is captured by AWS CloudTrail and presented in Splunk. The Operations/ Managed Services team can constantly monitor for such changes in the infrastructure and take actions accordingly.

Case 2: Reviewing Amazon EC2 related activities using AWS CloudTrail and Splunk:

From the above Screen shots , we can infer that Start, Stop and Terminate EC2 Instance activities are carried out in the AWS Account in the specified period. The EC2 Instance actions are noted with IAM User name and time stamp for monitoring purpose.
Case 3: Rare errors pertaining the AWS account can be reviewed using AWS CloudTrail and Splunk:

Case 4: Reviewing AWS IAM related activities using AWS CloudTrail and Splunk:
AWS IAM Activities like CreateUser, DeleteUser, DeleteLoginProfile etc are tracked by AWS CloudTrail as logs. These activities are presented to the IT Ops/MS team on the IAM actions module of Splunk. The diagrams representing the same is listed below:


Case 5: Reviewing Amazon ElasticIP related activities using AWS CloudTrail and Splunk:
From the above screen shot, We can infer that One EIP Allocate Address activity and One EIP Release Address 107.20.189.161 is carried out during the specified period. The Action, Time stamp , IAM user Name and AWS Account details are captured and can be used for audit purpose.

Case 6: View all the events occurred on your AWS Account as Graph



Case 7: Query your AWS CloudTrail logs for viewing activities and patterns

Splunk app provides the capability to query the AWS CloudTrail logs for viewing specific or overall actions carried out during specified period. This is a powerful feature used by operations/managed services team to view the events and take actions accordingly. 

Please talk to us to understand more about our Managed Services offerings and how we can help your cloud infrastructure. Contact

This article was co authored with Senthil.

Friday, April 26, 2013

Configuring NewRelic on Amazon Elastic BeanStalk

NewRelic is one of the most popular Application Performance Management tool used in Amazon Web Services to monitor applications . It supports most of the popular programming languages like Java,.Net,PHP,Ruby, Python etc. You can perform Server Monitoring,SQL/NoSQL performance monitoring,Web application transaction tracing etc using NewRelic in AWS infra. 

Amazon Elastic BeanStalk is a service that helps you to quickly deploy and manage applications in the AWS cloud. NewRelic+ BeanStalk is a popular combination in AWS. In this article we are going to explore how to configure NewRelic in Amazon Elastic BeanStalk for Java application deployed in Tomcat-7 container.

Step 1: Sign up and download the files
Sign up in the New Relic site with URL http://newrelic.com/signup. 
On successful sign up New Relic will provide customized newrelic.yml file by logging into https://rpm.newrelic.com.
Click the "Account settings" in upper right corner and then Click on the "Download the latest agent" link for Java to download the files you'll need.
The newrelic_agent2.16.0.zip will contain the newrelic.jar and the newrelic.yml

Step 2: Building Application with New Relic Agent:
Add the newrelic.jar and newrelic.yml  into WEB-INF/lib/ folder of your application war.
Repackage the war file. e.g., sample file name Newpet.war

Step 3: Uploading the new build into Amazon Elastic Beanstalk
Upload the repackaged jar to the Elastic BeanStalk using the tab “version” under the Elastic Beanstalk application details.
Once the upload is successful. It will be listed under the versions.
Choose "upload but do not deploy to any environment" option as illustrated in below diagram



Step 4: Launch the newly uploaded version 
Use the “Launch New Environment” to launch the new application version. Under the version select the latest upload version and then select the Container type as required. In this case the container is 64bit Amazon Linux running Tomcat 7.  


Follow the below steps , Choose the Instance type for your Web/App tier(t1.micro in this sample) . For customer facing production sites, it is recommended to start this with m1.large instance type.




and finally review and finish the setup as shown below.


Check the running instances in the AWS console

Step 5: Activate agent in AWS JVM configuration
Go to your "Petclinic" application environment and click the "Environment Details" and then go to the "Overview" tab. Click on "Edit Configuration" as seen below :


Click on your Container tab and enter the following in the "JVM Command Line Options" field as illustrated below:
-javaagent:/var/lib/tomcat7/webapps/ROOT/WEB-INF/lib/newrelic.jar



Note: This path is only accurate for the Tomcat7 container. You will need to alter the path accordingly based on your container requirements.

Click on "Apply Changes". The JVM will re-start and the application should start appearing in your New Relic account console within few minutes.

Step 5: Check Application status in New Relic Dashboard
You can see the Application status in the New Relic Dashboard as below

Since we had launched 3 EC2 instances in our Amazon Elastic BeanStalk tier you can see 3 servers listed for monitoring in the NewRelic Dashboard.

NewRelic charges your credit card each month/year for a specified number of servers associated to your account. A server/host is an Amazon EC2 instance running in AWS(in our context). Since EC2 instances have unique host names, NewRelic  distinguishes them easily .In our case ip-10-X.X.X listed in the above picture are EC2 instance host names. You can change the number of EC2 instance associated to NewRelic at any time and your billing will adjust with your next month.

In our case upto 5 EC2 instances are allowed for this NewRelic Account. So if Auto Scaling is enabled in Amazon Elastic BeanStalk and it scales out from 3->5 EC2 instances, they will still be automatically registered and monitored in NewRelic console. No additional configuration is needed. When more than 5 EC2 are launched, additional ones will not be shown in the NewRelic console until you upgrade your NewRelic plan. This simple SaaS licensing model and easy integration with Tomcat JVM makes NewRelic, a popular choice in AWS infra.

Now you can start monitoring and analyzing how your Web/App performs in deep using the NewRelic Dashboard.
















Friday, February 17, 2012

Part3:(Amazon ELB Series) Monitoring ELB using CloudWatch



Elastic Load Balancing provides data about the load balancers and the back-end EC2 application instances to Amazon CloudWatch. The Amazon CloudWatch service collects the data and presents it as readable, near real-time metrics. For example, we can monitor the number of unhealthy instances behind the load balancer in an Availibility Zone over a specified time period. By Default Elastic Load Balancing is enabled with Detailed Monitoring of CloudWatch.


Elastic Load Balancing only shows Amazon CloudWatch metrics when requests are flowing through the load balancer. If there are no requests are flowing then the metric will not be reported to CloudWatch.






Some of the ELB - CloudWatch metrics are :


Latency : Time elapsed after the ELB receives a request until it receives the corresponding response


RequestCount: The number of requests handled by the Elastic Load balancer


HealthyHostCount: The number of healthy Amazon EC2 instances active under a specified load balancer in a specified Availability Zone


UnHealthyHostCount : The number of unhealthy Amazon EC2 instances controlled by a specified load balancer in a specified Availability Zone.

HTTPCode_ELB_4XX: Number of Client error HTTP response codes generated by Elastic Load Balancing 

HTTPCode_ELB_5XX: Number of HTTP response codes generated by Elastic Load Balancing that are in the 5xx (server error) series. Elastic Load Balancing may generate 5xx errors if no back-end EC2 instances are registered or no healthy EC2 back-end instances

HTTPCode_Backend_2XX: Number of Success HTTP response codes generated by back-end instances 

HTTPCode_Backend_3XX: Number of HTTP response codes generated by back-end instances that are in the 3xx (user action required) series.

HTTPCode_Backend_4XX: Count of HTTP response codes generated by back-end instances that are in the 4xx (client error) series. This response count does not include any responses that were generated by Elastic Load Balancing.

HTTPCode_Backend_5XX: Count of HTTP response codes generated by back-end instances that are in the 5xx (server error) series. This response count does not include any responses that were generated by Elastic Load Balancing.

Need Consulting help ?

Name

Email *

Message *

DISCLAIMER
All posts, comments, views expressed in this blog are my own and does not represent the positions or views of my past, present or future employers. The intention of this blog is to share my experience and views. Content is subject to change without any notice. While I would do my best to quote the original author or copyright owners wherever I reference them, if you find any of the content / images violating copyright, please let me know and I will act upon it immediately. Lastly, I encourage you to share the content of this blog in general with other online communities for non-commercial and educational purposes.

Followers