Monitoring Amazon Web Services (AWS) with Amazon Web Services (AWS) agent
The AWS agent collects data from AWS APIs, such as CloudWatch, S3, and X-Ray, for which it is not possible to install a host agent or any other type of agent.
Note: To monitor AWS in a Kubernetes or Red Hat OpenShift cluster, do not install Instana AWS agent on each node of the cluster. Install AWS agent on a dedicated host machine.
- Platforms
- Monitored services
- Installation
- Configuration
Platforms
Monitored services
-
XRay (deprecated)
Note: Due to the nature of the AWS CloudWatch API, a delay in metrics retrieval is possible. The displayed values for the metrics are also delayed ensuring consistency. This delay depends on the actual AWS service and availability of data then but usually is around 10 minutes.
Installation
Note: This documentation covers installing the AWS Agent, which allows you to collect data from CloudWatch and other data sources to monitor services managed by Amazon.
Note: Depending on the number of monitored entities in your cloud environment, you might need to increase the maximum amount of available memory to your host agent. Agent memory can be increased by setting the environment variable
AGENT_MAX_MEM
to a value that is greater than the default value 512MB. For example, to set the agent memory to 1GB, you can set AGENT_MAX_MEM=1024mb
.
If you want to monitor an Amazon Elastic Computing (EC2) virtual machine, a Kubernetes cluster that runs on AWS, either installed and managed by you or using Amazon Elastic Kubernetes Service, or an Amazon Elastic Container cluster, refer to Install the Instana Host Agent documentation.
Note: Install only one AWS agent per combination of AWS account and AWS region. Installing multiple AWS Agents for the same combination of AWS account and AWS region can incur extra costs from AWS, without added benefit in terms of quality of monitoring by using Instana.
Installation on EC2
It is better to run the Instana AWS sensor on a Current Generation General Purpose machine that runs Linux®. For example, m5.large
instances are ideal.
-
Sign in to Instana and click More > Agents > Instana agent installation > AWS.
-
From the Technology list, select Instana AWS Sensor.
-
From the Run your AWS Agent on list, select Elastic Cloud Compute (EC2) (it's the default)
Your agent key and location are pre-populated in the script to be used as
User Data
on EC2. The script looks like the following, except that all the necessary information is provided:#!/bin/bash curl -o setup_agent.sh https://setup.instana.io/agent chmod 700 ./setup_agent.sh sudo ./setup_agent.sh -y -a <your-agent-key> -m aws -t dynamic -e <location> -s
-
Spin up a dedicated EC2 virtual machine and use the script as
User Data
. For more information on how to userUser Data
on EC2, see Running Commands on Your Linux Instance at Launch documentation. -
Copy the configuration.json file for the IAM role. It is the needed IAM role for the EC2 virtual machine that runs the Instana AWS sensor and enables the Instana agent to discover and monitor your AWS resources. Then, create an IAM role with the
configuration.json
file. For more information, see Creating a role to delegate permissions to an IAM user. -
For the IAM role to do the
AssumedRole
action, edit theTrust Relationship
. For example,{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "ec2.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }
In case your EC2 instance is in one of China's regions,
Trust Relationship
is look like:{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "ec2.amazonaws.com.cn" }, "Action": "sts:AssumeRole" } ] }
Refer to specifics of the China region monitoring for the additional necessary configuration.
Installation on Fargate on ECS
-
Sign in to Instana and click More -> Agents -> Instana agent installation -> AWS.
-
From the Technology list, select Instana AWS Sensor.
-
From the Run your AWS Agent on list, select Elastic Container Service (ECS)
The JSON of a Task Definition is pre-generated for you in the Task Definition JSON template. You can use it with the Configure by using JSON functions of the Task Definition user interface.
-
Assign to the new Task Definition an IAM role that contains at least the permissions that are listed under the IAM permissions JSON document.
-
Create an ECS Service with one instance of the newly created Task Definition.
Configuration
Installation outside your AWS infrastructure
You can also dedicate any agent that runs outside your AWS infrastructure. To achieve this goal, you need to specify the following environment variables within the /opt/instana/agent/bin/setenv
file:
-
The region that you want to monitor:
INSTANA_AWS_REGION_CONFIG=
-
The credentials to access AWS resources. These credentials should belong to a user, which is allowed to access the resources already described in the Amazon Web Services IAM Configuration section.
AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY=
Proxy configuration
Through environment variables
To configure the AWS Sensor to use proxy configuration, specify the following environment variables within the <instana-agent-dir>/bin/setenv
:
export HTTP_PROXY=
export HTTPS_PROXY=
Note: Both environment variables must be defined. After it is defined, Instana agent needs to be rebooted for changes to take place.
You can find more information about the HTTP proxy on the link.
Through agent configuration.yaml
To configure AWS sensors to use proxy configuration, add the following agent configuration settings:
com.instana.plugin.aws:
proxy_host: 'example.com' # proxy host name or ip address
proxy_port: 3128 # proxy port
proxy_protocol: 'HTTP' # proxy protocol: HTTP or HTTPS
proxy_username: 'username' # OPTIONAL: proxy username
proxy_password: 'password' # OPTIONAL: proxy password
tagging: # proxy setup for AWS Tagging API, used for AWS resource monitoring filtering
proxy_host: 'example.com' # proxy host name or ip address
proxy_port: 3128 # proxy port
proxy_protocol: 'HTTP' # proxy protocol: HTTP or HTTPS
proxy_username: 'username' # OPTIONAL: proxy username
proxy_password: 'password' # OPTIONAL: proxy password
Proxy settings can also be configured at the level of individual AWS Sensor. In this case, the previously mentioned global configuration is overridden by the specific AWS Sensor configuration. For more information, see the specific AWS Sensor documentation.
China region specifics
By default, the Instana agent contacts the global STS endpoint from the EC2 instance to gather instance profile credentials. Since this approach doesn't work in CN
regions, the STS region endpoint needs to be displayed as an environment
variable, which tells the Instana agent to use regional (CN) STS endpoints.
After the Instana agent is installed, specify the following environment variable within the <instana-agent-dir>/bin/setenv
:
export AWS_STS_REGIONAL_ENDPOINTS=regional
Enable monitoring for specific services
For each service, you need to add the needed permissions on the individual service pages, linked to from the Monitored Services section. To exclude a service from monitoring, leave out the respective permission.
Alternatively, another way to exclude a service from monitoring is to add the appropriate-enabled_ flag in <agent_install_dir>/etc/instana/configuration.yml
as described on the following individual service pages.
Monitoring multiple AWS accounts
The AWS Instana agent supports monitoring services from multiple AWS accounts in the same region. Currently, there are two approaches: using AWS named profiles and by using AWS Security Token Service (STS).
Note: When you configure the Instana agent to monitor multiple AWS accounts, only one of the two available approaches should be used.
AWS named profiles approach
To monitor multiple accounts, you need to define named profiles in the same way you would with the
AWS CLI, or creating the file manually. The .aws/credentials
file must be created within the home directory of the user who is running
the Instana agent, which is usually root
. The AWS CLI uses credentials files ~/.aws/credentials
as follows:
[default]
aws_access_key_id = accessKey1
aws_secret_access_key = secretAccessKey1
[profile2]
aws_access_key_id = accessKey2
aws_secret_access_key = secretAccessKey2
[profile3]
aws_access_key_id = accessKey3
aws_secret_access_key = secretAccessKey3
Every profile represents the mapping between AWS named profile and AWS access credentials. Upon installation of an AWS agent, a default
AWS profile is created. There is no need to add the default
profile to ~/.aws/credentials
file.
The additional profiles to be used by the AWS agent must be listed as follows in the agent configuration file /opt/instana/agent/etc/instana/configuration.yaml
:
com.instana.plugin.aws:
profile_names:
- 'profile2'
- 'profile3'
Notes:
- The monitoring of multiple AWS accounts can also be specified for particular AWS services within their specific configuration. The list of profiles that are specified for a specific service override the general configurations.
- Be sure to follow recommendations when it comes to the creation of the credentials file.
To avoid any security threats, you should either set more strict rules for EC2 instance or create a separate Instana AWS user and that way avoid adding root user security credentials to the ~/.aws/credentials
file.
AWS STS approach
This approach uses AWS STS service API to obtain access credentials for all additional AWS accounts that should be monitored by the Instana agent. After the agent is installed and configured to monitor default account, following
the steps that are described in the Installation
section, you should provide IAM Role ARNs from all additional AWS accounts, in the following way:
com.instana.plugin.aws:
role_arns:
- 'arn:aws:iam::<account_2_id>:role/<role_2_name>'
- 'arn:aws:iam::<account_3_id>:role/<role_3_name>'
Note: The monitoring of multiple AWS accounts can also be specified for particular AWS services within their specific configuration. The list of IAM roles that are specified for a specific service override the general configurations.
Each role, matching the specified ARN, should also comprise the needed IAM permissions necessary for Instana AWS monitoring. Thus, each role should allow default account to do sts:AssumeRole by specifying
the Trust relationship
policy in the following way:
-
If sts:AssumeRole is done from the AWS user context - when the agent is installed outside your AWS infrastructure
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::<default_account_id>:user/<default_account_username>" }, "Action": "sts:AssumeRole" } ] }
-
If sts:AssumeRole is done from the IAM Role context - when the agent is installed on EC2:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::<default_account_id>:role/<default_account_IAM_role_name>" }, "Action": "sts:AssumeRole" } ] }
Similarly, default account should be also allowed to do sts:AssumeRole to all additional accounts. This can be done by specifying extra IAM policies within the IAM Role that is used for Instana monitoring, in the following way:
{ "Version": "2012-10-17", "Statement": [ { #Instana monitoring policy specifications }, { "Action": [ "sts:AssumeRole" ], "Resource": "arn:aws:iam::<account_1_id>:role/<role_1_name>", "Effect": "Allow" }, { "Action": [ "sts:AssumeRole" ], "Resource": "arn:aws:iam::<account_2_id>:role/<role_2_name>", "Effect": "Allow" } ] }
Filtering and tagging
Note: To enable filtering, the IAM Permission tag:GetResources
should be included in the IAM permissions that are granted to the AWS Agent.
After you enable the monitoring of a service, it is possible to filter, which of its instances Instana will monitor based on AWS tags by modifying the agent configuration file /opt/instana/agent/etc/instana/configuration.yaml
of the AWS Agent.
Available options in the configuration file are:
com.instana.plugin.aws:
# Comma-separated list of tags in key:value format.
# Any AWS resource containing at least one of the specified tags is discovered.
include_tags: ...
# Comma-separated list of tags in key:value format.
# Any AWS resource containing at least one of the specified tags is omitted from discovery.
exclude_tags: ...
# Exclude untagged AWS resources by setting the flag to `false`
include_untagged: ...
Multiple tags can be defined, separated by a comma. Tags should be a key-value pair that is separated by :
. When you define tags in both lists (include and exclude), the exclude list has higher priority. If there is no need for
filtering services, the configuration should not be defined.
Note: The Instana agent automatically monitors all AWS resources that have no tags that are assigned. To exclude untagged resources from monitoring, set the include_untagged
flag to false
.
Filtering can also be configured on the service level. In this case, the default configuration is overridden for the particular service. For more details about discovery filtering by specific service, see specific service documentation.
Tag poll rate
To specify how often the AWS sensor polls monitored AWS service to get associated tags, use the tagged-services-poll-rate
configuration property. The default is 300
seconds. The sensor uses AWS service client to poll
tags.
The poll rate configuration for the tagged resources is:
com.instana.plugin.aws:
tagged-services-poll-rate: 60 #default 300
Polling interval
The polling interval indicates how often AWS sensor calls the CloudWatch API. It is configurable as a cloudwatch_period
in the configuration.yml
file. The default value is 300 seconds. It's most common to see monitoring
platforms use a value 5 - 10 minutes.
The polling interval is configurable on two levels:
-
Agent level for all AWS services monitored by the agent:
com.instana.plugin.aws: cloudwatch_period: 300
-
Per AWS service:
com.instana.plugin.aws.rds: cloudwatch_period: 300
Configuration for single service overrides agent level configuration.
CloudWatch costs
To provide insights into your AWS services, monitoring platforms like Instana must use the CloudWatch API. This API is provided by AWS with consumption-based pricing, and the purpose of this documentation is to provide transparency into how Instana uses the CloudWatch API for users to understand the impact on their AWS bill.
CloudWatch costs' are affected by:
- Number of monitored instances of AWS services
- Number of collected metrics per AWS sensor
- Polling interval (configurable)
Each AWS sensor calls the GetMetricData
CloudWatch API request for metrics collection, and if it fails GetMetricStatistics
is called as a fallback. Both endpoints incur the same costs per metrics (for clarity: the
fallback usage of GetMetricStatistics
does not incur extra costs). You can find details for both on the AWS CloudWatch pricing page.
The following table contains roughly estimated daily costs for different AWS sensors when the polling interval is 5 minutes and Amazon charge is $0.01 per 1000 CloudWatch metrics:
AWS Sensor | Number of Metrics | Daily cost per instance |
---|---|---|
DynamoDB | 71 | $0.2045 |
Elasticsearch | 12 | $0.0346 |
Lambda | 17 | $0.0490 |
MQ | 22 | $0.0634 |
RDS | 18 | $0.0518 |
SQS | 8 | $0.0230 |
S3 | 13 | $0.0374 |
Note that the CloudWatch are not used for EC2 and for polling tags, so there are no CloudWatch costs incurred there.
You can reduce CloudWatch costs by increasing the polling interval. The downside to increasing the polling interval is that you reduce granularity metrics from CloudWatch. Each request provides a single metric value, so the difference between a polling interval of 60s and 300s is five metric values or one metric value for a 300s period.
It is up to you to determine whether the default polling interval is right for your business or whether to customize it to strike the balance between cost and quality of insights.