id
stringlengths
8
78
source
stringclasses
743 values
chunk_id
int64
1
5.05k
text
stringlengths
593
49.7k
acw-ug-671
acw-ug.pdf
671
based on the ClusterName, ProducerGroupName, and ConsumerGroupName dimensions. The dashboard will include dropdown options to select and view metrics for specific clusters and groups, allowing you to monitor the performance of individual clusters and groups separately. Be sure to deploy the relevant agent configuration to the correct EC2 instances. Each configuration will be stored as a separate Parameter in SSM's Parameter Store, as detailed later in Step 2: Store the recommended CloudWatch agent configuration file in Systems Manager Parameter Store. The following instructions describe the situation where the producer, consumer, and broker roles are deployed to separate EC2 instances, without any overlap. If you are running multiple Kafka roles on the same EC2 instances, see Configure the agent for multiple Kafka roles on the same instance for more information. CloudWatch agent configuration for this solution 2364 Amazon CloudWatch User Guide Agent configuration for Kafka broker agents Use the following CloudWatch agent configuration on EC2 instances where Kafka broker agents are deployed. Replace ClusterName with the name of the cluster to use to group these metrics for a unified view. The value you specify for ClusterName is used as both the ClusterName dimension and the ProcessGroupName dimension. Replace port-number with the JMX port of your Kafka server. If JMX was enabled with password authentication or SSL for remote access, see Collect Java Management Extensions (JMX) metrics for information about setting up TLS or authorization as required. The EC2 metrics shown in this configuration (configuration shown outside the JMX block) only work for Linux and macOS instances. If you are using Windows instances, you can choose to omit these metrics in the configuration. For information about metrics collected on Windows instances, see Metrics collected by the CloudWatch agent on Windows Server instances. { "metrics": { "namespace": "CWAgent", "append_dimensions": { "InstanceId": "${aws:InstanceId}" }, "metrics_collected": { "jmx": [ { "endpoint": "localhost:port-number", "kafka": { "measurement": [ "kafka.request.time.avg", "kafka.request.failed", "kafka.request.count", "kafka.purgatory.size", "kafka.partition.under_replicated", "kafka.partition.offline", "kafka.network.io", "kafka.leader.election.rate", "kafka.isr.operation.count" ] }, "append_dimensions": { "ClusterName": "ClusterName" } }, CloudWatch agent configuration for this solution 2365 User Guide Amazon CloudWatch { "endpoint": "localhost:port-number", "jvm": { "measurement": [ "jvm.classes.loaded", "jvm.gc.collections.count", "jvm.gc.collections.elapsed", "jvm.memory.heap.committed", "jvm.memory.heap.max", "jvm.memory.heap.used", "jvm.memory.nonheap.committed", "jvm.memory.nonheap.max", "jvm.memory.nonheap.used", "jvm.threads.count" ] }, "append_dimensions": { "ProcessGroupName": "ClusterName" } } ], "disk": { "measurement": [ "used_percent" ] }, "mem": { "measurement": [ "used_percent" ] }, "swap": { "measurement": [ "used_percent" ] }, "netstat": { "measurement": [ "tcp_established", "tcp_time_wait" ] } } } CloudWatch agent configuration for this solution 2366 Amazon CloudWatch } Agent configuration for Kafka producers User Guide Use the following CloudWatch agent configuration on Amazon EC2 instances where Kafka producers are deployed. Replace ProducerGroupName with the name of the application or group that you want to use to group your metrics for a unified view. Replace port-number with the JMX port of your Kafka producer application. The solution doesn’t enable JVM metrics for Kafka producers because the solution dashboard doesn’t display JVM metrics related to JVM for producers. You can customize the agent configuration to emit JVM metrics as well, however, JVM metrics related to producers are not visible on the solution dashboard. { "metrics": { "namespace": "CWAgent", "append_dimensions": { "InstanceId": "${aws:InstanceId}" }, "metrics_collected": { "jmx": [ { "endpoint": "localhost:port-number", "kafka-producer": { "measurement": [ "kafka.producer.request-rate", "kafka.producer.byte-rate", "kafka.producer.request-latency-avg", "kafka.producer.response-rate", "kafka.producer.record-error-rate", "kafka.producer.record-send-rate" ] }, "append_dimensions": { "ProducerGroupName": "ProducerGroupName" } } ] } } } CloudWatch agent configuration for this solution 2367 Amazon CloudWatch User Guide Agent configuration for Kafka consumers Use the following CloudWatch agent configuration on EC2 instances where Kafka consumers are running. Replace ConsumerGroupName with the name of the application or group to use to group these metrics for a unified view. Replace port-number with the JMX port of your Kafka consumer application. The solution doesn’t enable JVM metrics for Kafka consumers because the solution dashboard doesn’t display JVM metrics related to JVM for consumers. You can customize the agent configuration to emit JVM metrics as well, however JVM metrics related to consumer are not visible on the solution dashboard. { "metrics": { "append_dimensions": { "InstanceId": "${aws:InstanceId}" }, "metrics_collected": { "jmx": [ { "endpoint": "localhost:port-number", "kafka-consumer": { "measurement": [ "kafka.consumer.fetch-rate", "kafka.consumer.total.bytes-consumed-rate", "kafka.consumer.records-consumed-rate", "kafka.consumer.bytes-consumed-rate", "kafka.consumer.records-lag-max" ] }, "append_dimensions": { "ConsumerGroupName": "ConsumerGroupName" } } ] } } } CloudWatch agent configuration for this solution 2368 Amazon CloudWatch User Guide Deploy the agent for your solution There are several approaches for installing the CloudWatch agent, depending on the use case. We recommend using Systems Manager for this solution. It provides a console experience and makes it simpler to manage a fleet of managed servers within a single AWS account. The instructions in this section use Systems Manager and are intended for when you don’t have the CloudWatch agent running with existing configurations. You can check whether the CloudWatch agent is running by following the steps in Verify that the CloudWatch agent is running. If you are already
acw-ug-672
acw-ug.pdf
672
CloudWatch User Guide Deploy the agent for your solution There are several approaches for installing the CloudWatch agent, depending on the use case. We recommend using Systems Manager for this solution. It provides a console experience and makes it simpler to manage a fleet of managed servers within a single AWS account. The instructions in this section use Systems Manager and are intended for when you don’t have the CloudWatch agent running with existing configurations. You can check whether the CloudWatch agent is running by following the steps in Verify that the CloudWatch agent is running. If you are already running the CloudWatch agent on the EC2 hosts where the workload is deployed and managing the agent configurations, you can skip the instructions in this section and follow your existing deployment mechanism to update the configuration. Be sure to merge the agent configuration according to the role (broker, producer, or consumer) with your existing agent configuration, and then deploy the merged configuration. If you are using Systems Manager to store and manage the configuration for the CloudWatch agent, you can merge the configuration to the existing parameter value. For more information, see Managing CloudWatch agent configuration files. Note Using Systems Manager to deploy the following CloudWatch agent configurations will replace or overwrite any existing CloudWatch agent configuration on your EC2 instances. You can modify this configuration to suit your unique environment or use case. The metrics defined in this solution are the minimum required for the recommended dashboard. The deployment process includes the following steps: • Step 1: Ensure that the target EC2 instances have the required IAM permissions. • Step 2: Store the recommended agent configuration file in the Systems Manager Parameter Store. • Step 3: Install the CloudWatch agent on one or more EC2 instances using an AWS CloudFormation stack. • Step 4: Verify the agent setup is configured properly. You must repeat these steps based on whether your broker, producer, and consumer are deployed on the same EC2 instance or different instances. For example, if the Kafka broker, producer, and Deploy the agent for your solution 2369 Amazon CloudWatch User Guide consumers are getting deployed on separate instances without overlap, you must repeat these steps three times with the appropriate agent configurations for broker, producer, and consumer EC2 instances. Step 1: Ensure the target EC2 instances have the required IAM permissions You must grant permission for Systems Manager to install and configure the CloudWatch agent. You must also grant permission for the CloudWatch agent to publish telemetry from your EC2 instance to CloudWatch. Make sure that the IAM role attached to the instance has the CloudWatchAgentServerPolicy and AmazonSSMManagedInstanceCore IAM policies attached. • To create a role, see Create IAM roles to use with the CloudWatch agent on Amazon EC2 instances. • After the role is created, attach the role to your EC2 instances. Follow the steps in Launch an instance with an IAM role to attach a role while launching a new EC2 instance. To attach a role to an existing EC2 instance, follow the steps in Attach an IAM role to an instance. Step 2: Store the recommended CloudWatch agent configuration file in Systems Manager Parameter Store Parameter Store simplifies the installation of the CloudWatch agent on an EC2 instance by securely storing and managing configuration parameters, eliminating the need for hard-coded values. This ensures a more secure and flexible deployment process, enabling centralized management and easier updates to configurations across multiple instances. Use the following steps to store the recommended CloudWatch agent configuration file as a parameter in Parameter Store. To create the CloudWatch agent configuration file as a parameter 1. Open the AWS Systems Manager console at https://console.aws.amazon.com/systems- manager/. 2. 3. From the navigation pane, choose Application Management, Parameter Store. Follow these steps to create a new parameter for the configuration. a. Choose Create parameter. b. Provide a name for the parameter that will store your CloudWatch agent configuration, such as AmazonCloudWatch-Kafka-Producer-Configuration for producers, Deploy the agent for your solution 2370 Amazon CloudWatch User Guide AmazonCloudWatch-Kafka-Consumer-Configuration for consumers, or AmazonCloudWatch-Kafka-Broker-Configuration for brokers. If you have multiple Kafka roles on a single EC2, name the roles accordingly for easier identification. This value will later be used to distribute this configuration to the agent running on your EC2 c. d. e. f. instance. For Parameter tier, choose Standard. For Type, choose String. For Data type, choose text. In the Value box, paste the full text of the CloudWatch agent configuration. Be sure to select the JSON block for the Kafka role that this instance is hosting. Refer to the configuration provided in Agent configuration for Kafka broker agents, Agent configuration for Kafka producers, and Agent configuration for Kafka consumers when storing the configuration for broker, producer, and consumer respectively. If you are running multiple Kafka roles
acw-ug-673
acw-ug.pdf
673
used to distribute this configuration to the agent running on your EC2 c. d. e. f. instance. For Parameter tier, choose Standard. For Type, choose String. For Data type, choose text. In the Value box, paste the full text of the CloudWatch agent configuration. Be sure to select the JSON block for the Kafka role that this instance is hosting. Refer to the configuration provided in Agent configuration for Kafka broker agents, Agent configuration for Kafka producers, and Agent configuration for Kafka consumers when storing the configuration for broker, producer, and consumer respectively. If you are running multiple Kafka roles on the same EC2 instance, be sure to merge the configuration if required as described in Configure the agent for multiple Kafka roles on the same instance on the same instance g. Choose Create parameter. Step 3: Install the CloudWatch agent and apply the configuration using an AWS CloudFormation template You can use AWS CloudFormation to install the agent and configure it to use the CloudWatch agent configuration that you created in the previous steps. To install and configure the CloudWatch agent for this solution 1. Open the AWS CloudFormation Quick create stack wizard using this link: https:// console.aws.amazon.com/cloudformation/home?#/stacks/quickcreate?templateURL=https:// aws-observability-solutions-prod-us-east-1.s3.us-east-1.amazonaws.com/CloudWatchAgent/ CFN/v1.0.0/cw-agent-installation-template-1.0.0.json. 2. Verify that the selected Region on the console is the Region where the Kafka workload is running. 3. 4. For Stack name, enter a name to identity this stack, such as CWAgentInstallationStack. In the Parameters section, specify the following: Deploy the agent for your solution 2371 Amazon CloudWatch User Guide a. For CloudWatchAgentConfigSSM, enter the name of the Systems Manager parameter for the agent configuration that you created earlier, such as AmazonCloudWatch- Kafka-Broker-Configuration for brokers, AmazonCloudWatch-Kafka-Producer- Configuration for producers, and AmazonCloudWatch-Kafka-Consumer- Configuration for consumers. b. To select the target instances, you have two options. i. ii. For InstanceIds, specify a comma-delimited list of instance IDs list of instance IDs where you want to install the CloudWatch agent with this configuration. You can list a single instance or several instances. If you are deploying at scale, you can specify the TagKey and the corresponding TagValue to target all EC2 instances with this tag and value. If you specify a TagKey, you must specify a corresponding TagValue. (For an Auto Scaling group, specify aws:autoscaling:groupName for the TagKey and specify the Auto Scaling group name for the TagValue to deploy to all instances within the Auto Scaling group.) If you specify both the InstanceIds and the TagKeys parameters, the InstanceIds will take precedence and the tags will be ignored. 5. Review the settings, then choose Create stack. If you want to edit the template file first to customize it, choose the Upload a template file option under Create Stack Wizard to upload the edited template. For more information, see Creating a stack on AWS CloudFormation console. You can use the following link to download the template: https://aws-observability-solutions-prod-us-east-1.s3.us-east-1.amazonaws.com/ CloudWatchAgent/CFN/v1.0.0/cw-agent-installation-template-1.0.0.json. Note After this step is completed, this Systems Manager parameter will be associated with the CloudWatch agents running in the targeted instances. This means that: 1. If the Systems Manager parameter is deleted, the agent will stop. 2. If the Systems Manager parameter is edited, the configuration changes will automatically apply to the agent at the scheduled frequency which is 30 days by default. Deploy the agent for your solution 2372 Amazon CloudWatch User Guide 3. If you want to immediately apply changes to this Systems Manager parameter, you must run this step again. For more information about associations, see Working with associations in Systems Manager. Step 4: Verify the agent setup is configured properly You can verify whether the CloudWatch agent is installed by following the steps in Verify that the CloudWatch agent is running. If the CloudWatch agent is not installed and running, make sure you have set up everything correctly. • Be sure you have attached a role with correct permissions for the EC2 instance as described in Step 1: Ensure the target EC2 instances have the required IAM permissions. • Be sure you have correctly configured the JSON for the Systems Manager parameter. Follow the steps in Troubleshooting installation of the CloudWatch agent with AWS CloudFormation. If everything is set up correctly, then you should see the Kafka metrics being published to CloudWatch. You can check the CloudWatch console to verify they are being published. To verify that Kafka metrics are being published to CloudWatch 1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 2. Choose Metrics, All metrics. 3. Make sure you've selected the Region where you deployed the solution, and choose Custom namespaces, CWAgent. 4. Search for the metrics mentioned in the agent configuration section of this document, such as kafka.partition.offline for brokers, kafka.consumer.fetch.rate for consumers, or kafka.producer.request-rate for producers. If you see results for these metrics, then the metrics are being published to CloudWatch. Create the Kafka solution
acw-ug-674
acw-ug.pdf
674
being published to CloudWatch. You can check the CloudWatch console to verify they are being published. To verify that Kafka metrics are being published to CloudWatch 1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 2. Choose Metrics, All metrics. 3. Make sure you've selected the Region where you deployed the solution, and choose Custom namespaces, CWAgent. 4. Search for the metrics mentioned in the agent configuration section of this document, such as kafka.partition.offline for brokers, kafka.consumer.fetch.rate for consumers, or kafka.producer.request-rate for producers. If you see results for these metrics, then the metrics are being published to CloudWatch. Create the Kafka solution dashboard This dashboard displays the newly emitted metrics for both Kafka and the underlying JVM. This dashboard provides a top contributor view for the health of your Kafka workload, across producers, brokers, and consumers. The top contributor view displays the top 10 per metric widget. This allows you to identify outliers at a glance. Create the Kafka solution dashboard 2373 Amazon CloudWatch User Guide The solution dashboard doesn't display EC2 metrics. To view EC2 metrics, you'll need to use the EC2 automatic dashboard to see EC2 vended metrics and use the EC2 console dashboard to see EC2 metrics that are collected by the CloudWatch agent. For more information about automatic dashboards for AWS services, see Viewing a CloudWatch dashboard for a single AWS service. To create the dashboard, you can use the following options: • Use CloudWatch console to create the dashboard. • Use AWS CloudFormation console to deploy the dashboard. • Download the AWS CloudFormation infrastructure as code and integrate it as part of your continuous integration (CI) automation. By using the CloudWatch console to create a dashboard, you can preview the dashboard before actually creating and being charged. Note The dashboard created with AWS CloudFormation in this solution displays metrics from the Region where the solution is deployed. Be sure to create the AWS CloudFormation stack in the Region where your JVM and Kafka metrics are published. If you've specified a custom namespace other than CWAgent in the CloudWatch agent configuration, you'll have to change the AWS CloudFormation template for the dashboard to replace CWAgent with the customized namespace you are using. To create the dashboard via CloudWatch Console Note Solution dashboards currently display garbage collection-related metrics only for the G1 Garbage Collector, which is the default collector for the latest Java versions. If you are using a different garbage collection algorithm, the widgets pertaining to garbage collection are empty. However, you can customize these widgets by changing the dashboard CloudFormation template and applying the appropriate garbage collection type to the name dimension of the garbage collection-related metrics. For example, if you are using parallel garbage collection, change the name=\"G1 Young Create the Kafka solution dashboard 2374 Amazon CloudWatch User Guide Generation\" to name=\"Parallel GC\" of the garbage collection count metric jvm.gc.collections.count. 1. Open the CloudWatch Console Create Dashboard using this link: https://console.aws.amazon.com/cloudwatch/home?#dashboards? dashboardTemplate=ApacheKafkaOnEc2&referrer=os-catalog . 2. Verify that the selected Region on the console is the Region where the Kafka workload is running. 3. Enter the name of the dashboard, then choose Create Dashboard. To easily differentiate this dashboard from similar dashboards in other Regions, we recommend including the Region name in the dashboard name, such as KafkaDashboard- us-east-1. 4. Preview the dashboard and choose Save to create the dashboard. To create the dashboard via AWS CloudFormation 1. Open the AWS CloudFormation Quick create stack wizard using this link: https:// console.aws.amazon.com/cloudformation/home?#/stacks/quickcreate?templateURL=https:// aws-observability-solutions-prod-us-east-1.s3.us-east-1.amazonaws.com/Kafka_EC2/ CloudWatch/CFN/v1.0.0/dashboard-template-1.0.0.json. 2. Verify that the selected Region on the console is the Region where the Kafka workload is running. 3. 4. For Stack name, enter a name to identity this stack, such as KafkaDashboardStack. In the Parameters section, specify the name of the dashboard under the DashboardName parameter. To easily differentiate this dashboard from similar dashboards in other Regions, we recommend including the Region name in the dashboard name, such as KafkaDashboard- us-east-1. 5. Acknowledge access capabilities for transforms under Capabilities and transforms. Note that CloudFormation doesn't add any IAM resources. 6. Review the settings, then choose Create stack. Create the Kafka solution dashboard 2375 Amazon CloudWatch User Guide 7. After the stack status is CREATE_COMPLETE, choose the Resources tab under the created stack and then choose the link under Physical ID to go to the dashboard. You can also access the dashboard in the CloudWatch console by choosing Dashboards in the left navigation pane of the console, and finding the dashboard name under Custom Dashboards. If you want to edit the template file to customize it for any purpose, you can use Upload a template file option under Create Stack Wizard to upload the edited template. For more information, see Creating a stack on AWS CloudFormation console. You can use this link to download the template: https://aws-observability-solutions-prod-us-east-1.s3.us- east-1.amazonaws.com/Kafka_EC2/CloudWatch/CFN/v1.0.0/dashboard-template-1.0.0.json. Note Solution dashboards currently display garbage collection-related
acw-ug-675
acw-ug.pdf
675
choose the link under Physical ID to go to the dashboard. You can also access the dashboard in the CloudWatch console by choosing Dashboards in the left navigation pane of the console, and finding the dashboard name under Custom Dashboards. If you want to edit the template file to customize it for any purpose, you can use Upload a template file option under Create Stack Wizard to upload the edited template. For more information, see Creating a stack on AWS CloudFormation console. You can use this link to download the template: https://aws-observability-solutions-prod-us-east-1.s3.us- east-1.amazonaws.com/Kafka_EC2/CloudWatch/CFN/v1.0.0/dashboard-template-1.0.0.json. Note Solution dashboards currently display garbage collection-related metrics only for the G1 Garbage Collector, which is the default collector for the latest Java versions. If you are using a different garbage collection algorithm, the widgets pertaining to garbage collection are empty. However, you can customize these widgets by changing the dashboard CloudFormation template and applying the appropriate garbage collection type to the name dimension of the garbage collection-related metrics. For example, if you are using parallel garbage collection, change the name=\"G1 Young Generation\" to name=\"Parallel GC\" of the garbage collection count metric jvm.gc.collections.count. Get started with the Kafka dashboard Here are a few tasks that you can try out with the new Kafka dashboard. These tasks allow you to validate that the dashboard is working correctly and provide you some hands-on experience using it to monitor a Kafka cluster. As you try these out, you'll get familiar with navigating the dashboard and interpreting the visualized metrics. Using the dropdown lists The dashboard provides dropdown lists at the top that you can use to filter and select the specific Kafka cluster, producer, and consumer groups that you want to monitor. • To display metrics for a specific Kafka cluster, select that cluster name in the Kafka Cluster dropdown list. Create the Kafka solution dashboard 2376 Amazon CloudWatch User Guide • To display metrics for a specific Kafka producer group, select that producer group name in the Kafka Producer dropdown list. • To display metrics for a specific Kafka consumer group, select that consumer group name in the Kafka Consumer Group dropdown list. Verify cluster health From the Cluster Overview section, find the Partitions Under Replicated and In-Sync Replicas widgets. These should ideally be zero or a small number. A large value for any of these metrics could indicate issues with the Kafka cluster that need investigation. Investigate broker performance In the Brokers section, find the Failed Fetch Requests and Failed Producer Requests widgets. These show the number of failed requests for fetch and produce operations, respectively. High failure rates could indicate issues with the brokers or network connectivity that require further investigation. Monitor producer performance In the Producer Group Overview section, find the Average Request Rate, Average Request Latency, and Average Record Send/Error Rate widgets. These will give you an overview of how the producers in the selected group are performing. You can also drill down to view metrics for specific producers and topics in the Producers section. Monitor consumer lag In the Consumer Group Overview section, find the Consumer Lag widget. This shows how far behind the consumers are in processing messages from the latest offsets in the partitions they are subscribed to. Ideally, the consumer lag should be low or zero. A high consumer lag could indicate that the consumers are unable to keep up with the rate of data production, leading to potential data loss or delays in processing. You can also drill down to view metrics for specific consumers and topics in the Consumers section. Configure the agent for multiple Kafka roles on the same instance The individual configurations for Kafka roles listed in CloudWatch agent configuration for this solution apply only when the producer, consumer, and broker roles are deployed on separate EC2 Configure the agent for multiple Kafka roles on the same instance 2377 Amazon CloudWatch User Guide instances, without any overlap. If you are running multiple Kafka roles on the same Amazon EC2 instances, you have two options: • Create a single agent configuration file which lists and configures all metrics for all the Kafka roles deployed on that instance. If you are going to use Systems Manager to manage agent configuration, this is the preferred option. If you choose this option and the multiple Kafka roles are part of the same JVM process, you must specify the same endpoint for each Kafka role in the agent configuration. If the multiple Kafka roles are part of different JVM processes, the endpoint for each role can be different depending on the JMX port set for that process. • Create separate agent configuration files for each Kafka role, and configure the agent to apply both configuration files. For instructions for applying multiple configuration files, see Multiple CloudWatch agent configuration files. The following example
acw-ug-676
acw-ug.pdf
676
configuration, this is the preferred option. If you choose this option and the multiple Kafka roles are part of the same JVM process, you must specify the same endpoint for each Kafka role in the agent configuration. If the multiple Kafka roles are part of different JVM processes, the endpoint for each role can be different depending on the JMX port set for that process. • Create separate agent configuration files for each Kafka role, and configure the agent to apply both configuration files. For instructions for applying multiple configuration files, see Multiple CloudWatch agent configuration files. The following example shows a CloudWatch agent configuration where the producer and consumer roles are running on one instance as part of the same JVM process. In this case, the port number must be the same in both the producer and consumer parts of the configuration below. If instead the two roles were running as part of different JVM processes, you could specify different port numbers for each, according to the JMX port of each individual JVM process. { "metrics": { "namespace": "CWAgent", "append_dimensions": { "InstanceId": "${aws:InstanceId}" }, "metrics_collected": { "jmx": [ { "endpoint": "localhost:port-number", "kafka-producer": { "measurement": [ "kafka.producer.request-rate", "kafka.producer.byte-rate", "kafka.producer.request-latency-avg", "kafka.producer.response-rate", "kafka.producer.record-error-rate", "kafka.producer.record-send-rate" ] Configure the agent for multiple Kafka roles on the same instance 2378 User Guide Amazon CloudWatch }, "append_dimensions": { "ProducerGroupName": "ProducerGroupName" } }, { "endpoint": "localhost:port-number", "kafka-consumer": { "measurement": [ "kafka.consumer.fetch-rate", "kafka.consumer.total.bytes-consumed-rate", "kafka.consumer.records-consumed-rate", "kafka.consumer.bytes-consumed-rate", "kafka.consumer.records-lag-max" ] }, "append_dimensions": { "ConsumerGroupName": "ConsumerGroupName" } } ] } } } CloudWatch solution: Tomcat workload on Amazon EC2 This solution helps you configure out-of-the-box metric collection using CloudWatch agents for Tomcat server running on EC2 instances. Additionally, it helps you set up a pre-configured CloudWatch dashboard. For general information about all CloudWatch observability solutions, see CloudWatch observability solutions. Topics • Requirements • Benefits • Costs • CloudWatch agent configuration for this solution • Deploy the agent for your solution • Create the Tomcat solution dashboard Tomcat workload on EC2 2379 Amazon CloudWatch Requirements User Guide This solution is relevant for the following conditions: • Supported versions: Tomcat versions 9, 10.1, and 11 (beta) • Compute: Amazon EC2 • Supports up to 500 EC2 instances across all Tomcat workloads in a given AWS Region • Latest version of CloudWatch agent • SSM agent installed on EC2 instance Note AWS Systems Manager (SSM agent) is pre-installed on some Amazon Machine Images (AMIs) provided by AWS and trusted third-parties. If the agent isn't installed, you can install it manually using the procedure for your operating system type. • Manually installing and uninstalling SSM Agent on EC2 instances for Linux • Manually installing and uninstalling SSM Agent on EC2 instances for macOS • Manually installing and uninstalling SSM Agent on EC2 instances for Windows Server Benefits The solution delivers Tomcat server monitoring, providing valuable insights for the following use cases: • Detect Tomcat server errors and performance issues. • Monitor network traffic for data transfer problems. • Track thread usage and active user sessions. • Analyze underlying JVM performance for Tomcat server. Below are the key advantages of the solution: • Automates metric collection for Apache Tomcat and the underlying JVM using CloudWatch agent configuration, eliminating manual instrumentation. • Provides a pre-configured, consolidated CloudWatch dashboard for Apache Tomcat and JVM metrics. The dashboard will automatically handle metrics from new Tomcat EC2 instances Requirements 2380 Amazon CloudWatch User Guide configured using the solution, even if those metrics don't exist when you first create the dashboard. It also allows you to group the metrics into logical applications for easier focus and management. The following image is an example of the dashboard for this solution. Benefits 2381 Amazon CloudWatch User Guide Benefits 2382 Amazon CloudWatch Costs User Guide This solution creates and uses resources in your account. You are charged for standard usage, including the following: • All metrics collected by the CloudWatch agent are charged as custom metrics. The number of metrics used by this solution depends on the number of EC2 hosts. • Each Tomcat host configured for the solution publishes a total of 27 metrics plus one metric (disk_used_percent) for which the metric count depends on number of disk paths for that host. • One custom dashboard. • API operations requested by the CloudWatch agent to publish the metrics. With the default configuration for this solution, the CloudWatch agent calls the PutMetricData once every minute. This means the PutMetricData API will be called 30*24*60=43,200 in a 30-day month for each EC2 host. For more information about CloudWatch pricing, see Amazon CloudWatch Pricing. The pricing calculator can help you estimate approximate monthly costs for using this solution. To use the pricing calculator to estimate your monthly solution costs 1. Open the Amazon CloudWatch pricing calculator. 2. 3. In the Metrics section, for Number of metrics, enter
acw-ug-677
acw-ug.pdf
677
custom dashboard. • API operations requested by the CloudWatch agent to publish the metrics. With the default configuration for this solution, the CloudWatch agent calls the PutMetricData once every minute. This means the PutMetricData API will be called 30*24*60=43,200 in a 30-day month for each EC2 host. For more information about CloudWatch pricing, see Amazon CloudWatch Pricing. The pricing calculator can help you estimate approximate monthly costs for using this solution. To use the pricing calculator to estimate your monthly solution costs 1. Open the Amazon CloudWatch pricing calculator. 2. 3. In the Metrics section, for Number of metrics, enter (27 + average number of disk paths per EC2 host) * number of EC2 instances configured for this solution. In the APIs section, for Number of API requests, enter 43200 * number of EC2 instances configured for this solution. By default, the solution performs one PutMetricData operation each minute for each EC2 host. 4. In the Dashboards and Alarms section, for Number of Dashboards, enter 1. 5. You can see your monthly estimated costs at the bottom of the pricing calculator. Costs 2383 Amazon CloudWatch User Guide CloudWatch agent configuration for this solution The CloudWatch agent is software that runs continuously and autonomously on your servers and in containerized environments. It collects metrics, logs, and traces from your infrastructure and applications and sends them to CloudWatch and X-Ray. For more information about the CloudWatch agent, see Collect metrics, logs, and traces with the CloudWatch agent. The agent configuration in this solution collects the foundational metrics for Tomcat, JVM, and EC2. The CloudWatch agent can be configured to collect more JVM metrics than the dashboard displays by default. For a list of all Tomcat metrics that you can collect, see Collect Tomcat metrics. For a list of all JVM metrics that you can collect, see Collect JVM metrics. For a list of Amazon EC2 metrics, see Metrics collected by the CloudWatch agent on Linux and macOS instances. Expose JMX ports for the Tomcat server The CloudWatch agent relies on JMX to collect the metrics related to the Tomcat server and JVM process. To make this possible, you must expose the JMX port from your servers. To enable a JMX port for monitoring and management, you would set system properties for your Tomcat servers. You can use the environment variable CATALINA_OPTS to set the required system properties for Tomcat. Review the startup scripts and configuration files of your Tomcat server on the best place to set the environment variable. Be sure that you specify an unused port number. You will need to restart the server after the change. export CATALINA_OPTS="-Dcom.sun.management.jmxremote - Dcom.sun.management.jmxremote.port=<<port-number>> - Dcom.sun.management.jmxremote.ssl=false - Dcom.sun.management.jmxremote.authenticate=false" This example sets up unauthenticated JMX. If your security policies/requirements require you to enable JMX with password authentication or SSL for remote access, refer to the JMX documentation to set the required property. To verify the JMX port, run ps aux | grep jmxremote.port. The results should show that the JMX port was set on the JVM processes. CloudWatch agent configuration for this solution 2384 Amazon CloudWatch User Guide Agent configuration for Tomcat solution The metrics collected by the agent are defined in the agent configuration. The solution provides agent configurations to collect the recommended metrics with suitable dimensions for the solution’s dashboard. The steps for deploying the solution are described later in Deploy the agent for your solution. The following information is intended to help you understand how to customize the agent configuration for your environment. You must customize some parts of the following agent configuration for your environment: • The JMX port number is the port number that you configured in the previous section of this documentation. The port number is in the endpoint line in the configuration. • AppName – This is used as a dimension for the Tomcat application metrics collected. Provide a meaningful name that represents the grouping for the instances that run the Tomcat application. • ProcessGroupName – This is used as a dimension for JVM metrics collected for Tomcat hosts. Provide the value which is the same as AppName above. This is to enable viewing the JVM metrics of the same Tomcat app group as server metrics under the solution dashboard. For example, if you have two Tomcat apps running in the same AWS account, one for the billing-system application and another for the order-system application, you can set the AppName and ProcessGroupName dimensions accordingly in the agent configuration of each instance. • For the billing-system application instances, set AppName=billing-system and ProcessGroupName=billing-system. • For the order-system application instances, set AppName=order-system and ProcessGroupName=order-system. When you follow these guidelines, the solution will automatically group the metrics based on the AppName and ProcessGroupName dimensions. The dashboard will include dropdown options to select and view metrics for a specific Tomcat application, allowing you
acw-ug-678
acw-ug.pdf
678
solution dashboard. For example, if you have two Tomcat apps running in the same AWS account, one for the billing-system application and another for the order-system application, you can set the AppName and ProcessGroupName dimensions accordingly in the agent configuration of each instance. • For the billing-system application instances, set AppName=billing-system and ProcessGroupName=billing-system. • For the order-system application instances, set AppName=order-system and ProcessGroupName=order-system. When you follow these guidelines, the solution will automatically group the metrics based on the AppName and ProcessGroupName dimensions. The dashboard will include dropdown options to select and view metrics for a specific Tomcat application, allowing you to monitor the performance of individual applications separately. CloudWatch agent configuration for this solution 2385 Amazon CloudWatch User Guide Agent configuration for Tomcat hosts Use the following CloudWatch agent configuration on EC2 instances where your Tomcat applications are deployed. Configuration will be stored as a parameter in SSM's Parameter Store, as detailed later in Step 2: Store the recommended CloudWatch agent configuration file in Systems Manager Parameter Store. Replace AppName with a meaningful name that represents the Tomcat application the instances are part of. Replace port-number with the JMX port of your Tomcat server. If JMX was enabled with password authentication or SSL for remote access, see Collect Java Management Extensions (JMX) metrics for information about setting up TLS or authorization in agent configuration as required. The EC2 metrics shown in this configuration (configuration shown outside the JMX block) only work for Linux and macOS instances. If you are using Windows instances, you can choose to omit these metrics in the configuration. For information about metrics collected on Windows instances, see Metrics collected by the CloudWatch agent on Windows Server instances. { "metrics": { "namespace": "CWAgent", "append_dimensions": { "InstanceId": "${aws:InstanceId}" }, "metrics_collected": { "jmx": [ { "endpoint": "localhost:port-number", "tomcat": { "measurement": [ "tomcat.sessions", "tomcat.errors", "tomcat.processing_time", "tomcat.traffic", "tomcat.max_time", "tomcat.request_count", "tomcat.threads" ] }, "append_dimensions": { "AppName": "AppName" } }, CloudWatch agent configuration for this solution 2386 User Guide Amazon CloudWatch { "endpoint": "localhost:port-number", "jvm": { "measurement": [ "jvm.classes.loaded", "jvm.gc.collections.count", "jvm.gc.collections.elapsed", "jvm.memory.heap.committed", "jvm.memory.heap.max", "jvm.memory.heap.used", "jvm.memory.nonheap.committed", "jvm.memory.nonheap.max", "jvm.memory.nonheap.used", "jvm.threads.count" ] }, "append_dimensions": { "ProcessGroupName": "AppName" } } ], "disk": { "measurement": [ "used_percent" ] }, "mem": { "measurement": [ "used_percent" ] }, "swap": { "measurement": [ "used_percent" ] }, "netstat": { "measurement": [ "tcp_established", "tcp_time_wait" ] } } } CloudWatch agent configuration for this solution 2387 Amazon CloudWatch } Deploy the agent for your solution User Guide There are several approaches for installing the CloudWatch agent, depending on the use case. We recommend using Systems Manager for this solution. It provides a console experience and makes it simpler to manage a fleet of managed servers within a single AWS account. The instructions in this section use Systems Manager and are intended for when you don’t have the CloudWatch agent running with existing configurations. You can check whether the CloudWatch agent is running by following the steps in Verify that the CloudWatch agent is running. If you are already running the CloudWatch agent on the EC2 hosts where the JVM application is deployed and managing the agent configurations, you can skip the instructions in this section and follow your existing deployment mechanism to update the configuration. Be sure to merge the agent configuration of JVM with your existing agent configuration, and then deploy the merged configuration. If you are using Systems Manager to store and manage the configuration for the CloudWatch agent, you can merge the configuration to the existing parameter value. For more information, see Managing CloudWatch agent configuration files. Note Using Systems Manager to deploy the following CloudWatch agent configurations will replace or overwrite any existing CloudWatch agent configuration on your EC2 instances. You can modify this configuration to suit your unique environment or use case. The metrics defined in this solution are the minimum required for the recommended dashboard. The deployment process includes the following steps: • Step 1: Ensure that the target EC2 instances have the required IAM permissions. • Step 2: Store the recommended agent configuration file in the Systems Manager Parameter Store. • Step 3: Install the CloudWatch agent on one or more EC2 instances using an AWS CloudFormation stack. • Step 4: Verify the agent setup is configured properly. Deploy the agent for your solution 2388 Amazon CloudWatch User Guide Step 1: Ensure the target EC2 instances have the required IAM permissions You must grant permission for Systems Manager to install and configure the CloudWatch agent. You must also grant permission for the CloudWatch agent to publish telemetry from your EC2 instance to CloudWatch. Make sure that the IAM role attached to the instance has the CloudWatchAgentServerPolicy and AmazonSSMManagedInstanceCore IAM policies attached. • To create a role, see Create IAM roles to use with the CloudWatch agent on Amazon EC2 instances. • After the role is created, attach
acw-ug-679
acw-ug.pdf
679
properly. Deploy the agent for your solution 2388 Amazon CloudWatch User Guide Step 1: Ensure the target EC2 instances have the required IAM permissions You must grant permission for Systems Manager to install and configure the CloudWatch agent. You must also grant permission for the CloudWatch agent to publish telemetry from your EC2 instance to CloudWatch. Make sure that the IAM role attached to the instance has the CloudWatchAgentServerPolicy and AmazonSSMManagedInstanceCore IAM policies attached. • To create a role, see Create IAM roles to use with the CloudWatch agent on Amazon EC2 instances. • After the role is created, attach the role to your EC2 instances. Follow the steps in Launch an instance with an IAM role to attach a role while launching a new EC2 instance. To attach a role to an existing EC2 instance, follow the steps in Attach an IAM role to an instance. Step 2: Store the recommended CloudWatch agent configuration file in Systems Manager Parameter Store Parameter Store simplifies the installation of the CloudWatch agent on an EC2 instance by securely storing and managing configuration parameters, eliminating the need for hard-coded values. This ensures a more secure and flexible deployment process, enabling centralized management and easier updates to configurations across multiple instances. Use the following steps to store the recommended CloudWatch agent configuration file as a parameter in Parameter Store. To create the CloudWatch agent configuration file as a parameter 1. Open the AWS Systems Manager console at https://console.aws.amazon.com/systems- manager/. 2. 3. From the navigation pane, choose Application Management, Parameter Store. Follow these steps to create a new parameter for the configuration. a. b. c. d. Choose Create parameter. In the Name box, enter a name that you'll use to reference the CloudWatch agent configuration file in later steps. For example, AmazonCloudWatch-Tomcat- Configuration. (Optional) In the Description box, type a description for the parameter. For Parameter tier, choose Standard. Deploy the agent for your solution 2389 Amazon CloudWatch User Guide e. f. g. For Type, choose String. For Data type, choose text. In the Value box, paste the corresponding JSON block that was listed in Agent configuration for Tomcat hosts. Be sure to customize the grouping dimension value and port number as described. h. Choose Create parameter. Step 3: Install the CloudWatch agent and apply the configuration using an AWS CloudFormation template You can use AWS CloudFormation to install the agent and configure it to use the CloudWatch agent configuration that you created in the previous steps. To install and configure the CloudWatch agent for this solution 1. Open the AWS CloudFormation Quick create stack wizard using this link: https:// console.aws.amazon.com/cloudformation/home?#/stacks/quickcreate?templateURL=https:// aws-observability-solutions-prod-us-east-1.s3.us-east-1.amazonaws.com/CloudWatchAgent/ CFN/v1.0.0/cw-agent-installation-template-1.0.0.json. 2. Verify that the selected Region on the console is the Region where the Tomcat workload is running. 3. 4. For Stack name, enter a name to identity this stack, such as CWAgentInstallationStack. In the Parameters section, specify the following: a. For CloudWatchAgentConfigSSM, enter the name of the Systems Manager parameter for the agent configuration that you created earlier, such as AmazonCloudWatch-Tomcat- Configuration. b. To select the target instances, you have two options. i. ii. For InstanceIds, specify a comma-delimited list of instance IDs list of instance IDs where you want to install the CloudWatch agent with this configuration. You can list a single instance or several instances. If you are deploying at scale, you can specify the TagKey and the corresponding TagValue to target all EC2 instances with this tag and value. If you specify a TagKey, you must specify a corresponding TagValue. (For an Auto Scaling group, specify Deploy the agent for your solution 2390 Amazon CloudWatch User Guide aws:autoscaling:groupName for the TagKey and specify the Auto Scaling group name for the TagValue to deploy to all instances within the Auto Scaling group.) If you specify both the InstanceIds and the TagKeys parameters, the InstanceIds will take precedence and the tags will be ignored. 5. Review the settings, then choose Create stack. If you want to edit the template file first to customize it, choose the Upload a template file option under Create Stack Wizard to upload the edited template. For more information, see Creating a stack on AWS CloudFormation console. You can use the following link to download the template: https://aws-observability-solutions-prod-us-east-1.s3.us-east-1.amazonaws.com/ CloudWatchAgent/CFN/v1.0.0/cw-agent-installation-template-1.0.0.json. Note After this step is completed, this Systems Manager parameter will be associated with the CloudWatch agents running in the targeted instances. This means that: 1. If the Systems Manager parameter is deleted, the agent will stop. 2. If the Systems Manager parameter is edited, the configuration changes will automatically apply to the agent at the scheduled frequency which is 30 days by default. 3. If you want to immediately apply changes to this Systems Manager parameter, you must run this step again. For more information about associations, see Working with associations in Systems Manager. Step 4:
acw-ug-680
acw-ug.pdf
680
template: https://aws-observability-solutions-prod-us-east-1.s3.us-east-1.amazonaws.com/ CloudWatchAgent/CFN/v1.0.0/cw-agent-installation-template-1.0.0.json. Note After this step is completed, this Systems Manager parameter will be associated with the CloudWatch agents running in the targeted instances. This means that: 1. If the Systems Manager parameter is deleted, the agent will stop. 2. If the Systems Manager parameter is edited, the configuration changes will automatically apply to the agent at the scheduled frequency which is 30 days by default. 3. If you want to immediately apply changes to this Systems Manager parameter, you must run this step again. For more information about associations, see Working with associations in Systems Manager. Step 4: Verify the agent setup is configured properly You can verify whether the CloudWatch agent is installed by following the steps in Verify that the CloudWatch agent is running. If the CloudWatch agent is not installed and running, make sure you have set up everything correctly. • Be sure you have attached a role with correct permissions for the EC2 instance as described in Step 1: Ensure the target EC2 instances have the required IAM permissions. • Be sure you have correctly configured the JSON for the Systems Manager parameter. Follow the steps in Troubleshooting installation of the CloudWatch agent with AWS CloudFormation. Deploy the agent for your solution 2391 Amazon CloudWatch User Guide If everything is set up correctly, then you should see the Tomcat metrics being published to CloudWatch. You can check the CloudWatch console to verify they are being published. To verify that Tomcat metrics are being published to CloudWatch 1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 2. Choose Metrics, All metrics. 3. Make sure you've selected the Region where you deployed the solution, and choose Custom namespaces, CWAgent. 4. Search for the metrics mentioned in the agent configuration section of this document, such as tomcat.errors. If you see results for these metrics, then the metrics are being published to CloudWatch. Create the Tomcat solution dashboard This dashboard displays the newly emitted metrics, showing both the Tomcat application server and the underlying JVM. This dashboard provides a top contributor view for the health of your Tomcat workload. The top contributor view displays the top 10 per metric widget. This allows you to identify outliers at a glance. The dashboard also includes an overview of the cluster by aggregating and presenting metrics across all instances, providing a high-level summary of the overall health and operational state of the cluster. The solution dashboard doesn't display EC2 metrics. To view EC2 metrics, you'll need to use the EC2 automatic dashboard to see EC2 vended metrics and use the EC2 console dashboard to see EC2 metrics that are collected by the CloudWatch agent. For more information about automatic dashboards for AWS services, see Viewing a CloudWatch dashboard for a single AWS service. To create the dashboard, you can use the following options: • Use CloudWatch console to create the dashboard. • Use AWS CloudFormation console to deploy the dashboard. • Download the AWS CloudFormation infrastructure as code and integrate it as part of your continuous integration (CI) automation. By using the CloudWatch console to create a dashboard, you can preview the dashboard before actually creating and being charged. Create the Tomcat solution dashboard 2392 Amazon CloudWatch Note User Guide The dashboard created with AWS CloudFormation in this solution displays metrics from the Region where the solution is deployed. Be sure to create the AWS CloudFormation stack in the Region where your Tomcat metrics are published. If you've specified a custom namespace other than CWAgent in the CloudWatch agent configuration, you'll have to change the AWS CloudFormation template for the dashboard to replace CWAgent with the customized namespace you are using. To create the dashboard via CloudWatch Console Note Solution dashboards currently display garbage collection-related metrics only for the G1 Garbage Collector, which is the default collector for the latest Java versions. If you are using a different garbage collection algorithm, the widgets pertaining to garbage collection are empty. However, you can customize these widgets by changing the dashboard CloudFormation template and applying the appropriate garbage collection type to the name dimension of the garbage collection-related metrics. For example, if you are using parallel garbage collection, change the name=\"G1 Young Generation\" to name=\"Parallel GC\" of the garbage collection count metric jvm.gc.collections.count. 1. Open the CloudWatch Console Create Dashboard using this link: https://console.aws.amazon.com/cloudwatch/home?#dashboards? dashboardTemplate=ApacheTomcatOnEc2&referrer=os-catalog . 2. Verify that the selected Region on the console is the Region where the Tomcat workload is running. 3. Enter the name of the dashboard, then choose Create Dashboard. To easily differentiate this dashboard from similar dashboards in other Regions, we recommend including the Region name in the dashboard name, such as TomcatDashboard- us-east-1. 4. Preview the dashboard and choose Save to create the dashboard. Create the Tomcat solution dashboard 2393 Amazon CloudWatch User Guide To create the dashboard
acw-ug-681
acw-ug.pdf
681
GC\" of the garbage collection count metric jvm.gc.collections.count. 1. Open the CloudWatch Console Create Dashboard using this link: https://console.aws.amazon.com/cloudwatch/home?#dashboards? dashboardTemplate=ApacheTomcatOnEc2&referrer=os-catalog . 2. Verify that the selected Region on the console is the Region where the Tomcat workload is running. 3. Enter the name of the dashboard, then choose Create Dashboard. To easily differentiate this dashboard from similar dashboards in other Regions, we recommend including the Region name in the dashboard name, such as TomcatDashboard- us-east-1. 4. Preview the dashboard and choose Save to create the dashboard. Create the Tomcat solution dashboard 2393 Amazon CloudWatch User Guide To create the dashboard via AWS CloudFormation 1. Open the AWS CloudFormation Quick create stack wizard using this link: https:// console.aws.amazon.com/cloudformation/home?#/stacks/quickcreate?templateURL=https:// aws-observability-solutions-prod-us-east-1.s3.us-east-1.amazonaws.com/Tomcat_EC2/ CloudWatch/CFN/v1.0.0/dashboard-template-1.0.0.json. 2. Verify that the selected Region on the console is the Region where the Tomcat workload is running. 3. 4. 5. For Stack name, enter a name to identity this stack, such as TomcatDashboard-us-east-1. In the Parameters section, specify the name of the dashboard under the DashboardName parameter. To easily differentiate this dashboard from similar dashboards in other Regions, we recommend including the Region name in the dashboard name, such as TomcatDashboard- us-east-1. 6. Acknowledge access capabilities for transforms under Capabilities and transforms. Note that CloudFormation doesn't add any IAM resources. 7. Review the settings, then choose Create stack. 8. After the stack status is CREATE_COMPLETE, choose the Resources tab under the created stack and then choose the link under Physical ID to go to the dashboard. You can also access the dashboard in the CloudWatch console by choosing Dashboards in the left navigation pane of the console, and finding the dashboard name under Custom Dashboards. If you want to edit the template file to customize it for any purpose, you can use Upload a template file option under Create Stack Wizard to upload the edited template. For more information, see Creating a stack on AWS CloudFormation console. You can use this link to download the template: https://aws-observability-solutions-prod-us-east-1.s3.us- east-1.amazonaws.com/Tomcat_EC2/CloudWatch/CFN/v1.0.0/dashboard-template-1.0.0.json. Note Solution dashboards currently display garbage collection-related metrics only for the G1 Garbage Collector, which is the default collector for the latest Java versions. If you are using a different garbage collection algorithm, the widgets pertaining to garbage collection are empty. However, you can customize these widgets by changing the dashboard CloudFormation template and applying the appropriate garbage collection type to the name dimension of the garbage collection-related metrics. For Create the Tomcat solution dashboard 2394 Amazon CloudWatch User Guide example, if you are using parallel garbage collection, change the name=\"G1 Young Generation\" to name=\"Parallel GC\" of the garbage collection count metric jvm.gc.collections.count. Get started with the Tomcat monitoring dashboard Here are a few tasks that you can try out with the new Tomcat dashboard. These tasks allow you to validate that the dashboard is working correctly and provide you some hands-on experience using it to monitor a Tomcat application. As you try these out, you'll get familiar with navigating the dashboard and interpreting the visualized metrics. Using the dropdown list The dashboard provides a dropdown list at the top that you can use to filter and select the specific Tomcat application that you want to monitor. To display metrics for a specific Tomcat application, select that application name in the Tomcat App dropdown list. Verify application health From the App Overview section, find the Requests, Errors, and Error Rate widgets. These provide a high-level summary of the application's request handling performance. Look for any abnormally high error counts or rates, which could indicate issues that need investigation. Monitor request processing In the Request Processing Time section, find the Max Time and Total Time to Process All Requests widgets. These metrics help you identify potential performance bottlenecks in request processing. Look for any servers with significantly higher max processing times compared to others. Analyze network traffic In the Network Traffic section, find the Sent Traffic and Received Traffic widgets. These show the amount of data being sent and received by the application over the network. Unexpectedly high traffic levels could indicate potential issues with network saturation or inefficient data transfer. Investigate thread usage In the Sessions and Threads section, find the Busy Threads Count, Threads Count, and Sessions widgets. These metrics provide insights into the application's thread management and active user Create the Tomcat solution dashboard 2395 Amazon CloudWatch User Guide sessions. Look for any servers with an abnormally high number of busy threads or sessions, which could indicate potential resource constraints. CloudWatch solution: Amazon EC2 health This solution helps you configure out-of-the-box metric collection using CloudWatch agents for workloads running on EC2 instances. Additionally, it helps you set up a pre-configured CloudWatch dashboard. Topics • Requirements • Benefits • Costs • CloudWatch agent configuration for this solution • Deploy the agent for your solution • Create the EC2 Health solution dashboard
acw-ug-682
acw-ug.pdf
682
insights into the application's thread management and active user Create the Tomcat solution dashboard 2395 Amazon CloudWatch User Guide sessions. Look for any servers with an abnormally high number of busy threads or sessions, which could indicate potential resource constraints. CloudWatch solution: Amazon EC2 health This solution helps you configure out-of-the-box metric collection using CloudWatch agents for workloads running on EC2 instances. Additionally, it helps you set up a pre-configured CloudWatch dashboard. Topics • Requirements • Benefits • Costs • CloudWatch agent configuration for this solution • Deploy the agent for your solution • Create the EC2 Health solution dashboard • Get started with the EC2 Health solution dashboard Requirements This solution is relevant for the following conditions: • Compute: Amazon EC2 • Platform: Linux and macOS • Supports up to 500 EC2 instances in a given AWS Region • Latest version of CloudWatch agent • SSM agent installed on EC2 instance Note AWS Systems Manager (SSM agent) is pre-installed on some Amazon Machine Images (AMIs) provided by AWS and trusted third-parties. If the agent isn't installed, you can install it manually using the procedure for your operating system type. • Manually installing and uninstalling SSM Agent on EC2 instances for Linux EC2 health 2396 Amazon CloudWatch User Guide • Manually installing and uninstalling SSM Agent on EC2 instances for macOS • Manually installing and uninstalling SSM Agent on EC2 instances for Windows Server Benefits The solution delivers EC2 server monitoring using the CloudWatch Agent, providing additional system-level metrics on top of the standard EC2 namespace metrics for the following use cases: • Detect CPU performance issues and resource constraints. • Monitor disk utilization and storage capacity across different disks throughout your EC2 instances. • Track memory usage patterns and potential memory leaks. • Analyze I/O operations and their impact on overall performance. • Observe network traffic patterns and potential anomalies. Below are the key advantages of the solution: • Automates metric collection for EC2 instances eliminating manual instrumentation. • Provides a pre-configured, consolidated CloudWatch dashboard for EC2 instance metrics. The dashboard will automatically handle metrics from new EC2 instances configured using the solution, even if those metrics don't exist when you first create the dashboard. It also allows you to observe EC2 instances managed via Auto Scaling groups. The following image is an example of the dashboard for this solution. Benefits 2397 Amazon CloudWatch User Guide Benefits 2398 Amazon CloudWatch Costs User Guide This solution creates and uses resources in your account. You are charged for standard usage, including the following: • All metrics collected by the CloudWatch agent are charged as custom metrics. The number of metrics used by this solution depends on the number of EC2 hosts. The total number of CloudWatch agent metrics depends on the configuration of disks. Excluding disk and diskio metrics, the solution publishes six metrics. The number of disk metrics (disk_used_percent, disk_inodes_free) depend on the count of device/fstype/path dimensions. The diskio metric (diskio_io_time) depends on the count of name dimensions. For example, a single t2.micro with default settings as per EC2 console experience, produces a total of 22 CloudWatch agent metrics (4 CPU, 12 disk, 4 diskio, 1 memory, and 1 swap). Vended metrics like AWS/EC2 are provided free of charge. • One custom dashboard. • API operations requested by the CloudWatch agent to publish the metrics. With the default configuration for this solution, the CloudWatch agent calls the PutMetricData once every minute. This means the PutMetricData API will be called 30*24*60=43,200 in a 30-day month for each EC2 host. For more information about CloudWatch pricing, see Amazon CloudWatch Pricing. The pricing calculator can help you estimate approximate monthly costs for using this solution. To use the pricing calculator to estimate your monthly solution costs 1. Open the Amazon CloudWatch pricing calculator. 2. 3. In the Metrics section, for Number of metrics, enter (6 + total count of disk and diskio metrics per EC2 host as described above) * number of EC2 instances configured for this solution. In the APIs section, for Number of API requests, enter 43200 * number of EC2 instances configured for this solution. 4. By default, the solution performs one PutMetricData operation each minute for each EC2 host. 5. In the Dashboards and Alarms section, for Number of Dashboards, enter 1. 6. You can see your monthly estimated costs at the bottom of the pricing calculator. Costs 2399 Amazon CloudWatch User Guide CloudWatch agent configuration for this solution The CloudWatch agent is software that runs continuously and autonomously on your servers and in containerized environments. It collects metrics, logs, and traces from your infrastructure and applications and sends them to CloudWatch and X-Ray. For more information about the CloudWatch agent, see Collect metrics, logs, and traces with the CloudWatch agent. The agent configuration in this solution collects a
acw-ug-683
acw-ug.pdf
683
5. In the Dashboards and Alarms section, for Number of Dashboards, enter 1. 6. You can see your monthly estimated costs at the bottom of the pricing calculator. Costs 2399 Amazon CloudWatch User Guide CloudWatch agent configuration for this solution The CloudWatch agent is software that runs continuously and autonomously on your servers and in containerized environments. It collects metrics, logs, and traces from your infrastructure and applications and sends them to CloudWatch and X-Ray. For more information about the CloudWatch agent, see Collect metrics, logs, and traces with the CloudWatch agent. The agent configuration in this solution collects a set of metrics to help you get started monitoring and observing your EC2 instances. The CloudWatch agent can be configured to collect more EC2 metrics than the dashboard displays by default. For a list of Amazon EC2 metrics, see Metrics collected by the CloudWatch agent on Linux and macOS instances. For information about metrics collected on Windows instances, see Metrics collected by the CloudWatch agent on Windows Server instances. Agent configuration for EC2 Health solution The metrics collected by the agent are defined in the agent configuration. The solution provides agent configurations to collect the recommended metrics with suitable dimensions for the solution's dashboard. The steps for deploying the solution are described later in the section called “Deploy the agent for your solution”. The following information is intended to help you understand how to customize the agent configuration for your environment. Note If an EC2 instance is not part of an Auto Scaling group, the CloudWatch agent drops the AutoScalingGroupName dimension entirely. This behavior helps to prevent dimension names with null/empty values. Each metric widget included in the solution dashboard searches for metrics which include and exclude the AutoScalingGroup dimension. This helps to ensure that all EC2 instances where the solution is applied are supported by the same dashboard. If you wish to make any modifications to the agent configuration, you must apply the same changes to the solution's accompanying dashboard. For example, if you decide to omit the ImageId CloudWatch agent configuration for this solution 2400 Amazon CloudWatch User Guide dimension, the same dimension must be removed from the metric search expression used in the dashboard widgets. Agent configuration for EC2 Instances Use the following CloudWatch agent configuration on Amazon EC2 instances where your workloads are deployed. { "agent": { "metrics_collection_interval": 60, "run_as_user": "cwagent" }, "metrics": { "append_dimensions": { "InstanceId": "${aws:InstanceId}", "InstanceType": "${aws:InstanceType}", "ImageId": "${aws:ImageId}", "AutoScalingGroupName": "${aws:AutoScalingGroupName}" }, "metrics_collected": { "cpu": { "measurement": [ "cpu_usage_idle", "cpu_usage_iowait", "cpu_usage_user", "cpu_usage_system" ], "totalcpu": true }, "disk": { "measurement": [ "used_percent", "inodes_free" ], "resources": [ "*" ], "dimensions": [ ["device", "fstype", "path"] ] }, "diskio": { CloudWatch agent configuration for this solution 2401 Amazon CloudWatch User Guide "measurement": [ "io_time" ], "resources": [ "*" ] }, "mem": { "measurement": [ "used_percent" ] }, "swap": { "measurement": [ "used_percent" ] } } } } Deploy the agent for your solution There are several approaches for installing the CloudWatch agent, depending on the use case. We recommend using Systems Manager for this solution. It provides a console experience and makes it simpler to manage a fleet of managed servers within a single AWS account. The instructions in this section use Systems Manager and are intended for when you don't have the CloudWatch agent running with existing configurations. You can check whether the CloudWatch agent is running by following the steps in Verify that the CloudWatch agent is running. If you are already running the CloudWatch agent on the EC2 hosts and managing the agent configurations, you can skip the instructions in this section and follow your existing deployment mechanism to update the configuration. Be sure to merge the EC2 Health agent configuration with your existing agent configuration, and then deploy the merged configuration. If you are using Systems Manager to store and manage the configuration for the CloudWatch agent, you can merge the configuration to the existing parameter value. For more information, see Managing CloudWatch agent configuration files. Deploy the agent for your solution 2402 Amazon CloudWatch Note User Guide Using Systems Manager to deploy the following CloudWatch agent configurations will replace or overwrite any existing CloudWatch agent configuration on your EC2 instances. You can modify this configuration to suit your unique environment or use case. The metrics defined in configuration are the minimum required for the dashboard provided the solution. The deployment process includes the following steps: • Step 1: Ensure that the target EC2 instances have the required IAM permissions. • Step 2: Store the recommended agent configuration file in the Systems Manager Parameter Store. • Step 3: Install the CloudWatch agent on one or more EC2 instances using an AWS CloudFormation stack. • Step 4: Verify the agent setup is configured properly. Step 1: Ensure the target EC2 instances have the required
acw-ug-684
acw-ug.pdf
684
modify this configuration to suit your unique environment or use case. The metrics defined in configuration are the minimum required for the dashboard provided the solution. The deployment process includes the following steps: • Step 1: Ensure that the target EC2 instances have the required IAM permissions. • Step 2: Store the recommended agent configuration file in the Systems Manager Parameter Store. • Step 3: Install the CloudWatch agent on one or more EC2 instances using an AWS CloudFormation stack. • Step 4: Verify the agent setup is configured properly. Step 1: Ensure the target EC2 instances have the required IAM permissions You must grant permission for Systems Manager to install and configure the CloudWatch agent. You must also grant permission for the CloudWatch agent to publish telemetry from your EC2 instance to CloudWatch. Make sure that the IAM role attached to the instance has the CloudWatchAgentServerPolicy and AmazonSSMManagedInstanceCore IAM policies attached. • To create a role, see Create IAM roles to use with the CloudWatch agent on Amazon EC2 instances. • After the role is created, attach the role to your EC2 instances. To attach a role to an EC2 instance, follow the steps in Attach an IAM role to an instance. Step 2: Store the recommended CloudWatch agent configuration file in Systems Manager Parameter Store Parameter Store simplifies the installation of the CloudWatch agent on an EC2 instance by securely storing and managing configuration parameters, eliminating the need for hard-coded values. This Deploy the agent for your solution 2403 Amazon CloudWatch User Guide ensures a more secure and flexible deployment process, enabling centralized management and easier updates to configurations across multiple instances. Use the following steps to store the recommended CloudWatch agent configuration file as a parameter in Parameter Store. To create the CloudWatch agent configuration file as a parameter 1. Open the AWS Systems Manager console at https://console.aws.amazon.com/systems- manager/. 2. Verify that the selected Region on the console is the Region where the EC2 instances are running. 3. 4. From the navigation pane, choose Application Management, Parameter Store. Follow these steps to create a new parameter for the configuration. a. b. c. d. e. f. g. Choose Create parameter. In the Name box, enter a name that you'll use to reference the CloudWatch agent configuration file in later steps. For example, AmazonCloudWatch-EC2Health- Configuration. (Optional) In the Description box, type a description for the parameter. For Parameter tier, choose Standard. For Type, choose String. For Data type, choose text. In the Value box, paste the agent configuration JSON provided earlier in this document. h. Choose Create parameter. Step 3: Install the CloudWatch agent and apply the configuration using an AWS CloudFormation template You can use AWS CloudFormation to install the agent and configure it to use the CloudWatch agent configuration that you created in the previous steps. To install and configure the CloudWatch agent for this solution 1. Open the AWS CloudFormation Quick create stack wizard using this link: https:// console.aws.amazon.com/cloudformation/home?#/stacks/quickcreate?templateURL=https:// Deploy the agent for your solution 2404 Amazon CloudWatch User Guide aws-observability-solutions-prod-us-east-1.s3.us-east-1.amazonaws.com/CloudWatchAgent/ CFN/v1.0.0/cw-agent-installation-template-1.0.0.json . 2. Verify that the selected Region on the console is the Region where the EC2 instances are running. 3. 4. For Stack name, enter a name to identity this stack, such as CWAgentInstallationStack. In the Parameters section, specify the following: a. For CloudWatchAgentConfigSSM, enter the name of the Systems Manager parameter for the agent configuration that you created earlier, such as AmazonCloudWatch- EC2Health-Configuration. b. To select the target instances, you have two options. i. ii. For InstanceIds, specify a comma-delimited list of instance IDs list of instance IDs where you want to install the CloudWatch agent with this configuration. You can list a single instance or several instances. If you are deploying at scale, you can specify the TagKey and the corresponding TagValue to target all EC2 instances with this tag and value. If you specify a TagKey, you must specify a corresponding TagValue. (For an Auto Scaling group, specify aws:autoscaling:groupName for the TagKey and specify the Auto Scaling group name for the TagValue to deploy to all instances within the Auto Scaling group.) If you specify both the InstanceIds and the TagKeys parameters, the InstanceIds will take precedence and the tags will be ignored. 5. Review the settings, then choose Create stack. If you want to edit the template file first to customize it, choose the Upload a template file option under Create Stack Wizard to upload the edited template. For more information, see Creating a stack on AWS CloudFormation console. You can use the following link to download the template: https://aws-observability-solutions-prod-us-east-1.s3.us-east-1.amazonaws.com/ CloudWatchAgent/CFN/v1.0.0/cw-agent-installation-template-1.0.0.json . Note After this step is completed, this Systems Manager parameter will be associated with the CloudWatch agents running in the targeted instances. This means that: Deploy the agent for your solution 2405 Amazon CloudWatch User Guide 1. If
acw-ug-685
acw-ug.pdf
685
be ignored. 5. Review the settings, then choose Create stack. If you want to edit the template file first to customize it, choose the Upload a template file option under Create Stack Wizard to upload the edited template. For more information, see Creating a stack on AWS CloudFormation console. You can use the following link to download the template: https://aws-observability-solutions-prod-us-east-1.s3.us-east-1.amazonaws.com/ CloudWatchAgent/CFN/v1.0.0/cw-agent-installation-template-1.0.0.json . Note After this step is completed, this Systems Manager parameter will be associated with the CloudWatch agents running in the targeted instances. This means that: Deploy the agent for your solution 2405 Amazon CloudWatch User Guide 1. If the Systems Manager parameter is deleted, the agent will stop. 2. If the Systems Manager parameter is edited, the configuration changes will automatically apply to the agent at the scheduled frequency which is 30 days by default. 3. If you want to immediately apply changes to this Systems Manager parameter, you must run this step again. For more information about associations, see Working with associations in AWS Systems Manager. Step 4: Verify the agent setup is configured properly You can verify whether the CloudWatch agent is installed by following the steps in Verify that the CloudWatch agent is running. If the CloudWatch agent is not installed and running, make sure you have set up everything correctly. • Be sure you have attached a role with correct permissions for the EC2 instance as described in the section called “Step 1: Ensure the target EC2 instances have the required IAM permissions”. • Be sure you have correctly configured the JSON for the Systems Manager parameter. Follow the steps in Troubleshooting installation of the CloudWatch agent with AWS CloudFormation. To verify that EC2 health metrics are being published to CloudWatch 1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 2. Choose Metrics, All metrics. 3. Make sure you've selected the Region where you deployed the solution, and choose Custom namespaces, CWAgent. 4. Search for the metrics mentioned in the agent configuration section of this document, such as mem_used_percent. If you see results for these metrics, then the metrics are being published to CloudWatch. Create the EC2 Health solution dashboard This dashboard displays the newly emitted metrics, showing the EC2 Health metrics. This dashboard provides a top contributor view for the health of your EC2 instances in a single region. The top contributor view displays the top 10 per metric widget. This allows you to identify outliers at a glance. Create the EC2 Health solution dashboard 2406 Amazon CloudWatch User Guide To create the dashboard, you can use the following options: • Use CloudWatch console to create the dashboard. • Use AWS CloudFormation console to deploy the dashboard. • Download the AWS CloudFormation infrastructure as code and integrate it as part of your continuous integration (CI) automation. By using the CloudWatch console to create a dashboard, you can preview the dashboard before actually creating and being charged. Note The dashboard created with AWS CloudFormation in this solution displays metrics from the Region where the solution is deployed. Be sure to create the AWS CloudFormation stack in the Region where your EC2 metrics are published. If you've specified a custom namespace other than CWAgent in the CloudWatch agent configuration, you'll have to change the AWS CloudFormation template for the dashboard to replace CWAgent with the customized namespace you are using. To create the dashboard via CloudWatch Console 1. Open the CloudWatch Console Create Dashboard using this link: https://console.aws.amazon.com/cloudwatch/home?#dashboards? dashboardTemplate=Ec2LinuxMacOsHealth&referrer=os-catalog . 2. Verify that the selected Region on the console is the Region where the EC2 instances are running. 3. Enter the name of the dashboard, then choose Create Dashboard. To easily differentiate this dashboard from similar dashboards in other Regions, we recommend including the Region name in the dashboard name, such as EC2HealthDashboard-us-east-1. 4. Preview the dashboard and choose Save to create the dashboard. Create the EC2 Health solution dashboard 2407 Amazon CloudWatch User Guide To create the dashboard via AWS CloudFormation 1. Open the AWS CloudFormation Quick create stack wizard using this link: https:// console.aws.amazon.com/cloudformation/home?#/stacks/quickcreate?templateURL=https:// aws-observability-solutions-prod-us-east-1.s3.us-east-1.amazonaws.com/EC2_Health/ CloudWatch/CFN/v1.0.0/dashboard-template-linux-macos-1.0.0.json . 2. Verify that the selected Region on the console is the Region where the EC2 instances are running. 3. 4. For Stack name, enter a name to identity this stack, such as EC2HealthDashboardStack. In the Parameters section, specify the name of the dashboard under the DashboardName parameter. To easily differentiate this dashboard from similar dashboards in other Regions, we recommend including the Region name in the dashboard name, such as EC2HealthDashboard-us-east-1. 5. Acknowledge access capabilities for transforms under Capabilities and transforms. Note that AWS CloudFormation doesn't add any IAM resources. 6. Review the settings, then choose Create stack. 7. After the stack status is CREATE_COMPLETE, choose the Resources tab under the created stack and then choose the link under Physical ID to go to the dashboard. You can
acw-ug-686
acw-ug.pdf
686
this stack, such as EC2HealthDashboardStack. In the Parameters section, specify the name of the dashboard under the DashboardName parameter. To easily differentiate this dashboard from similar dashboards in other Regions, we recommend including the Region name in the dashboard name, such as EC2HealthDashboard-us-east-1. 5. Acknowledge access capabilities for transforms under Capabilities and transforms. Note that AWS CloudFormation doesn't add any IAM resources. 6. Review the settings, then choose Create stack. 7. After the stack status is CREATE_COMPLETE, choose the Resources tab under the created stack and then choose the link under Physical ID to go to the dashboard. You can also access the dashboard in the CloudWatch console by choosing Dashboards in the left navigation pane of the console, and finding the dashboard name under Custom Dashboards. If you want to edit the template file to customize it for any purpose, you can use the Upload a template file option under Create Stack Wizard to upload the edited template. For more information, see Creating a stack on AWS CloudFormation console. You can use this link to download the template: https://aws-observability-solutions-prod-us-east-1.s3.us- east-1.amazonaws.com/EC2_Health/CloudWatch/CFN/v1.0.0/dashboard-template-linux- macos-1.0.0.json Get started with the EC2 Health solution dashboard Here are a few tasks that you can try out with the new EC2 monitoring dashboard. These tasks allow you to validate that the dashboard is working correctly and provide you some hands- on experience using it to monitor EC2 instances. As you try these out, you'll get familiar with navigating the dashboard and interpreting the visualized metrics. Get started with the EC2 Health solution dashboard 2408 Amazon CloudWatch User Guide Monitor the various CPU utilization metrics In the CPU section, examine the array of CPU usage metrics. These provide insight into how CPU resources are being utilized across different activities like user processes, system tasks, and I/ O operations. Look for instances with consistently high utilization or unusual patterns, which might indicate the need for scaling or optimization. Analyze disk utilization across different devices Navigate to the Disk section to find the storage usage and inode availability metrics. These help you identify instances that are running low on storage space or file system resources. Pay attention to any instances approaching high disk usage levels, as this could lead to performance issues or service disruptions. Investigate memory utilization patterns In the Memory section, observe the graph which plots memory utilization over time. This shows how much of the available memory is being used by each instance. Look for patterns or spikes in memory usage that might correlate with specific times or events. High memory utilization could indicate the need for instance resizing or application optimization. Correlate patterns across core utilization metrics Compare and watch out for related utilization patterns. For example, a workload running a log rotation process could present regular increases in CPU and memory utilization, followed by a decrease in disk utilization. Inspect network activity In the Network section, examine the inbound and outbound network traffic metrics, both in terms of data volume and packet count. These give you insight into the network activity for your EC2 instances. Look out for both regular or anomalous spikes in network traffic, or imbalances between inbound and outbound data. Get started with the EC2 Health solution dashboard 2409 Amazon CloudWatch User Guide Monitor across accounts and Regions To enable unified monitoring across accounts, CloudWatch offers the following features: • CloudWatch cross-account observability– facilitate observability within a single Region with the Observability Access Manager (OAM) service. You can link accounts and easily view metrics, logs, traces, and other telemetry between accounts. This helps you to unify observability in central monitoring accounts that view telemetry shared from source accounts, and operate on this shared telemetry as if it were native to the monitoring account. • Cross-account cross-Region CloudWatch console– delivers a console experience that allows you to view dashboards, metrics, and alarms consoles of other accounts across Regions by toggling between accounts. After you set up the necessary permissions, you use an account selector integrated into the alarms, dashboards, and metrics consoles to view metrics, dashboards, and alarms in other accounts without having to log in and out of the accounts. By enabling this feature, you can also set up dashboards that contain cross-account cross-Region metrics for centralized visibility within an account. These two features are complementary to each other and can be used independently or together. See the following table for a comparison of the two features. We recommend that you use CloudWatch cross-account observability for the richest cross-account observability and discovery experience within a Region for your metrics, logs, and traces. What is it? CloudWatch cross-account observability Cross-account cross-Region CloudWatch console Unified access to underlying telemetry and other observabi lity resources across multiple accounts. After this is configure d, observability resources are seamlessly viewable between accounts, eliminating the need A designated
acw-ug-687
acw-ug.pdf
687
cross-account cross-Region metrics for centralized visibility within an account. These two features are complementary to each other and can be used independently or together. See the following table for a comparison of the two features. We recommend that you use CloudWatch cross-account observability for the richest cross-account observability and discovery experience within a Region for your metrics, logs, and traces. What is it? CloudWatch cross-account observability Cross-account cross-Region CloudWatch console Unified access to underlying telemetry and other observabi lity resources across multiple accounts. After this is configure d, observability resources are seamlessly viewable between accounts, eliminating the need A designated monitoring account assume a CrossAccountSharin gRole defined in source accounts from the CloudWatch console. By assuming this role, the monitorin g account can invoke operation s such as dashboard viewing on for role assumptions. The central behalf of source accounts, directly monitoring account gains direct from its console. access to the telemetry data and resources from source accounts, 2410 Amazon CloudWatch User Guide How does it work? CloudWatch cross-account observability Cross-account cross-Region CloudWatch console streamlining the monitoring and observability process. A monitoring account, using the Observability Access Monitorin g service, creates a sink and attaches a sink policy to it. A source account initiates the configuration by setting up a CrossAccountSharingRole, allowing a monitoring account The sink policy defines which to run operations in the source resources they would like to account. Then, a monitoring view and which source accounts account enables the cross-acc should share them. Then source ount cross-Region selector in accounts can create a link to the the console by specifying the monitoring account sink, establish source account ID. This enables ing what they actually want to the monitoring account to be share. After the link is created, the able to switch into the source specified resources are visible in account. When switching, the the monitoring account. What telemetry is supported? • Metrics • Traces • Logs . CloudWatch console checks for the existence of a service-linked role that allows CloudWatch to assume the CrossAccountSharin gRole that was created in the source account. • Metrics • Traces 2411 Amazon CloudWatch User Guide CloudWatch cross-account observability Cross-account cross-Region CloudWatch console What functionality is supported? • Dashboarding • Alarms • Metrics Insights • Anomaly Detection • CloudWatch Logs insights • Application Insights • Other functionalities. For more details see CloudWatch cross- account observability. . • Console switching between accounts and Regions in metrics, alarms, and traces consoles. • Custom dashboards with metrics and alarms from other accounts and Regions For more details, see Cross-acc ount cross-Region CloudWatch console. How many accounts can I use it with? A monitoring account can see resources from as many as By using the cross-account cross- Region selector in the console, a 100,000 source accounts at the monitoring account can switch to same time. A source account one other account at a time but can share their resources with as there is no limit on the number many as five different monitoring of accounts that can be linked. accounts. Does it move telemetry data? No. Resources are shared between accounts with the exception of copied traces. When defining cross-account dashboards and alarms, many source accounts can be reference d. No. An IAM policy is configure d to allow embedded account switching for cross-account cross- Region resource visibilty. 2412 Amazon CloudWatch User Guide CloudWatch cross-account observability Cross-account cross-Region CloudWatch console How much does it cost? No extra charges for shared logs and metrics, and the first trace No additional charges for cross- account or cross-Region actions. copy is free. For more informati on about pricing, see Amazon CloudWatch pricing. Does it support observability across No Regions? Yes Does it support programmatic access? Does it support programmatic setup? Yes. the AWS CLI, AWS Cloud Development Kit (AWS CDK), and No. APIs are supported. Yes Yes Yes Does it support AWS Organizations? Yes Topics • CloudWatch cross-account observability • Cross-account cross-Region CloudWatch console CloudWatch cross-account observability With Amazon CloudWatch cross-account observability, you can monitor and troubleshoot applications that span multiple accounts within a Region. Seamlessly search, visualize, and analyze your metrics, logs, traces, Application Signals services and service level objectives (SLOs), Application Insights applications, and internet monitors in any of the linked accounts without account boundaries. CloudWatch cross-account observability 2413 Amazon CloudWatch User Guide Set up one or more AWS accounts as monitoring accounts and link them with multiple source accounts. A monitoring account is a central AWS account that can view and interact with observability data generated from source accounts. A source account is an individual AWS account that generates observability data for the resources that reside in it. Source accounts share their observability data with the monitoring account. The shared observability data can include the following types of telemetry: • Metrics in Amazon CloudWatch. You
acw-ug-688
acw-ug.pdf
688
in any of the linked accounts without account boundaries. CloudWatch cross-account observability 2413 Amazon CloudWatch User Guide Set up one or more AWS accounts as monitoring accounts and link them with multiple source accounts. A monitoring account is a central AWS account that can view and interact with observability data generated from source accounts. A source account is an individual AWS account that generates observability data for the resources that reside in it. Source accounts share their observability data with the monitoring account. The shared observability data can include the following types of telemetry: • Metrics in Amazon CloudWatch. You can choose to share the metrics from all namespaces with the monitoring account, or filter to a subset of namespaces. • Log groups in Amazon CloudWatch Logs. You can choose to share all log groups with the monitoring account, or filter to a subset of log groups. • Traces in AWS X-Ray • Services and Service level objectives (SLOs) in Application Signals • Applications in Amazon CloudWatch Application Insights • Monitors in CloudWatch Internet Monitor To create links between monitoring accounts and source accounts, you can use the CloudWatch console. Alternatively, use the Observability Access Manager commands in the AWS CLI and API. For more information, see Observability Access Manager API Reference. A sink is a resource that represents an attachment point in a monitoring account. Source accounts can link to the sink to share observability data. Each account can have one sink per Region. Each sink is managed by the monitoring account where it is located. An observability link is a resource that represents the link established between a source account and a monitoring account. Links are managed by the source account. For a video demonstration of setting up CloudWatch cross-account observability, see the following video. The next topic explains how to set up CloudWatch cross-account observability in both monitoring accounts and source accounts. For information about the cross-account cross-Region CloudWatch dashboard, see Cross-account cross-Region CloudWatch console. Use Organizations for source accounts There are two options for linking source accounts to your monitoring account. You can use one or both options. CloudWatch cross-account observability 2414 Amazon CloudWatch User Guide • Use AWS Organizations to link accounts in an organization or organizational unit to the monitoring account. • Connect individual AWS accounts to the monitoring account. We recommend that you use Organizations so that new AWS accounts created later in the organization are automatically onboarded to cross-account observability as source accounts. Details about linking monitoring accounts and source accounts • Each monitoring account can be linked to as many as 100,000 source accounts. • Each source account can share data with as many as five monitoring accounts. • You can set up a single account as both a monitoring account and a source account. If you do, this account sends only the observability data from itself to its linked monitoring account. It does not relay the data from its source accounts. • A monitoring account specifies which telemetry types can be shared with it. A source account specifies which telemetry types it wants to share. • If there are more telemetry types selected in the monitoring account than in the source account, the accounts are linked. Only the data types that are selected in both accounts are shared. • If there are more telemetry types selected in the source account than in the monitoring account, the link creation fails and nothing is shared. • A metric name doesn't appear in the monitoring account console until that metric emits new data points after the link is created. • To remove a link between accounts, do so from the source account. • To delete a sink in a monitoring account, you must first remove all links to that sink the monitoring account. Pricing Cross-account observability in CloudWatch comes with no extra cost for logs and metrics, Application Signals, and the first trace copy is free. For more information about pricing, see Amazon CloudWatch Pricing. Contents • Link monitoring accounts with source accounts CloudWatch cross-account observability 2415 Amazon CloudWatch • Necessary permissions • Permissions needed to create links • Permissions needed to monitor across accounts • Setup overview • Step 1: Set up a monitoring account User Guide • Step 2: (Optional) Download an AWS CloudFormation template or URL • Step 3: Link the source accounts • Use an AWS CloudFormation template to set up all accounts in an organization or an organizational unit as source accounts • Use an AWS CloudFormation template to set up individual source accounts • Use a URL to set up individual source accounts • Manage monitoring accounts and source accounts • Link more source accounts to an existing monitoring account • Remove the link between a monitoring account and source account • View information about a monitoring
acw-ug-689
acw-ug.pdf
689
a monitoring account User Guide • Step 2: (Optional) Download an AWS CloudFormation template or URL • Step 3: Link the source accounts • Use an AWS CloudFormation template to set up all accounts in an organization or an organizational unit as source accounts • Use an AWS CloudFormation template to set up individual source accounts • Use a URL to set up individual source accounts • Manage monitoring accounts and source accounts • Link more source accounts to an existing monitoring account • Remove the link between a monitoring account and source account • View information about a monitoring account Link monitoring accounts with source accounts The topics in this section explain how to set up links between monitoring accounts and source accounts. We recommend that you create a new AWS account to serve as the monitoring account for your organization. Contents • Necessary permissions • Permissions needed to create links • Permissions needed to monitor across accounts • Setup overview • Step 1: Set up a monitoring account • Step 2: (Optional) Download an AWS CloudFormation template or URL • Step 3: Link the source accounts Link monitoring accounts with source accounts 2416 Amazon CloudWatch User Guide • Use an AWS CloudFormation template to set up all accounts in an organization or an organizational unit as source accounts • Use an AWS CloudFormation template to set up individual source accounts • Use a URL to set up individual source accounts Necessary permissions Permissions needed to create links To create links between a monitoring account and a source account, you must be signed in with certain permissions. • To set up a monitoring account – You must have either full administrator access in the monitoring account, or you must sign in to that account with the following permissions: { "Version": "2012-10-17", "Statement": [ { "Sid": "AllowSinkModification", "Effect": "Allow", "Action": [ "oam:CreateSink", "oam:DeleteSink", "oam:PutSinkPolicy", "oam:TagResource" ], "Resource": "*" }, { "Sid": "AllowReadOnly", "Effect": "Allow", "Action": ["oam:Get*", "oam:List*"], "Resource": "*" } ] } • Source account, scoped to a specific monitoring account – To create, update, and manage links for just one specified monitoring account, you must sign in to account with at least the following permissions. In this example, the monitoring account is 999999999999. Link monitoring accounts with source accounts 2417 Amazon CloudWatch User Guide If the link isn't going to share all seven resource types (metrics, logs, traces, Application Insights applications, Application Signals services and service level objectives (SLOs), and Internet Monitor monitors), you can omit cloudwatch:Link, logs:Link, xray:Link, applicationinsights:Link, application-signals:Link, or internetmonitor:Link as needed. { "Version": "2012-10-17", "Statement": [ { "Action": [ "oam:CreateLink", "oam:UpdateLink", "oam:DeleteLink", "oam:GetLink", "oam:TagResource" ], "Effect": "Allow", "Resource": "arn:*:oam:*:*:link/*" }, { "Action": [ "oam:CreateLink", "oam:UpdateLink" ], "Effect": "Allow", "Resource": "arn:*:oam:*:*:sink/*", "Condition": { "StringEquals": { "aws:ResourceAccount": [ "999999999999" ] } } }, { "Action": "oam:ListLinks", "Effect": "Allow", "Resource": "*" }, { "Action": "cloudwatch:Link", Link monitoring accounts with source accounts 2418 Amazon CloudWatch User Guide "Effect": "Allow", "Resource": "*" }, { "Action": "logs:Link", "Effect": "Allow", "Resource": "*" }, { "Action": "xray:Link", "Effect": "Allow", "Resource": "*" }, { "Action": "applicationinsights:Link", "Effect": "Allow", "Resource": "*" }, { "Action": "internetmonitor:Link", "Effect": "Allow", "Resource": "*" }, { "Action": "application-signals:Link", "Effect": "Allow", "Resource": "*" } ] } • Source account, with permissions to link to any monitoring account – To create a link to any existing monitoring account sink and share metrics, log groups, traces, Application Insights applications, and Internet Monitor monitors, you must sign in to the source account with full administrator permissions or sign in there with the following permissions If the link isn't going to share all seven resource types (metrics, logs, traces, Application Insights applications, Application Signals services and service level objectives (SLOs), and Internet Monitor monitors), you can omit cloudwatch:Link, logs:Link, xray:Link, applicationinsights:Link, application-signals:Link, or internetmonitor:Link as needed. Link monitoring accounts with source accounts 2419 Amazon CloudWatch User Guide { "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action": [ "oam:CreateLink", "oam:UpdateLink" ], "Resource": [ "arn:aws:oam:*:*:link/*", "arn:aws:oam:*:*:sink/*" ] }, { "Effect": "Allow", "Action": [ "oam:List*", "oam:Get*" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "oam:DeleteLink", "oam:GetLink", "oam:TagResource" ], "Resource": "arn:aws:oam:*:*:link/*" }, { "Action": "cloudwatch:Link", "Effect": "Allow", "Resource": "*" }, { "Action": "xray:Link", "Effect": "Allow", "Resource": "*" }, { "Action": "logs:Link", "Effect": "Allow", Link monitoring accounts with source accounts 2420 Amazon CloudWatch User Guide "Resource": "*" }, { "Action": "applicationinsights:Link", "Effect": "Allow", "Resource": "*" }, { "Action": "internetmonitor:Link", "Effect": "Allow", "Resource": "*" }, { "Action": "application-signals:Link", "Effect": "Allow", "Resource": "*" } ] } Permissions needed to monitor across accounts After a link has been created, to view source account information from a monitoring account, you must be signed in to an account with one of the following: • Full administrator access in the monitoring account • The following cross-account permissions, in addition to permissions to view the specific types
acw-ug-690
acw-ug.pdf
690
"Action": "logs:Link", "Effect": "Allow", Link monitoring accounts with source accounts 2420 Amazon CloudWatch User Guide "Resource": "*" }, { "Action": "applicationinsights:Link", "Effect": "Allow", "Resource": "*" }, { "Action": "internetmonitor:Link", "Effect": "Allow", "Resource": "*" }, { "Action": "application-signals:Link", "Effect": "Allow", "Resource": "*" } ] } Permissions needed to monitor across accounts After a link has been created, to view source account information from a monitoring account, you must be signed in to an account with one of the following: • Full administrator access in the monitoring account • The following cross-account permissions, in addition to permissions to view the specific types of resources that you will be monitoring { "Sid": "AllowReadOnly", "Effect": "Allow", "Action": [ "oam:Get*", "oam:List*" ], "Resource": "*" } Link monitoring accounts with source accounts 2421 Amazon CloudWatch Setup overview User Guide The following high-level steps show you how to set up CloudWatch cross-account observability. Note We recommend creating a new AWS account to use as your organization's monitoring account. 1. Set up a dedicated monitoring account. 2. (Optional) Download an AWS CloudFormation template or copy a URL to link source accounts. 3. Link source accounts to the monitoring account. After completing these steps, you can use the monitoring account to view the observability data of the source accounts. Step 1: Set up a monitoring account Follow the steps in this section to set up an AWS account as a monitoring account for CloudWatch cross-account observability. Prerequisites • If you're setting up accounts in an AWS Organizations organization as the source accounts – Get the organization path or organization ID. • If you're not using Organizations for the source accounts – Get the account IDs of the source accounts. To set up an account as a monitoring account, you must have certain permissions. For more information, see Necessary permissions. To set up a monitoring account 1. Sign in to the account that you want to use as a monitoring account. 2. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 3. In the left navigation pane, choose Settings. 4. By Monitoring account configuration, choose Configure. Link monitoring accounts with source accounts 2422 Amazon CloudWatch User Guide 5. For Select data, choose whether this monitoring account will be able to view Logs, Metrics, Traces, Application Insights - Applications, Internet Monitor - Monitors, and Application Signals - Services, Service Level Objectives (SLOs) data from the source accounts it is linked to. 6. For List source accounts, enter the source accounts that this monitoring account will view. To identify the source accounts, enter individual account IDs, organization paths, or organization IDs. If you enter an organization path or organization ID, this monitoring account is allowed to view observability data from all linked accounts in that organization. Separate the entries in this list with commas. Important When you enter an organization path, follow the exact format. The ou-id must end with a / (a slash character). For example: o-a1b2c3d4e5/r-f6g7h8i9j0example/ ou-def0-awsbbbb/ 7. For Define a label to use to identify your source account, you can define alabel that is used to create a AWS CloudFormation template. The label is then applied to source accounts when that template is used to link the source accounts to this monitoring account. You can specify whether to use account names or email addresses in this label, and also use variables such as $AccountName, $AcccountEmail, and $AcccountEmailNoDomain. Note In the AWS GovCloud (US-East) and AWS GovCloud (US-West) Regions, the only supported option is to use custom labels, and the $AccountName, $AcccountEmail, and $AcccountEmailNoDomain variables all resolve as account-id instead of the specified variable. 8. Choose Configure. Important The link between the monitoring and source accounts is not complete until you configure the source accounts. For more information, see the following sections. Link monitoring accounts with source accounts 2423 Amazon CloudWatch User Guide Step 2: (Optional) Download an AWS CloudFormation template or URL To link source accounts to a monitoring account, we recommend using an AWS CloudFormation template or a URL. • If you are linking an entire organization – CloudWatch provides an AWS CloudFormation template. • If you are linking individual accounts – Use either an AWS CloudFormation template or a URL that CloudWatch provides. To use an AWS CloudFormation template, you must download it during these steps. After you link the monitoring account with at least one source account, the AWS CloudFormation template is no longer available to download. To download an AWS CloudFormation template or copy a URL for linking source accounts to the monitoring account 1. Sign in to the account that you want to use as a monitoring account. 2. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 3. In the left navigation pane, choose Settings. 4. By Monitoring account configuration, choose Resources to link accounts. 5. Do one of the following: • Choose AWS organization to get a template
acw-ug-691
acw-ug.pdf
691
must download it during these steps. After you link the monitoring account with at least one source account, the AWS CloudFormation template is no longer available to download. To download an AWS CloudFormation template or copy a URL for linking source accounts to the monitoring account 1. Sign in to the account that you want to use as a monitoring account. 2. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 3. In the left navigation pane, choose Settings. 4. By Monitoring account configuration, choose Resources to link accounts. 5. Do one of the following: • Choose AWS organization to get a template to use to link accounts in an organization to this monitoring account. • Choose Any account to get a template or URL for setting up individual accounts as source accounts. 6. Do one of the following: • If you chose AWS organization, choose Download CloudFormation template. • If you chose Any account, choose either Download CloudFormation template or Copy URL. 7. (Optional) Repeat steps 5-6 to download both the AWS CloudFormation template and the URL. Link monitoring accounts with source accounts 2424 Amazon CloudWatch User Guide Step 3: Link the source accounts Use the steps in these sections to link source accounts to a monitoring account. To link monitoring accounts with source accounts, you must have certain permissions. For more information, see Necessary permissions. Use an AWS CloudFormation template to set up all accounts in an organization or an organizational unit as source accounts These steps assume that you already downloaded the necessary AWS CloudFormation template by performing the steps in Step 2: (Optional) Download an AWS CloudFormation template or URL. To use an AWS CloudFormation template to link accounts in an organization or organizational unit to the monitoring account 1. Sign in to the organization's management account. 2. Open the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation. 3. In the left navigation bar, choose StackSets. 4. Check that you are signed in to the Region that you want, then choose Create StackSet. 5. Choose Next. 6. Choose Template is ready and choose Upload a template file. 7. Choose Choose file, choose the template that you downloaded from the monitoring account, and choose Open. 8. Choose Next. 9. For Specify StackSet details, enter a name for the StackSet and choose Next. 10. For Add stacks to stack set, choose Deploy new stacks. 11. For Deployment targets, choose whether to deploy to the entire organization or to specified organizational units. 12. For Specify regions, choose which Regions to deploy CloudWatch cross-account observability to. 13. Choose Next. 14. On the Review page, confirm your selected options and choose Submit. 15. In the Stack instances tab, refresh the screen until you see that your stack instances have the status CREATE_COMPLETE. Link monitoring accounts with source accounts 2425 Amazon CloudWatch User Guide Use an AWS CloudFormation template to set up individual source accounts These steps assume that you already downloaded the necessary AWS CloudFormation template by performing the steps in Step 2: (Optional) Download an AWS CloudFormation template or URL. To use an AWS CloudFormation template to set up individual source accounts for CloudWatch cross-account observability 1. Sign in to the source account. 2. Open the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation. 3. In the left navigation bar, choose Stacks. 4. Check that you are signed in to the Region that you want, then choose Create stack, With new resources (standard). 5. Choose Next. 6. Choose Upload a template file. 7. Choose Choose file, choose the template that you downloaded from the monitoring account, and choose Open. 8. Choose Next. 9. For Specify stack details, enter a name for the stack and choose Next. 10. On the Configure stack options page, choose Next. 11. On the Review page, choose Submit. 12. On the status page for your stack, refresh the screen until you see that your stack has the status CREATE_COMPLETE. 13. To use this same template to link more source accounts to this monitoring account, sign out of this account and sign in to the next source account. Then repeat steps 2-12. Use a URL to set up individual source accounts These steps assume that you already copied the necessary URL by performing the steps in Step 2: (Optional) Download an AWS CloudFormation template or URL. To use a URL to link individual source accounts to the monitoring account 1. 2. Sign in to the account that you want to use as a source account. Enter the URL that you copied from the monitoring account. Link monitoring accounts with source accounts 2426 Amazon CloudWatch User Guide You see the CloudWatch settings page, with some information filled in. 3. For Select data, choose whether this source account will share Logs, Metrics, Traces, Application Insights - Applications, and Internet Monitor - Monitors data to this monitoring account. For
acw-ug-692
acw-ug.pdf
692
Step 2: (Optional) Download an AWS CloudFormation template or URL. To use a URL to link individual source accounts to the monitoring account 1. 2. Sign in to the account that you want to use as a source account. Enter the URL that you copied from the monitoring account. Link monitoring accounts with source accounts 2426 Amazon CloudWatch User Guide You see the CloudWatch settings page, with some information filled in. 3. For Select data, choose whether this source account will share Logs, Metrics, Traces, Application Insights - Applications, and Internet Monitor - Monitors data to this monitoring account. For both Logs and Metrics, you can choose whether to share all resources or a subset with the monitoring account. a. (Optional) To share a subset of this account's log groups with the monitoring account, select Logs and choose Filter Logs. Then use the Filter Logs box to construct a query to find the log groups that you want to share. The query will use the term LogGroupName and one or more of the following operands. • = and != • AND • OR • ^ indicates LIKE and !^ indicates NOT LIKE. These can be used only as prefix searches. Include a % at the end of the string that you want to search for and include. • IN and NOT IN, using parentheses (( )) The complete query must be no more than 2000 characters and is limited to five conditional operands. Conditional operands are AND and OR. There isn't a limit on the number of other operands. Tip Choose View sample queries to see the correct syntax for common query formats. b. (Optional) To share a subset of this account's metric namespaces with the monitoring account, select Metrics and choose Filter Metrics. Then use the Filter Metrics box to construct a query to find the metric namespaces that you want to share. Use the term Namespace and one or more of the following operands. • = and != • AND • OR Link monitoring accounts with source accounts 2427 Amazon CloudWatch User Guide • LIKE and NOT LIKE. These can be used only as prefix searches. Include a % at the end of the string that you want to search for and include. • IN and NOT IN, using parentheses (( )) The complete query must be no more than 2000 characters and is limited to five conditional operands. Conditional operands are AND and OR. There isn't a limit on the number of other operands. Tip Choose View sample queries to see the correct syntax for common query formats. 4. Do not change the ARN in Enter monitoring account configuration ARN. 5. The Define a label to identify your source account section is pre-filled with the label choice from the monitoring account, if there is one. Optionally, choose Edit to change it. Note In the AWS GovCloud (US-East) and AWS GovCloud (US-West) Regions, the only supported option is to use custom labels, and the $AccountName, $AcccountEmail, and $AcccountEmailNoDomain variables all resolve as account-id instead of the specified variable. 6. Choose Link. 7. 8. Enter Confirm in the box and choose Confirm. To use this same URL to link more source accounts to this monitoring account, sign out of this account and sign in to the next source account. Then repeat steps 2-7. Manage monitoring accounts and source accounts After you set up your monitoring accounts and source accounts, you can use the steps in these sections to manage them. Contents • Link more source accounts to an existing monitoring account Manage monitoring accounts and source accounts 2428 Amazon CloudWatch User Guide • Remove the link between a monitoring account and source account • View information about a monitoring account Link more source accounts to an existing monitoring account Follow the steps in this section to add links from additional source accounts to an existing monitoring account. Each source account can be linked to as many as five monitoring accounts. Each monitoring account can be linked to as many as 100,000 source accounts. To manage a source account, you must have certain permissions. For more information, see Necessary permissions. To add more source accounts to a monitoring account 1. Sign in to the monitoring account. 2. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 3. In the left navigation pane, choose Settings. 4. By Monitoring account configuration, choose Manage source accounts. 5. Choose the Configuration policy tab. 6. In the Configuration policy box, add the new source account ID in the Principal line. For example, suppose the Principal line is currently the following: "Principal": {"AWS": ["111111111111", "222222222222"]} To add 999999999999 as a third source account, edit the line to the following: "Principal": {"AWS": ["111111111111", "222222222222", "999999999999"]} 7. Choose Update. 8. Choose the Configuration details tab. 9. Choose the copy icon that
acw-ug-693
acw-ug.pdf
693
Sign in to the monitoring account. 2. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 3. In the left navigation pane, choose Settings. 4. By Monitoring account configuration, choose Manage source accounts. 5. Choose the Configuration policy tab. 6. In the Configuration policy box, add the new source account ID in the Principal line. For example, suppose the Principal line is currently the following: "Principal": {"AWS": ["111111111111", "222222222222"]} To add 999999999999 as a third source account, edit the line to the following: "Principal": {"AWS": ["111111111111", "222222222222", "999999999999"]} 7. Choose Update. 8. Choose the Configuration details tab. 9. Choose the copy icon that is next to the monitoring account's sink ARN. 10. Sign in to the account that you want to use as a new source account. 11. Paste the monitoring account's sink ARN that you copied in Step 9. Manage monitoring accounts and source accounts 2429 Amazon CloudWatch User Guide You see the CloudWatch settings page, with some information filled in. 12. For Select data, choose whether this source account will send Logs, Metrics, Traces, and Application Insights - Applications, Internet Monitor - Monitors, and Application Signals - Services, Service Level Objectives (SLOs) data to the monitoring accounts it is linked to. 13. Do not change the ARN in Enter monitoring account configuration ARN. 14. The Define a label to identify your source account section is pre-filled with the label choice from the monitoring account, if there is one. Optionally, choose Edit to change it. Note In the AWS GovCloud (US-East) and AWS GovCloud (US-West) Regions, the only supported option is to use custom labels, and the $AccountName, $AcccountEmail, and $AcccountEmailNoDomain variables all resolve as account-id instead of the specified variable. 15. Choose Link. 16. Enter Confirm in the box and choose Confirm. Remove the link between a monitoring account and source account Follow the steps in this section to stop sending data from one source account to a monitoring account. You must have the permissions required to manage a source account to complete this task. For more information, see Necessary permissions. To remove the link between a source account and a monitoring account 1. Sign in to the source account. 2. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 3. In the left navigation pane, choose Settings. 4. By Source account information, choose View monitoring accounts. 5. Select the check box next to the monitoring account that you want to stop sharing data with. 6. Choose Stop sharing data, Confirm. 7. Sign in to the monitoring account. Manage monitoring accounts and source accounts 2430 Amazon CloudWatch User Guide 8. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 9. Choose Settings. 10. By Monitoring account information, choose View configuration. 11. In the Policy box, delete the source account ID from the Principal line and choose Update. View information about a monitoring account Follow the steps in this section to view the cross-account settings for a monitoring account. To manage a monitoring account, you must have certain permissions. For more information, see Necessary permissions. To manage a monitoring account 1. Sign in to the monitoring account. 2. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 3. In the left navigation pane, choose Settings. 4. By Monitoring account configuration, choose Manage source accounts. 5. 6. 7. To view the Observability Access Manager policy that enables this account to be a monitoring account, choose the Configuration policy tab. To view the source accounts that are linked to this monitoring account, choose the Linked source accounts tab. To view the monitoring account sink ARN, and the types of data that this monitoring account can view in linked source accounts, choose the Linked source accounts tab. Cross-account cross-Region CloudWatch console Note We recommend that you use CloudWatch cross-account observability to get the richest cross-account observability and discovery experience for your metrics, logs, and traces within a Region. For more information, see CloudWatch cross-account observability. The cross-account, cross-Region CloudWatch console allows you to easily switch between different accounts and Region by using selectors in the console to view the dashboards, alarms, and metrics Cross-account cross-Region CloudWatch console 2431 Amazon CloudWatch User Guide in other accounts and Regions. This feature also allows you to create cross-account, cross-Region dashboards which summarize your CloudWatch metrics from multiple AWS accounts and multiple Regions into a single dashboard, making them accessible without having to switch accounts or Regions. Many organizations have their AWS resources deployed in multiple accounts, to provide billing and security boundaries. In this case, we recommend that you designate one or more of your accounts as your monitoring accounts, and build your cross-account cross-Region dashboards in these accounts. Cross-account cross-Region console functionality is integrated with AWS Organizations, to help you efficiently build your cross-account cross-Region dashboards. The cross-account, cross-region CloudWatch console experience does not provide cross-account cross-Region visibility for logs. Additionally, it does not support the
acw-ug-694
acw-ug.pdf
694
AWS accounts and multiple Regions into a single dashboard, making them accessible without having to switch accounts or Regions. Many organizations have their AWS resources deployed in multiple accounts, to provide billing and security boundaries. In this case, we recommend that you designate one or more of your accounts as your monitoring accounts, and build your cross-account cross-Region dashboards in these accounts. Cross-account cross-Region console functionality is integrated with AWS Organizations, to help you efficiently build your cross-account cross-Region dashboards. The cross-account, cross-region CloudWatch console experience does not provide cross-account cross-Region visibility for logs. Additionally, it does not support the creation of alarms on metrics in other accounts or Regions from within a monitoring account. Topics • Enabling cross-account cross-Region functionality in CloudWatch • (Optional) Integrate with AWS Organizations • Troubleshooting your CloudWatch cross-account setup • Disabling and cleaning up after using cross-account Enabling cross-account cross-Region functionality in CloudWatch To set up cross-account cross-Region functionality in your CloudWatch console, use the CloudWatch console to set up your sharing accounts and monitoring accounts. Set up a sharing account You must enable sharing in each account that will make data available to the monitoring account. This will grant the read-only permissions that you choose in step 5 to all users that view a cross account dashboard in the account that you share with, if the user has corresponding permissions in the account that you share with. To enable your account to share CloudWatch data with other accounts 1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 2. In the navigation pane, choose Settings. Enabling cross-account cross-Region functionality 2432 Amazon CloudWatch User Guide 3. 4. For Share your CloudWatch data, choose Configure. For Sharing, choose Specific accounts and enter the IDs of the accounts that you want to share data with. Any accounts that you specify here can view your account's CloudWatch data. Specify the IDs only of accounts that you know and trust. 5. For Permissions, specify how to share your data with one of the following options: • Provide read-only access to your CloudWatch metrics, dashboards, and alarms. This option enables the monitoring accounts to create cross-account dashboards that include widgets that contain CloudWatch data from your account. • Include CloudWatch automatic dashboards. If you select this option, users in the monitoring account can also view the information in this account's automatic dashboards. For more information, see Getting started with CloudWatch automatic dashboards. • Include X-Ray read-only access for the X-Ray Trace Map. If you select this option, users in the monitoring account can also view the X-Ray trace map and X-Ray trace information in this account. For more information, see Using the X-Ray Trace Map. • Full read-only access to everything in your account. This option enables the accounts that you use for sharing to create cross-account dashboards that include widgets that contain CloudWatch data from your account. It also enables those accounts to look deeper into your account and view your account's data in the consoles of other AWS services. 6. Choose Launch CloudFormation template. In the confirmation screen, type Confirm, and choose Launch template. 7. Select the I acknowledge... check box, and choose Create stack. Sharing with an entire organization Completing the preceding procedure creates an IAM role which enables your account to share data with one account. You can create or edit an IAM role that shares your data with all accounts in an organization. Do this only if you know and trust all accounts in the organization. This will grant the read-only permissions listed in the policies shown in step 5 of the previous procedure to all users that view a cross-account dashboard in the account that you share with, if the user has corresponding permissions in the account that you share with. Enabling cross-account cross-Region functionality 2433 Amazon CloudWatch User Guide To share your CloudWatch account data with all accounts in an organization 1. If you haven't already, complete the preceding procedure to share your data with one AWS account. 2. Sign in to the AWS Management Console and open the IAM console at https:// console.aws.amazon.com/iam/. In the navigation pane, choose Roles. In the list of roles, choose CloudWatch-CrossAccountSharingRole. 3. 4. 5. Choose Trust relationships, Edit trust relationship. You see a policy like this: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012:root" }, "Action": "sts:AssumeRole" } ] } 6. Change the policy to the following, replacing org-id with the ID of your organization. { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "*" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "aws:PrincipalOrgID": "org-id" } } Enabling cross-account cross-Region functionality 2434 Amazon CloudWatch User Guide } ] } 7. Choose Update Trust Policy. Set up a monitoring account Enable each monitoring account if you want to view cross-account CloudWatch data. When you complete
acw-ug-695
acw-ug.pdf
695
relationship. You see a policy like this: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012:root" }, "Action": "sts:AssumeRole" } ] } 6. Change the policy to the following, replacing org-id with the ID of your organization. { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "*" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "aws:PrincipalOrgID": "org-id" } } Enabling cross-account cross-Region functionality 2434 Amazon CloudWatch User Guide } ] } 7. Choose Update Trust Policy. Set up a monitoring account Enable each monitoring account if you want to view cross-account CloudWatch data. When you complete the following procedure, CloudWatch creates a service-linked role that CloudWatch uses in the monitoring account to access data shared from your other accounts. This service-linked role is called AWSServiceRoleForCloudWatchCrossAccount. For more information, see Using service-linked roles for CloudWatch. To enable your account to view cross-account CloudWatch data 1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 2. In the navigation pane, choose Settings, and then, in the Cross-account cross-region section, choose Configure. 3. Under the View cross-account cross-region section, choose Enable, and then select the Show selector in the console checkbox to enable an account selector to appear in the CloudWatch console when you're graphing a metric or creating an alarm. 4. Under View cross-account cross-region, choose one of the following options: • Account Id Input. This option prompts you to manually input an account ID each time that you want to switch accounts when you view cross-account data. • AWS Organization account selector. This option causes the accounts that you specified when you completed your cross-account integration with Organizations to appear. When you next use the console, CloudWatch displays a dropdown list of these accounts for you to select from when you are viewing cross-account data. To do this, you must have first used your organization management account to allow CloudWatch to see a list of accounts in your organization. For more information, see (Optional) Integrate with AWS Organizations. Enabling cross-account cross-Region functionality 2435 Amazon CloudWatch User Guide • Custom account selector. This option prompts you to enter a list of account IDs. When you next use the console, CloudWatch displays a dropdown list of these accounts for you to select from when you are viewing cross-account data. You can also enter a label for each of these accounts to help you identify them when choosing accounts to view. The account selector settings that a user makes here are retained only for that user, not for all other users in the monitoring account. 5. Choose Enable. After you complete this setup, you can create cross-account dashboards. For more information, see Creating a customized CloudWatch dashboard. Cross-Region functionality Cross-Region functionality is built in to this feature automatically. You do not need to take any extra steps to be able to display metrics from different Regions in a single account on the same graph or the same dashboard. Cross-Region functionality is not supported for alarms, so you can't create an alarm in one Region that watches a metric in a different Region. (Optional) Integrate with AWS Organizations If you want to integrate cross-account functionality with AWS Organizations, you must make a list of all accounts in the organization available to the monitoring accounts. To enable cross-account CloudWatch functionality to access a list of all accounts in your organization 1. Sign in to your organization's management account. 2. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 3. 4. In the navigation pane, choose Settings, then choose Configure. For Grant permission to view the list of accounts in the organization, choose Specific accounts to be prompted to enter a list of account IDs. The list of accounts in your organization are shared with only the accounts that you specify here. 5. Choose Share organization account list. 6. Choose Launch CloudFormation template. (Optional) Integrate with AWS Organizations 2436 Amazon CloudWatch User Guide In the confirmation screen, type Confirm, and choose Launch template. Troubleshooting your CloudWatch cross-account setup This section contains troubleshooting tips for cross-account, console deployment in CloudWatch. I am getting access denied errors displaying cross-account data Check the following: • Your monitoring account should have a role named AWSServiceRoleForCloudWatchCrossAccount. If it does not, you need to create this role. For more information, see Set Up a Monitoring Account. • Each sharing account should have a role named CloudWatch-CrossAccountSharingRole. If it does not, you need to create this role. For more information, see Set Up A Sharing Account. • The sharing role must trust the monitoring account. To confirm that your roles are set up properly for the CloudWatch cross-account console 1. Sign in to the AWS Management Console and open the IAM console at https:// 2. 3. 4. console.aws.amazon.com/iam/. In the navigation pane, choose Roles. In the list of roles, make sure the needed role exists. In
acw-ug-696
acw-ug.pdf
696
this role. For more information, see Set Up a Monitoring Account. • Each sharing account should have a role named CloudWatch-CrossAccountSharingRole. If it does not, you need to create this role. For more information, see Set Up A Sharing Account. • The sharing role must trust the monitoring account. To confirm that your roles are set up properly for the CloudWatch cross-account console 1. Sign in to the AWS Management Console and open the IAM console at https:// 2. 3. 4. console.aws.amazon.com/iam/. In the navigation pane, choose Roles. In the list of roles, make sure the needed role exists. In a sharing account, look for CloudWatch-CrossAccountSharingRole. In a monitoring account, look for AWSServiceRoleForCloudWatchCrossAccount. If you are in a sharing account and CloudWatch-CrossAccountSharingRole already exists, choose CloudWatch-CrossAccountSharingRole. 5. Choose Trust relationships, Edit trust relationship. 6. Confirm that the policy lists either the account ID of the monitoring account, or the organization ID of an organization that contains the monitoring account. I don't see an account dropdown in the console First, check that you have created the correct IAM roles, as discussed in the preceding troubleshooting section. If those are set up correctly, make sure that you have enabled this Troubleshooting 2437 Amazon CloudWatch User Guide account to view cross-account data, as described in Enable Your Account to View Cross-Account Data. Disabling and cleaning up after using cross-account To disable cross-account functionality for CloudWatch, follow these steps. Step 1: Remove the cross-account stacks or roles The best method is to remove the AWS CloudFormation stacks that were used to enable cross- account functionality. • In each of the sharing accounts, remove the CloudWatch-CrossAccountSharingRole stack. • If you used AWS Organizations to enable cross-account functionality with all accounts in an organization, remove the CloudWatch-CrossAccountListAccountsRole stack in the organization's management account. If you didn't use the AWS CloudFormation stacks to enable cross-account functionality, do the following: • In each of the sharing accounts, delete the CloudWatch-CrossAccountSharingRole IAM role. • If you used AWS Organizations to enable cross-account functionality with all accounts in an organization, delete the CloudWatch-CrossAccountSharing-ListAccountsRole IAM role in the organization's management account. Step 2: Remove the service-linked role In the monitoring account, delete the AWSServiceRoleForCloudWatchCrossAccount service-linked IAM role. Disabling and cleaning up after using cross-account 2438 Amazon CloudWatch User Guide Explore related telemetry Computer systems can generate a large amount of telemetry, including both metrics and logs, and complex systems even more so. When looking at a specific set of telemetry, it can be a challenge to find other telemetry related to your initial set. It can take advanced training to gain the skills needed to find issues and troubleshoot them. Because systems are complex, understanding what is going on can involve viewing metrics and logs from many different services and resources, requiring context switching and navigating between systems. The Amazon CloudWatch Explore related feature offers access to AWS resource relationships, related metrics, and logs across service consoles, enhancing observability and efficiency for operators of all skill levels. When viewing alarms or anomalies in CloudWatch dashboards, or metrics in AWS, users can quickly find and view metrics and logs for related resources in your system. CloudWatch provides visibility into metrics and logs tied to specific resources, and the Explore related pane extends that by allowing you to correlate your infrastructure resources to your workloads with all of their associated telemetry. This gives you quick access to the information you need to troubleshoot infrastructure-related issues. You view the relationship between resources, and their related telemetry in the Explore related pane. The Explore related pane is accessed from CloudWatch or from other AWS consoles showing resources or telemetry. Note Explore related is currently limited in accounts set up as monitoring accounts in CloudWatch cross-account observability. You should access Explore related from the source accounts where the resources are originally created and managed. In source accounts, you can navigate between connected resources, and view related logs and metrics. The following topics discuss the details of exploring related telemetry. Topics • What is related telemetry? • How to access the Explore related pane • Navigating related telemetry 2439 Amazon CloudWatch • Using the topology map • Finding a specific resource • Permissions and prerequisites needed to view and explore related telemetry • How does CloudWatch find related telemetry? • AWS services that support related telemetry • How to add related information to custom telemetry sent to CloudWatch User Guide What is related telemetry? Related telemetry is metrics and log data from resources that are related to the current resource or service. Traditionally, you might look at the metrics and logs that are related to a single load balancer, or all telemetry related to Amazon EC2. The Explore related feature in Amazon CloudWatch adds an interactive topology map. The map is a resource-centric view where you can
acw-ug-697
acw-ug.pdf
697
view and explore related telemetry • How does CloudWatch find related telemetry? • AWS services that support related telemetry • How to add related information to custom telemetry sent to CloudWatch User Guide What is related telemetry? Related telemetry is metrics and log data from resources that are related to the current resource or service. Traditionally, you might look at the metrics and logs that are related to a single load balancer, or all telemetry related to Amazon EC2. The Explore related feature in Amazon CloudWatch adds an interactive topology map. The map is a resource-centric view where you can find metrics and logs for a specific resource, but you can also see how that resource is connected to other resources. For example, if you are looking at the telemetry for a load balancer in the Explore related pane, besides the metrics and logs associated with that load balancer, the maps shows you the target groups for that load balancer. Selecting one of the target groups will then show you the Amazon EC2 instances associated with that target group. At each step in this process, the telemetry, including metrics and logs, for the selected resources are shown, making it easy to quickly find the telemetry you are looking for, or to explore the telemetry, looking for the cause of a specific issue. How to access the Explore related pane Within the CloudWatch console, there are multiple ways to access telemetry related to your current view. For example, if you are looking at a graph on a dashboard, and you want to view telemetry related to that graph or an aspect of the graph, you can choose to explore related data directly from that graph. From many places in the console, you can choose an Explore related menu item, or select a compass icon ( to show the Explore related pane. You can access the exploring experience from entry points throughout the CloudWatch console (and other AWS consoles), including: What is related telemetry? ) 2440 Amazon CloudWatch User Guide • Metrics navigation – When you choose Metrics then All metrics from the CloudWatch console left hand menu, the tile for any supported service or metric source will show the compass icon that brings up related telemetry in the bottom right corner. • Metric legend – When viewing any metric graph (in CloudWatch or other AWS consoles), hovering over the legend of the graph shows information about the data, as well as an Explore related button that brings up the related telemetry. • Metric datapoints – When viewing any metric graph, hovering over a datapoint in the graph shows information about the metric, as well as a compass icon, to bring up the related telemetry. • Metric search – When searching for metrics in CloudWatch, if you choose a found metric name, you can select Explore related from the menu that pops up, which will bring up the related telemetry. • Console toolbar – In many AWS console pages, the console toolbar (usually in the upper right of the console) includes a CloudWatch service icon, which will bring up CloudWatch tools, including the Explore related pane. Depending on where you access the pane from, the default context of the pane will show an appropriate filter, if possible. Navigating related telemetry When you select any of the entry points to the Explore related pane, it appears on the right side of the CloudWatch console. This pane gives you access to view and find telemetry related to entities, in your system. An entity is a resource, such as an Amazon EC2 instance, or a service, such as an application that you have built. You can work within this pane without interrupting your current workflow, because it opens to the side of your initial page. The following image shows the Explore related pane focused on a single Amazon EC2 instance, and the associated entities. Navigating related telemetry 2441 Amazon CloudWatch User Guide The top of the Explore related pane is a visual topology map (map) of the current entity and other related entities. The currently selected entity sets the focus for the pane. There are two ways to select an entity. • Topology map – The map is a visual display of the current entity with focus. It also displays any related entities, allowing you to navigate around the set of resources and services that are related to each other. • Find other resources – You can use the Find other resources button to filter and search for entities to use as the focus. The bottom part of the pane shows you an automated search of metrics and logs for the current focal entity. By default, the focus is set to an entity matching the location from which you accessed the Explore related pane. For
acw-ug-698
acw-ug.pdf
698
The map is a visual display of the current entity with focus. It also displays any related entities, allowing you to navigate around the set of resources and services that are related to each other. • Find other resources – You can use the Find other resources button to filter and search for entities to use as the focus. The bottom part of the pane shows you an automated search of metrics and logs for the current focal entity. By default, the focus is set to an entity matching the location from which you accessed the Explore related pane. For example, if you accessed it by clicking the compass icon associated with a metric from a specific Amazon EC2 instance, then the focus will be set to that Amazon EC2 instance. Navigating related telemetry 2442 Amazon CloudWatch User Guide When you select an AWS resource for the focus in the Explore related pane, you can navigate to the resource-specific console for the selected resource. For example, if you have selected an Amazon EC2 instance, you can select the View in EC2 console link to open the Amazon EC2 console with that instance selected. When you set a focus, the metrics and logs are automatically filtered to show the telemetry related to your focus. • Metrics – Each metric is shown as a graph for the time period that you have chosen. Much like any dashboard graph in CloudWatch, you can hover over or select a graph to get more information about the metric graph, and to see options including viewing in CloudWatch metrics. Choosing to view in CloudWatch will open the metrics view with the same viewing context as the Explore related pane, including resource and time range. • Log patterns – CloudWatch analyzes the log groups associated with the focal resource and shows common patterns in those logs. For more information about log patterns, see Pattern analysis in the Amazon CloudWatch Logs User Guide. You can select Compare timerange to choose another time range and compare logs across the two time ranges. You can select View in Logs Insights to analyze the logs in CloudWatch Logs Insights with the same options as your current view, including resource, log group, and time range. For more information, see Analyzing log data with CloudWatch Logs Insights in the Amazon CloudWatch Logs User Guide. • Log groups – The log groups that contain the logs are shown. You can select the log groups and then perform one of the following actions: • Choose Start tailing in Live Tail to view a streaming list of new log events as they are ingested for the selected log groups. The Live Tail session is started in the CloudWatch console. For more information on Live Tail, see Troubleshoot with CloudWatch Logs LiveTail in the Amazon CloudWatch Logs User Guide. • Choose Query in Logs Insights to open Logs Insights with a query scoped to just those log groups, applying your current context, including resources and time range. Navigating related telemetry 2443 Amazon CloudWatch User Guide Using the topology map The topology map (map) is a visual display of the current focal entity and its related resources or services. You can use this interactive visualization to see the connections between different resources and services, and explore the relationships between components in your system. For example, if you are viewing load balancer resource, the map will show connected target group resources. Selecting a target group will display the associated instances. The visualization of connectivity helps operators understand and explore the relationships between different resources and services in your system. You can drag the map, and zoom in and out, to see more of the associated entities, or to focus on fewer entities. When you select an associated entity, like a target group, the pane's focus shifts to show telemetry for that entity. The map updates to center on the selected target group, displaying its connections to other entities, such as the load balancer and and any Amazon EC2 instances that are specified in that target group. As you navigate through different entities in the map, the metrics and logs at the bottom of the pane dynamically update, providing you with relevant telemetry for the newly selected resources. Finding a specific resource If a resource doesn't appear on the topology map, you can use the Find other resources feature to locate it. You can filter resources by tag or type, then select the ones you are looking for. After you have found resources to focus on, you are returned to the topology map, with those resources selected, to browse associated entities and telemetry. Note There are many reasons why you might not see your resources on the topology map. For example: • It's not related to the current focal entity.
acw-ug-699
acw-ug.pdf
699
with relevant telemetry for the newly selected resources. Finding a specific resource If a resource doesn't appear on the topology map, you can use the Find other resources feature to locate it. You can filter resources by tag or type, then select the ones you are looking for. After you have found resources to focus on, you are returned to the topology map, with those resources selected, to browse associated entities and telemetry. Note There are many reasons why you might not see your resources on the topology map. For example: • It's not related to the current focal entity. • You don't have permissions to access associated entities or telemetry. • The resource or service may not support telemetry or associated entities. Using the topology map 2444 Amazon CloudWatch User Guide By using Find other resources, you can discover and visualize resources that may not be directly connected or visible in the current map. This ensures that you can access and analyze all relevant components of your infrastructure. Select a resource with Find resources. 1. Open the Explore related pane from any of the entry points in the CloudWatch console. 2. Choose Find resources. 3. Choose the time frame for which you want to view logs or metrics. 4. Choose Resource types, then select the type of the resource you want to focus on from the drop down list, for example, EC2 instances. 5. Optionally, filter the set of resources by providing a tag to filter on. You can do this by selecting the Filter resources by tags filter, or by choosing the label that says 5 tags found (the number will depend on the tags in your system). This gives you a list of tags to choose from. After you have selected the tags, the list of resources is automatically filtered to only those that are associated with those tags. 6. Optionally, choose one or more specific resources from the ones found that match your filters. 7. Choose Show on map to return to the Topology map with your resources selected. Your list of Metrics and Logs is now filtered to just logs and metrics that are associated with that resource type. You can choose the Metrics or Logs tab to view the kind of telemetry that you want to view. Permissions and prerequisites needed to view and explore related telemetry To explore related telemetry, you must be getting entity information with the telemetry from your workloads, and you must have the proper permissions to view that data. Many services send entity information automatically. For workloads that use the CloudWatch agent, you must have at least version 1.300049.1 of the agent, and you must configure it correctly. For information about configuring the agent, see How to add related information to custom telemetry sent to CloudWatch. For workloads running on Amazon EKS, you must have at Prerequisites 2445 Amazon CloudWatch User Guide least version v2.3.1-eksbuild.1 of the Amazon CloudWatch Observability EKS add-on. For more information about this add-on, see Quick start with the Amazon CloudWatch Observability EKS add-on. To explore related telemetry you must be signed in with certain permissions. Exploring related telemetry is a read-only activity, and requires at least read-only access to CloudWatch. The permissions needed for viewing associations between telemetry and entities are: logs:ListLogGroupsForEntity, logs:ListEntitiesForLogGroup, cloudwatch:ListEntitiesForMetric, and application- signals:ListObservedEntities. Each of the following AWS managed policies will provide the CloudWatch permissions needed to access related telemetry in the CloudWatch console: • CloudWatchFullAccessV2 – Provides full access to CloudWatch. • CloudWatchReadOnlyAccess – Provides read-only access to CloudWatch. • ReadOnlyAccess – Provides read-only access to AWS services and resources. Additionally, you must have at least read-only access (Describe* and Get*) to any resources in the topology map, in order for CloudWatch to discover and display relationships. For more details about using policies to control access, see Managing access using policies. How does CloudWatch find related telemetry? The CloudWatch Explore related pane shows you metrics and logs that are related to each other, but how does that work? Metrics and logs that are sent to CloudWatch can include an optional entity to which they are related. Typically, the entity will be a representation of what the telemetry is about. For example, a metric about CPU usage is about an Amazon EC2 instance, and will use that instance as its entity. When you view that metric in the Explore related pane, it shows you other telemetry for that same instance. The topology map (map) in the Explore related pane displays the currently selected resource, along with related resources. For AWS resources, CloudWatch automatically displays other resources that How does CloudWatch find related telemetry? 2446 Amazon CloudWatch User Guide it knows are related. For example, if you are viewing an Amazon EC2 instance, the map will also display any Amazon EBS
acw-ug-700
acw-ug.pdf
700
For example, a metric about CPU usage is about an Amazon EC2 instance, and will use that instance as its entity. When you view that metric in the Explore related pane, it shows you other telemetry for that same instance. The topology map (map) in the Explore related pane displays the currently selected resource, along with related resources. For AWS resources, CloudWatch automatically displays other resources that How does CloudWatch find related telemetry? 2446 Amazon CloudWatch User Guide it knows are related. For example, if you are viewing an Amazon EC2 instance, the map will also display any Amazon EBS volumes that are attached to the instance. Selecting a volume shows telemetry for the volume, and the map is updated to display resources related to the volume. It also displays resources that are part of the same service. The entity information associated with your telemetry defines the resource that the telemetry is associated with, such as the Amazon EC2 instance. However, it can also include contextual data about the resource. For example, if you have a website application that includes resources such as an Amazon EC2 instance and a database, the entity information can include the website application as a service. In this case, the topology map shows the service as a related entity, and when you select it, it displays the instances and database. This can make finding all the telemetry for a service simpler. Note CloudWatch must have received telemetry with entity information within the last three hours in order to find related resources and telemetry. Where does the entity data come from? There are different ways that CloudWatch gets entities for telemetry: • Most telemetry sent to CloudWatch from AWS services are associated with resources automatically. For a complete list of supported resources, see AWS services that support related telemetry. • The CloudWatch agent automatically adds entity information to the telemetry that it sends to CloudWatch. Note You may need to update your CloudWatch agent to the latest version to include entity data. For more information, see Collect metrics, logs, and traces with the CloudWatch agent, and Configure CloudWatch agent service and environment names for related entities. • When you are submitting your own telemetry, you can add entity information to the data. For more information, see How to add related information to custom telemetry sent to CloudWatch. Where does the entity data come from? 2447 Amazon CloudWatch User Guide • CloudWatch makes a best effort to recognize the entity information associated with other telemetry (for example, custom telemetry that you send to CloudWatch without any entity information). Where does service data come from? Besides recognizing the natural connections between resources, such as an instance resource and an attached volume resource, CloudWatch can also group resources by service. For example, a service might be a website application. An Amazon EC2 instance with a web server, and another with a database might both be part of the same service, and are connected on the topology map based on that service. There are different ways that CloudWatch gets a service name for telemetry, including: • Application signals or otel instrumented telemetry use the OTEL_SERVICE_NAME environment variable used by supported OpenTelemetry instrumentation libraries to set the service name. • The CloudWatch agent configuration allows configuring a service name. For more information, see Configure CloudWatch agent service and environment names for related entities. • Kubernetes workloads use a corresponding name from the cluster, such as the Deployment, ReplicaSet, Pod, or Container, for the service name. • For Amazon EC2 workloads, the service can come from tags (the service, application, or app tags). Note To use tags to generate service names, you must first set up instance metadata for the Amazon EC2 instance. • When you are submitting your own telemetry, you can add service information to the data. For more information, see How to add related information to custom telemetry sent to CloudWatch. • When it cannot use the above, CloudWatch uses the name of the IAM role that sends the metrics as the service name. This, for example, can provide a service name for Amazon ECS telemetry. Where does service data come from? 2448 Amazon CloudWatch User Guide AWS services that support related telemetry The following table lists the AWS services that support related entity information in their CloudWatch telemetry. Services or resources that are not listed in the table do not have related entity information exposed in CloudWatch. Note For services that use the CloudWatch agent, you may need to update the agent to the latest version to get related telemetry. For information about sending related entity information with your own custom metrics, see How to add related information to custom telemetry sent to CloudWatch. AWS Service Resource Metrics Logs Amazon API Gateway AWS::ApiG ateway::Method Amazon API Gateway AWS::ApiG
acw-ug-701
acw-ug.pdf
701
that support related telemetry The following table lists the AWS services that support related entity information in their CloudWatch telemetry. Services or resources that are not listed in the table do not have related entity information exposed in CloudWatch. Note For services that use the CloudWatch agent, you may need to update the agent to the latest version to get related telemetry. For information about sending related entity information with your own custom metrics, see How to add related information to custom telemetry sent to CloudWatch. AWS Service Resource Metrics Logs Amazon API Gateway AWS::ApiG ateway::Method Amazon API Gateway AWS::ApiG Yes Yes ateway::R esource Amazon API Gateway AWS::ApiG Yes ateway::R estApi Amazon API Gateway AWS::ApiG ateway::Stage Amazon API Gateway AWS::ApiG ateway::V pcLink Amazon API Gateway V2 AWS::ApiG atewayV2: :Integration Yes Yes Yes No No No Yes No No AWS services that support related telemetry 2449 Amazon CloudWatch User Guide AWS Service Resource Metrics Amazon API Gateway V2 AWS::ApiG atewayV2: :Route Amazon API Gateway V2 AWS::ApiG atewayV2: :Stage Amazon API Gateway V2 AWS::ApiG atewayV2::Api AWS App Runner AWS::AppR unner::Service AWS Application Migration Service AWS::MGN: :SourceServer Amazon AppStream 2.0 AWS::AppS tream::Fleet AWS AppSync AWS::AppS ync::Grap hQLApi AWS B2B Data Interchange AWS::B2BI ::Transformer AWS Backup gateway AWS::Back Amazon Bedrock upGateway ::Hypervisor AWS::Bedr ock::Know ledgeBase Yes No Yes No Yes Yes Yes No No No Amazon Bedrock AWS::Bedr Yes ock::ModelId Logs No Yes No Yes No Yes Yes Yes Yes Yes No AWS services that support related telemetry 2450 Amazon CloudWatch User Guide AWS Service Resource Metrics Amazon Chime Amazon Chime AWS Clean Rooms AWS::Chim e::SipMed iaApplication AWS::Chim e::VoiceC onnector AWS::Clea nRooms::M embership AWS CloudFormation AWS CloudFormation Hooks Amazon CloudFront AWS::Clou AWS CloudTrail dFront::D istribution AWS::Clou dTrail::E ventDataStore AWS CloudTrail AWS::Clou dTrail::Trail Amazon CloudWatch AWS::Clou dWatch::M etricStream Amazon CloudWatch Evidently AWS::Evid ently::Project Amazon CloudWatch Logs AWS::Logs ::LogGroup No No No No No Yes No No Yes No Yes Logs Yes Yes Yes Yes Yes Yes Yes Yes No Yes No AWS services that support related telemetry 2451 Amazon CloudWatch User Guide AWS Service Resource Metrics Amazon CloudWatch RUM AWS::RUM: :AppMonitor Amazon CloudWatch Synthetics AWS::Synt hetics::Canary AWS CodeBuild AWS::Code Build::Project Amazon CodeWhisp erer AWS::Code Whisperer ::Customi zation No Yes Yes No Amazon Cognito user pools AWS::Cogn Yes ito::UserPool AWS Config AWS::Conf ig::ConfigRule Amazon Connect AWS::Conn ect::Instance AWS Database Migration Service AWS Database Migration Service AWS DataSync AWS DataSync AWS::DMS: :Replicat ionInstance AWS::DMS: :Replicat ionTask AWS::Data sync::Agent AWS::Data Sync::Task No No Yes Yes Yes Yes Logs Yes No No Yes Yes Yes Yes No No No Yes AWS services that support related telemetry 2452 Amazon CloudWatch User Guide AWS Service Resource Metrics AWS Directory Service AWS::Dire ctoryServ ice::Micr osoftAD Amazon DynamoDB AWS::Dyna moDB::Table DynamoDB Accelerat or AWS::DAX: :Cluster Amazon EC2 Amazon EC2 Amazon EC2 Amazon EC2 Amazon EC2 Amazon EC2 Amazon EC2 AWS::EC2: :Capacity Reservation AWS::EC2: :Instance AWS::EC2: :FlowLog AWS::EC2: :NATGateway AWS::EC2: :NetworkI nterface AWS::EC2: :Subnet AWS::EC2: :TransitG ateway No Yes Yes Yes Yes Yes Yes Yes Yes Yes Logs Yes No No No No No No Yes Yes No AWS services that support related telemetry 2453 Amazon CloudWatch User Guide AWS Service Resource Metrics Amazon EC2 Amazon EC2 Amazon EC2 AWS::EC2: :TransitG atewayAtt achment AWS::EC2: :Verified AccessInstance AWS::EC2: :Volume Amazon EC2 AWS::EC2::VPC Amazon EC2 AWS::EC2: :VPNConnection Amazon EC2 Auto Scaling AWS::Auto Scaling:: AutoScali ngGroup Yes No Yes No Yes Yes AWS Elastic Beanstalk AWS::Elas Yes ticBeanst alk::Envi ronment Amazon Elastic Container Service AWS::ECS: :Cluster Amazon Elastic Container Service AWS::ECS: :Service Amazon Elastic File System AWS::EFS: :AccessPoint Yes Yes Yes Logs Yes Yes No Yes Yes No No Yes Yes No AWS services that support related telemetry 2454 Amazon CloudWatch User Guide AWS Service Resource Metrics Logs Amazon Elastic File System AWS::EFS: :FileSystem Amazon Elastic File System AWS::EFS: :MountTarget Amazon Elastic Kubernetes Service AWS::EKS: :Cluster Amazon Elastic Kubernetes Service on AWS Fargate Elastic Load Balancing Elastic Load Balancing V2 Elastic Load Balancing V2 AWS::Elas ticLoadBa lancing:: LoadBalancer AWS::Elas ticLoadBa lancingV2 ::LoadBalancer AWS::Elas ticLoadBa lancingV2 ::TargetGroup Yes Yes Yes No Yes Yes Yes Amazon ElastiCache AWS::Elas Yes AWS Elemental MediaConvert tiCache:: CacheCluster AWS::Medi aConvert: :Queue Yes No No Yes Yes No No No Yes No AWS services that support related telemetry 2455 Amazon CloudWatch User Guide AWS Service Resource Metrics AWS Elemental MediaLive AWS Elemental MediaLive AWS::Medi aLive::Channel AWS Elemental MediaPackage AWS Elemental MediaStore AWS Elemental MediaTailor Amazon EMR AWS::Medi aPackage: :Channel AWS::Medi aStore::C ontainer AWS::EMR: :Cluster Amazon EventBridge AWS::Even ts::Rule Amazon EventBridge Pipes AWS::Pipe s::Pipe AWS Fault Injection Service Amazon FinSpace Amazon FSx AWS::FIS: :Experime ntTemplate AWS::FinS pace::Env ironment AWS::FSx: :FileSystem No Yes Yes Yes No Yes Yes Yes No No Yes Logs Yes No No Yes Yes Yes Yes Yes Yes Yes No AWS services that support related telemetry 2456 Amazon CloudWatch User Guide AWS Service Resource Metrics Amazon GameLift Servers AWS::Game Lift::Fleet AWS Glue
acw-ug-702
acw-ug.pdf
702
Service Resource Metrics AWS Elemental MediaLive AWS Elemental MediaLive AWS::Medi aLive::Channel AWS Elemental MediaPackage AWS Elemental MediaStore AWS Elemental MediaTailor Amazon EMR AWS::Medi aPackage: :Channel AWS::Medi aStore::C ontainer AWS::EMR: :Cluster Amazon EventBridge AWS::Even ts::Rule Amazon EventBridge Pipes AWS::Pipe s::Pipe AWS Fault Injection Service Amazon FinSpace Amazon FSx AWS::FIS: :Experime ntTemplate AWS::FinS pace::Env ironment AWS::FSx: :FileSystem No Yes Yes Yes No Yes Yes Yes No No Yes Logs Yes No No Yes Yes Yes Yes Yes Yes Yes No AWS services that support related telemetry 2456 Amazon CloudWatch User Guide AWS Service Resource Metrics Amazon GameLift Servers AWS::Game Lift::Fleet AWS Glue AWS::Glue::Job AWS Identity Sync Amazon Interactive Video Service AWS IoT AWS::Iden titySync: :Profile AWS::IVSC hat::Logg ingConfig uration AWS::IoT: :TopicRule AWS IoT 1-Click AWS::IoT1 Click::Device AWS IoT Analytics AWS IoT Events AWS IoT FleetWise AWS IoT SiteWise AWS::IoTF leetWise: :Vehicle AWS Key Managemen t Service AWS::KMS::Key Amazon Managed Service for Apache Flink AWS::Kine sisAnalyt ics::Appl ication Yes No No Yes Yes Yes No No No No Yes Yes Logs No Yes Yes Yes Yes No Yes Yes Yes Yes No Yes AWS services that support related telemetry 2457 Amazon CloudWatch User Guide AWS Service Resource Metrics Amazon Data Firehose AWS::Kine sisFireho se::Deliv eryStream Amazon Kinesis Data Streams AWS::Kine sis::Stream Amazon Kinesis Video Streams AWS::Kine sisVideo: :Stream AWS::Lamb da::Function AWS Lambda Amazon Lex AWS Mainframe Modernization AWS::M2:: Application Amazon Managed Streaming for Apache AWS::Kafk a::Cluster Kafka Amazon Managed Streaming for Apache Kafka Amazon Managed Streaming for Apache Kafka AWS::Kafk aConnect: :Connector AWS::MSK: :Cluster Amazon MemoryDB AWS::Mmem Amazon MQ orydb::Cluster AWS::Amaz onMQ::Broker Yes Yes Yes Yes No No Yes No Yes Yes Yes Logs Yes No No No Yes Yes No Yes Yes No Yes AWS services that support related telemetry 2458 Amazon CloudWatch User Guide AWS Service Resource Metrics AWS Network Firewall AWS::Netw orkFirewa ll::Firewall Amazon OpenSearch Service AWS::Open SearchSer vice::Domain Amazon OpenSearch Service Amazon OpenSearch Service Ingestion AWS::OSIS ::Pipeline AWS OpsWorks AWS::OpsW orks::Instance AWS OpsWorks AWS OpsWorks AWS Organizations AWS::OpsW orks::Layer AWS::OpsW orks::Stack AWS::Orga nizations ::Organization AWS Outposts AWS::Outp osts::Outpost Amazon Managed Service for Prometheus AWS::Prom etheus::R esource Amazon Q Business Yes Yes No No Yes Yes Yes No Yes Yes No Logs Yes No Yes Yes No No No Yes No No Yes AWS services that support related telemetry 2459 Amazon CloudWatch User Guide AWS Service Resource Metrics Logs Amazon QLDB AWS::QLDB ::Ledger Amazon QuickSight AWS::Quic Yes Yes ksight::D ashboard Amazon QuickSight AWS::Quic Yes ksight::D ataSet Amazon Redshift AWS::Reds Amazon Redshift Serverless hift::Cluster AWS::Reds hiftServe rless::Wo rkgroup Amazon Relational Database Service AWS::RDS: :DBCluster Amazon Relational Database Service AWS::RDS: :DBInstance AWS RoboMaker Amazon Route 53 Amazon Route 53 AWS::Robo Maker::Si mulationJob AWS::Rout e53::Heal thCheck AWS::Rout e53::Host edZone Yes Yes Yes Yes Yes Yes Yes No No No Yes No Yes Yes No Yes No AWS services that support related telemetry 2460 Amazon CloudWatch User Guide AWS Service Resource Metrics Amazon Route 53 Resolver AWS::Rout e53Resolv er::Resol verEndpoint Amazon S3 AWS::S3::Bucket Amazon SageMaker AI Amazon SageMaker AI AWS::Sage Maker::En dpoint AWS::Sage Maker::Wo rkteam Yes Yes Yes No AWS Service Catalog AWS::Serv Yes iceCatalo g::CloudF ormationP roduct Amazon Simple Email Service AWS::SES: :Configur Yes ationSet AWS::SNS::Topic Yes No AWS::SQS::Queue Yes Amazon Simple Notification Service Amazon Simple Notification Service Amazon Simple Queue Service AWS Step Functions AWS::Step Yes Functions ::Activity Logs No No No Yes No No Yes Yes No No AWS services that support related telemetry 2461 Amazon CloudWatch User Guide AWS Service Resource Metrics AWS Step Functions AWS::Step Yes AWS Storage Gateway AWS Storage Gateway Functions ::StateMachine AWS::Stor ageGatewa y::Gateway AWS::Stor ageGatewa y::Share AWS Transfer Family AWS::Tran sfer::Server Amazon VPC Lattice AWS::VpcL AWS WAFV2 Amazon WorkMail attice::S ervice AWS::WAFv 2::WebAcl AWS::Work Mail::Org anization Yes No Yes No No Yes Amazon WorkSpaces AWS::Work Yes Spaces::W orkspace Logs Yes No Yes Yes Yes Yes No Yes How to add related information to custom telemetry sent to CloudWatch When you publish your own metrics and logs to CloudWatch, the entity information needed for related telemetry is not there by default. When you send metrics to CloudWatch or logs Add related information to custom telemetry 2462 Amazon CloudWatch User Guide to CloudWatch Logs (with the PutMetricData or PutLogEvents operations), you can add entity information to those logs or metrics. The entity information is associated with the telemetry, and used in the Explore related feature to find related telemetry that is associated with the same entity. The entity sent with telemetry represents a resource or service that the telemetry is associated with. For example, a metric about a service, or that comes from an AWS resource. To identify the entity associated in your code, you create a set of KeyAttributes and optional Attributes of the entity. Note CloudWatch can only find related resources for entities that have had telemetry sent within the previous three hours. If your
acw-ug-703
acw-ug.pdf
703
logs or metrics. The entity information is associated with the telemetry, and used in the Explore related feature to find related telemetry that is associated with the same entity. The entity sent with telemetry represents a resource or service that the telemetry is associated with. For example, a metric about a service, or that comes from an AWS resource. To identify the entity associated in your code, you create a set of KeyAttributes and optional Attributes of the entity. Note CloudWatch can only find related resources for entities that have had telemetry sent within the previous three hours. If your resource only emits sparse telemetry (less than once every 3 hours), you may want to send additional heartbeat telemetry, to keep the entity active within CloudWatch. The following sections describe how to create the KeyAttributes and Attributes so that CloudWatch can identify the resources and services associated with the telemetry. Identifying the entity with the KeyAttributes object The KeyAttributes property of the Entity objects ( in CloudWatch or in CloudWatch logs) uniquely identifies the entity for CloudWatch. It is a list of key-value pairs. Entities with the same KeyAttributes are considered to be the same entity. Telemetry associated with the same entity are considered related, and can be easily found in the Explore related pane. Note In the CloudWatch API, the property is called KeyAttributes. In the CloudWatch Logs API, the property is called keyAttributes. Here they are treated as the same property. There are five possible types of object that an Entity can represent. • AWS::Resource – The entity represents an AWS resource, such as a DynamoDB table or Amazon EC2 instance. Entity KeyAttributes 2463 Amazon CloudWatch User Guide • AWS::Service – The entity represent an AWS service, such as Amazon S3. This might be used, for example, when calling the ListBuckets operation, which is not associated with a specific Amazon S3 resource. • Service – The entity represents a workload running in your account. For example, an application or service that you manage. • Resource – The entity represents a resource that is not managed by AWS, for example, operating system resources, such as processes or file volumes. • RemoteService – The entity represents an external service in a remote call. For example, a remote call to a database, external cache, or an external endpoint. Depending on which of the above types you are trying to represent, you must provide the correct key-value pairs for the KeyAttributes. The following describes each type. AWS::Resource To specify an AWS Resource, you must include the following three key value pairs: • "Type": "AWS::Resource" – This key-value pair identifies the entity as an AWS resource. • "ResourceType": "<resource-type>" – The string value of the ResourceType is the AWS CloudFormation resource type string. For example, AWS::DynamoDB::Table. • "Identifier": "<resource-id>" – The primary identifier for the resource. For more information, see primaryIdentifier in the Extension Development for CloudFormation User Guide. AWS::Service To specify an AWS Service, you must include the following two key value pairs: • "Type": "AWS::Service" – This key-value pair identifies the entity as an AWS service. • "Name": "<service-name>" – The value of the Name is the AWS CloudFormation service name string. For example, AWS::DynamoDB. Service To specify a service that is not operated by AWS, you must include the following three key value pairs: Entity KeyAttributes 2464 Amazon CloudWatch User Guide • "Type": "Service" – This key-value pair identifies the entity as a service. • "Name": "<service-name>" – This represents the name of the service that is sending the metrics. For example, my-service-frontend or api.myservice.com. • "Environment": "<environment-name>" – This attribute specifies where the service is hosted, or the environment to which it belongs. For example us-west-2, or myservice.production. Resource To specify a resource that is not provided by AWS, you must include the following three key value pairs: • "Type": "Resource" – This key-value pair identifies the entity as a resource. • "ResourceType": "<resource-type>" – A string specifying the type of resource. For example, K8s::Pod for a Kubernetes Pod. • "Identifier": "<resource-id>" – A string identifier for the resource. Can contain multiple names, separated by pipes. For example, a Kubernetes Pod might be represented by it's cluster name, namespace, and pod name, such as MyCluster|MyNamespace|MyPod. RemoteService To specify a remote service, you must include the following two key value pairs: • "Type": "RemoteService" – This key-value pair identifies the entity as a remote service. • "Name": "<remote-service-name>" – Specifies how the application refers to the external service in a remote call. For example, api.test.myservice.com. Providing additional details about the entity with the Attributes object You can provide additional details about the Entity that you provide with your telemetry. This can include details about the platform, resource, application, or telemetry provider. The following tables describes the key words that you
acw-ug-704
acw-ug.pdf
704
and pod name, such as MyCluster|MyNamespace|MyPod. RemoteService To specify a remote service, you must include the following two key value pairs: • "Type": "RemoteService" – This key-value pair identifies the entity as a remote service. • "Name": "<remote-service-name>" – Specifies how the application refers to the external service in a remote call. For example, api.test.myservice.com. Providing additional details about the entity with the Attributes object You can provide additional details about the Entity that you provide with your telemetry. This can include details about the platform, resource, application, or telemetry provider. The following tables describes the key words that you can use for each of these types of data. Entity Attributes 2465 Amazon CloudWatch Note User Guide In the CloudWatch API, the property is called Attributes. In the CloudWatch Logs API, the property is called attributes. Here they are treated as the same property. Platform details Keyword Usage Domain of Values Examples PlatformType Defines the hosted-in platform. AWS::EKS, AWS::ECS, AWS::EC2, AWS::EC2 AWS::Lambda, K8s, Generic EKS.Cluster K8s.Cluster K8s.Namespace K8s.Workload K8s.Node Name of the Amazon EKS cluster. Alphanumeric string with basic delimiters. FlyingSquad Name of the self- hosted Kubernetes Alphanumeric string with basic delimiters. minicube cluster. Name of Kubernete s namespace in Amazon EKS or K8s clusters. Name of Kubernetes workload in Amazon EKS and K8s clusters. Identity of Kubernete s node in Amazon EKS and K8s clusters. Alphanumeric string with basic delimiters. default, pet- clinic Alphanumeric string with basic delimiters. frontend K8s node name (for example, Amazon EC2 instance DNS name). ip-11-22- 33-44.ec2 .internal Entity Attributes 2466 Amazon CloudWatch Keyword K8s.Pod Usage Domain of Values Examples User Guide Identity of Kubernete s pod in Amazon EKS and K8s clusters. K8s pod identifier. frontend- 1234abcd56- ef7890 my-asg-name-1 EC2.AutoS calingGroup Name of the Amazon EC2 AutoScaling Alphanumeric string with basic delimiters. Group. EC2.InstanceId Identity of the Amazon EC2 instance. Amazon EC2 instance identifier. i-1234abc d5678ef90 ECS.Cluster ECS.Service ECS.Task Identity of the Amazon ECS cluster. Amazon ECS cluster name. MyCluster Identity of the Amazon ECS service. Amazon ECS service name. MyService Identity of the Amazon ECS task. Amazon ECS task ID. task-123abc Lambda.Function Identity of the Lambda function. Lambda function name. MyFunction Host Name of the host for all platform types. Sub-domain format. ip-111-22 -33-44.ex ample.com Resource details Keyword Usage Domain of Values Examples AWS.Resou rce.ARN ARN for the AWS resource. Alphanumeric string with basic delimiters. arn:aws:d ynamodb:u s-east-1: 123456789 Entity Attributes 2467 Amazon CloudWatch User Guide Keyword Usage Domain of Values Examples 012:table/ myDynamoDBTable Application details Keyword Usage Domain of Values Examples AWS.Application Name of the applicati on in AppRegistry. Alphanumeric string with basic delimiters. PetClinicApp AWS.Appli cation.ARN ARN of the applicati on in AppRegistry. Alphanumeric string with basic delimiters. arn:aws:s ervicecat alog:us-e ast-1:123 4567890:/ applicati ons/... Telemetry provider details Keyword Usage Domain of Values Examples Telemetry.SDK Telemetry.Agent The fingerprint of OTEL SDK version for instrumented services. The fingerprint of the Agent used to collect and send telemetry data. Alphanumeric string with basic delimiters. opentelem etry,1.32.0- aws-SNAPSHOT,ja va,Auto Alphanumeric string with basic delimiters. CWAgent/1 .300026.3 , ADOTColle ctor/1.x ClientSpan, JMX Telemetry .Source Specifies the point of application where ServerSpan, ClientSpan, Entity Attributes 2468 Amazon CloudWatch User Guide Keyword Usage Domain of Values Examples the telemetry was ProducerSpan, collected or what was used for the source of ConsumerSpan, LocalRoot Span, JMX, telemetry data. OS. Entity Attributes 2469 Amazon CloudWatch User Guide Query metrics from other data sources You can use CloudWatch to query, visualize, and create alarms for metrics from other data sources. To do so, you connect CloudWatch to the other data sources. This gives you a single, consolidated monitoring experience within the CloudWatch console. You can have a unified view of your infrastructure and application metrics regardless of where the data is stored, helping you identify and resolve issues faster. After you connect to a data source using a CloudWatch wizard, CloudWatch creates an AWS CloudFormation stack that deploys and configures an AWS Lambda function. This Lambda function runs on demand every time you query the data source. The CloudWatch query builder shows you in real time a list of elements that can be queried, such as metrics, tables, fields, or labels. As you make choices, the query builder pre-populates a query in the native language of the selected source. CloudWatch provides guided wizards for you to connect to the following data sources. For these data sources, you provide basic information to identify the data source and credentials. You can also manually create connectors to other data sources by creating your own Lambda functions. • Amazon OpenSearch Service– Derive metrics from your OpenSearch Service logs and traces. • Amazon Managed Service for Prometheus– Query these metrics using PromQL. • Amazon RDS for MySQL – Use SQL to convert data stored in your Amazon RDS tables into metrics. • Amazon RDS for PostgreSQL–
acw-ug-705
acw-ug.pdf
705
in the native language of the selected source. CloudWatch provides guided wizards for you to connect to the following data sources. For these data sources, you provide basic information to identify the data source and credentials. You can also manually create connectors to other data sources by creating your own Lambda functions. • Amazon OpenSearch Service– Derive metrics from your OpenSearch Service logs and traces. • Amazon Managed Service for Prometheus– Query these metrics using PromQL. • Amazon RDS for MySQL – Use SQL to convert data stored in your Amazon RDS tables into metrics. • Amazon RDS for PostgreSQL– Use SQL to convert data stored in your Amazon RDS tables into metrics. • Amazon S3 CSV files– Display metrics data from a CSV file stored in an Amazon S3 bucket. • Microsoft Azure Monitor– Query metrics from your Microsoft Azure Monitor account. • Prometheus– Query these metrics using PromQL. After you create connectors to data sources, see Creating a graph of metrics from another data source for information about graphing a metric from a data source. For information about setting an alarm on a metric from a data source, see Create an alarm based on a connected data source. Topics • Managing access to data sources 2470 Amazon CloudWatch User Guide • Connect to a prebuilt data source with a wizard • Create a custom connector to a data source • Use your custom data source • Delete a connector to a data source Managing access to data sources CloudWatch uses AWS CloudFormation to create the required resources in your account. We recommend that you use the cloudformation:TemplateUrl condition to control access to AWS CloudFormation templates when you grant CreateStack permissions to IAM users. Warning Any user that you grant data source invoke permission to can query metrics from that data source even if that user does not have direct IAM permissions to the data source. For example, if you grant lambda:InvokeFunction permissions on a Amazon Managed Service for Prometheus data source Lambda function to a user, that user will be able to query metrics from the corresponding Amazon Managed Service for Prometheus workspace even if you didn't grant them direct IAM access to that workspace. You can find template URLs for data sources on the Create stack page in the CloudWatch Settings Console. { "Version":"2012-10-17", "Statement":[ { "Effect" : "Allow", "Action" : [ "cloudformation:CreateStack" ], "Resource" : "*", "Condition" : { "StringEquals" : { "cloudformation:TemplateUrl" : [ data-source-template-url ] } } } ] Managing access to data sources 2471 Amazon CloudWatch } User Guide For more information about controlling AWS CloudFormation access, see Controlling access with AWS Identity and Access Management Connect to a prebuilt data source with a wizard This topic provides instructions for using the wizard to connect CloudWatch to the following data sources. • Amazon OpenSearch Service • Amazon Managed Service for Prometheus • Amazon RDS for MySQL • Amazon RDS for PostgreSQL • Amazon S3 CSV files • Microsoft Azure Monitor • Prometheus The subsections in this topic include notes about managing and querying with each of these data sources. To create a connector to a data source 1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 2. In the navigation pane, choose Settings. 3. Choose the Metrics data sources tab. 4. Choose Create data source. 5. 6. 7. Select the source that you want, then choose Next. Enter a name for the data source. Enter the other required information, depending on the data source that you chose. This can include credentials to access the data source and data source identifying information such as Prometheus workspace name, database name, or Amazon S3 bucket name. For AWS services, the wizard discovers the resources and populates them into the selection dropdown. For more notes about the data source you are using, see the sections after this procedure. Connect to a prebuilt data source with a wizard 2472 Amazon CloudWatch User Guide 8. To have CloudWatch connect to the data source in a VPC, choose Use a VPC and select the VPC to use. Then select the subnet and security group. 9. Choose I acknowledge that AWS CloudFormation will create IAM resources. This resource is the Lambda function execution role. 10. Choose Create data source. The new source that you just added doesn't appear until the AWS CloudFormation stack is done creating it. To check progress, you can choose View the status of my CloudFormation stack. Or you can choose the refresh icon to update this list. When your new data source appears in this list, it is ready to use. You can choose Query from CloudWatch metrics to begin querying with it. For more information, see Creating a graph of metrics from another data source. Amazon Managed Service for Prometheus Updating the data source configuration • You can
acw-ug-706
acw-ug.pdf
706
role. 10. Choose Create data source. The new source that you just added doesn't appear until the AWS CloudFormation stack is done creating it. To check progress, you can choose View the status of my CloudFormation stack. Or you can choose the refresh icon to update this list. When your new data source appears in this list, it is ready to use. You can choose Query from CloudWatch metrics to begin querying with it. For more information, see Creating a graph of metrics from another data source. Amazon Managed Service for Prometheus Updating the data source configuration • You can update your data source manually by doing the following: • To update the Amazon Managed Service for Prometheus workspace ID, update the AMAZON_PROMETHEUS_WORKSPACE_ID environment variable for the data source connector Lambda function. • To update the VPC configuration, see Configuring VPC access (console) for more information. Querying the data source • When querying Amazon Managed Service for Prometheus, after you select the data source in the Multi source query tab and select an Amazon Managed Service for Prometheus connector, you can use the Query helper to discover metrics and labels and provide simple PromQL queries. You can also use the PromQL query editor to build a PromQL query. • Multi-line queries are not supported by the CloudWatch data source connectors. Every line feed is replaced with a space when the query is executed, or when you create an alarm or a dashboard widget with the query. In some cases, this might make your query not valid. For example, if your query contains a single line comment it will not be valid. If you try to create a dashboard or alarm with a multi-line query from the command line or Infrastructure as Code, the API will reject the action with a parse error. Amazon Managed Service for Prometheus 2473 Amazon CloudWatch User Guide Amazon OpenSearch Service Creating the data source If the OpenSearch domain is enabled for FGAC, you must map the execution role of the connector Lambda function to a user in OpenSearch Service. For more information, see the Mapping users to roles section in Managing permissions in the OpenSearch Service documentation. If your OpenSearch domain is only accessible within a Virtual Private Cloud (VPC), you need to manually include a new environment variable in the Lambda function called AMAZON_OPENSEARCH_ENDPOINT. The value for this variable should be the root domain of the OpenSearch endpoint. You can obtain this root domain by removing https:// and <region>.es.amazonaws.com from the domain endpoint listed in the OpenSearch Service console. For example, if your domain endpoint is https://sample-domain.us- east-1.es.amazonaws.com, the root domain would be sample-domain. Updating the data source • You can update your data source manually by doing the following: • To update the OpenSearch Service domain, update the AMAZON_OPENSEARCH_DOMAIN_NAME environment variable for the data source connector Lambda function. • To update the VPC configuration, see Configuring VPC access (console) for more information. Querying the data source • When querying OpenSearch Service, after you select the data source in the Multi source query tab, do the following: • Select the Index to query. • Select the Metric name (Any numeric field in the document) and Stat. • Select the Time axis (Any date field in the document). • Select Filters to apply (Any String field in the document). • Choose Graph query. Amazon RDS for PostgreSQL and Amazon RDS for MySQL Creating the data source Amazon OpenSearch Service 2474 Amazon CloudWatch User Guide • If your data source is only accessible in a VPC, you must include the VPC configuration for the connector, as described in Connect to a prebuilt data source with a wizard. If the data source is to connect to the VPC for credentials, the endpoint must be configured in the VPC. For more information, see Using an AWS Secrets Manager VPC endpoint. Additionally, you must create a VPC endpoint for the Amazon RDS service. For more information, see Amazon RDS API and interface VPC endpoints (AWS PrivateLink). Updating the data source • You can update your data source manually by doing the following: • To update the database instance, update the RDS_INSTANCE environment variable for the data source connector Lambda function. • To update the username and password used to connect to Amazon RDS, use AWS Secrets Manager. You can find the ARN of the secret used for the data source in the environment variable RDS_SECRET on the data source Lambda function. For more information about updating the secret in AWS Secrets Manager, see Modify an AWS Secrets Manager secret. • To update the VPC configuration, see Configuring VPC access (console) for more information. Querying the data source • When querying Amazon RDS, after you select the data source in the Multi source query tab and select an Amazon RDS
acw-ug-707
acw-ug.pdf
707
function. • To update the username and password used to connect to Amazon RDS, use AWS Secrets Manager. You can find the ARN of the secret used for the data source in the environment variable RDS_SECRET on the data source Lambda function. For more information about updating the secret in AWS Secrets Manager, see Modify an AWS Secrets Manager secret. • To update the VPC configuration, see Configuring VPC access (console) for more information. Querying the data source • When querying Amazon RDS, after you select the data source in the Multi source query tab and select an Amazon RDS connector, you can use the database discoverer to view available databases, tables, and columns. You can also use the SQL editor to create an SQL query. You can use the following variables in the query: • $start.iso – The start time in ISO date format • $end.iso – The end time in ISO date format • $period – The selected period in seconds For example, you can query SELECT value, timestamp FROM table WHERE timestamp BETWEEN $start.iso and $end.iso • Multi-line queries are not supported by the CloudWatch data source connectors. Every line feed is replaced with a space when the query is executed, or when you create an alarm or a dashboard widget with the query. In some cases, this might make your query not valid. For example, if your query contains a single line comment it will not be valid. If you try to create a dashboard Amazon RDS for PostgreSQL and Amazon RDS for MySQL 2475 Amazon CloudWatch User Guide or alarm with a multi-line query from the command line or Infrastructure as Code, the API will reject the action with a parse error. Note If no date field is found in the results, the values for each numeric field are summed to single values and plotted across the provided time range. If the timestamps don't align with the selected period in CloudWatch, the data is automatically aggregated using SUM and aligned with the period in CloudWatch. Amazon S3 CSV files Querying the data source • When querying Amazon S3 CSV files, after you select the data source in the Multi source query tab and select an Amazon S3 connector, you select the Amazon S3 bucket and key. The CSV file must be formatted in the following ways: • The time stamp must be the first column. • The table must have a header row. The headers are used to name your metrics. The title of the time stamp column will be ignored, only the titles of the metrics columns are used. • The time stamps must be in ISO date format. • The metrics must be numeric fields. Timestamp, Metric-1, Metric-2, ... The following is an example: timestamp CPU (%) Memory (%) Storage (%) 2023-11-23T17:09:4 1+00:00 2023-11-23T17:04:4 1+00:00 1 4 2 5 3 6 Amazon S3 CSV files 2476 Amazon CloudWatch User Guide timestamp CPU (%) Memory (%) Storage (%) 2023-11-23T16:59:4 1+00:00 7 2023-11-23T16:54:4 1+00:00 10 Note 8 11 9 12 If no timestamp is provided, the values for each metric are summed to single values and plotted across the provided time range. If the timestamps don't align with the selected period in CloudWatch, the data is automatically aggregated using SUM and aligned with the period in CloudWatch. Microsoft Azure Monitor Creating the data source • You must provide your tenant ID, client ID, and client secret to connect to Microsoft Azure Monitor. The credentials will be stored in AWS Secrets Manager. For more information, see Create a Microsoft Entra application and service principal that can access resources in the Microsoft documentation. Updating the data source • You can update your data source manually by doing the following: • To update the tenant ID, client ID, and client secret used to connect to Azure Monitor, you can find the ARN of the secret used for the data source as the AZURE_CLIENT_SECRET environment variable on the data source Lambda function. For more information about updating the secret in AWS Secrets Manager, see Modify an AWS Secrets Manager secret. Querying the data source Microsoft Azure Monitor 2477 Amazon CloudWatch User Guide • When querying Azure Monitor, after you select the data source in the Multi source query tab and select an Azure Monitor connector, you specify the Azure subscription, and the resource group and resource. You can then select the metric namespace, metric, and aggregation, and filter by dimensions. Prometheus Creating the data source • You must provide the Prometheus endpoint and the user and password required to query Prometheus. The credentials will be stored in AWS Secrets Manager. • If your data source is only accessible in a VPC, you must include the VPC configuration for the connector, as described in Connect to a prebuilt data source
acw-ug-708
acw-ug.pdf
708
select the data source in the Multi source query tab and select an Azure Monitor connector, you specify the Azure subscription, and the resource group and resource. You can then select the metric namespace, metric, and aggregation, and filter by dimensions. Prometheus Creating the data source • You must provide the Prometheus endpoint and the user and password required to query Prometheus. The credentials will be stored in AWS Secrets Manager. • If your data source is only accessible in a VPC, you must include the VPC configuration for the connector, as described in Connect to a prebuilt data source with a wizard. If the data source is to connect to for credentials, the endpoint must be configured in the VPC. For more information, see Using an AWS Secrets Manager VPC endpoint. Updating data source configuration • You can update your data source manually by doing the following: • To update the Prometheus endpoint, specify the new endpoint as the PROMETHEUS_API_ENDPOINT environment variable on the data source Lambda function. • To update the username and password used to connect to Prometheus, you can find the ARN of the secret used for the data source as the PROMETHEUS_API_SECRET environment variable on the data source Lambda function. For more information about updating the secret in AWS Secrets Manager, see Modify an AWS Secrets Manager secret. • To update the VPC configuration, see Configuring VPC access (console) for more information. Querying the data source Important Prometheus metric types are different than CloudWatch metrics and many metrics available through Prometheus are cumulative by design. When you query Prometheus metrics, CloudWatch doesn't apply any additional transformation to the data: if you specify only the metric name or label, the displayed value will be cumulative. For more information, see Metric types in the Prometheus documentation. Prometheus 2478 Amazon CloudWatch User Guide To see Prometheus metrics data as discrete values, like CloudWatch metrics, you need to edit the query before you run it. For example, you might need to add a call to the rate function over your Prometheus metric name. For documentation about the rate function and other Prometheus functions, see rate() in the Prometheus documentation. Multi-line queries are not supported by the CloudWatch data source connectors. Every line feed is replaced with a space when the query is executed, or when you create an alarm or a dashboard widget with the query. In some cases, this might make your query not valid. For example, if your query contains a single line comment it will not be valid. If you try to create a dashboard or alarm with a multi-line query from the command line or Infrastructure as Code, the API will reject the action with a parse error. Notification of Available Updates From time to time, Amazon might notify you that we recommend that you update your connectors with a newer available version and will provide instructions for how to do so. Create a custom connector to a data source This topic describes how to connect a custom data source to CloudWatch. You can connect a custom data source to CloudWatch in two ways: • Using a sample template that CloudWatch provides. You can use either JavaScript or Python with this template. These templates include sample Lambda code that will be useful to you when you create your Lambda function. You can then modify the Lambda function from the template to connect to your custom data source. • Creating an AWS Lambda function from scratch that implements the data source connector, the data query, and the preparation of the time series for use by CloudWatch. This function must pre-aggregate or merge datapoints if needed, and also align the period and timestamps to be compatible with CloudWatch. Contents • Use a template • Create a custom data source from scratch • Step 1: Create the function Notification of Available Updates 2479 Amazon CloudWatch User Guide • GetMetricData event • DescribeGetMetricData event • Important considerations for CloudWatch alarms • (Optional) Use AWS Secrets Manager to store credentials • (Optional) Connect to a data source in a VPC • Step 2: Create a Lambda permissions policy • Step 3: Attach a resource tag to the Lambda function Use a template Using a template creates a sample Lambda function, and can help you get your custom connector built faster. These sample functions provide sample code for many common scenarios involved with building a custom connector. You can examine the Lambda code after you create a connector with a template, then modify it to use to connect to your data source. Additionally, if you use the template, CloudWatch takes care of creating the Lambda permissions policy and attaching resource tags to the Lambda function. To use the template to create a connector to a custom data source 1. Open the
acw-ug-709
acw-ug.pdf
709
a template Using a template creates a sample Lambda function, and can help you get your custom connector built faster. These sample functions provide sample code for many common scenarios involved with building a custom connector. You can examine the Lambda code after you create a connector with a template, then modify it to use to connect to your data source. Additionally, if you use the template, CloudWatch takes care of creating the Lambda permissions policy and attaching resource tags to the Lambda function. To use the template to create a connector to a custom data source 1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 2. In the navigation pane, choose Settings. 3. Choose the Metrics data sources tab. 4. Choose Create data source. 5. Choose the radio button for Custom - getting started template and then choose Next. 6. 7. 8. Enter a name for the data source. Select the one of the listed templates. Select either Node.js or Python. 9. Choose Create data source. The new custom source that you just added doesn't appear until the AWS CloudFormation stack finishes creating it. To check progress, you can choose View the status of my CloudFormation stack. Or you can choose the refresh icon to update this list. Use a template 2480 Amazon CloudWatch User Guide When your new data source appears in this list, it is ready for you to test in the console and modify. 10. (Optional) To query the test data from this source in the console, follow the instructions in Creating a graph of metrics from another data source. 11. Modify the Lambda function for your needs. a. In the navigation pane, choose Settings. b. Choose the Metrics data sources tab. c. Choose View in Lambda console for the source that you want to modify. You can now modify the function to access your data source. For more information, see Step 1: Create the function. Note By using the template, when you write your Lambda function you don't need to follow the instructions in Step 2: Create a Lambda permissions policy or Step 3: Attach a resource tag to the Lambda function. These steps were performed by CloudWatch because you used the template. Create a custom data source from scratch Follow the steps in this section to create a Lambda function that connects CloudWatch to a data source. Step 1: Create the function A custom data source connector must support GetMetricData events from CloudWatch. Optionally, you can also implement a DescribeGetMetricData event to provide documentation to users in the CloudWatch console for how to use the connector. The DescribeGetMetricData response can also be used to set defaults that are used in the CloudWatch custom query builder. CloudWatch provides code snippets as samples to help you get started. For more information, see the samples repository at https://github.com/aws-samples/cloudwatch-data-source-samples. Constraints Create a custom data source from scratch 2481 Amazon CloudWatch User Guide • The response from Lambda must be smaller than 6 Mb. If the response exceeds 6 Mb, the GetMetricData response marks the Lambda function as InternalError and no data is returned. • The Lambda function must complete its execution within 10 seconds for visualization and dashboarding purposes, or within 4.5 seconds for alarms usage. If the execution time exceeds that time, the GetMetricData response marks the Lambda function as InternalError and no data is returned. • The Lambda function must send its output using epoch timestamps in seconds. • If the Lambda function doesn't resample the data and instead returns data that doesn't correspond to the start time and period length that was requested by the CloudWatch user, that data is ignored by CloudWatch. The extra data is discarded from any visualization or alarming. Any data that is not between the start time and end time is also discarded. For example, if a user asks for data from 10:00 to 11:00 with a period of 5 min, then "10:00:00 to 10:04:59" and "10:05:00 to 10:09:59" are the valid time ranges for data to be returned. You must return a time series that includes 10:00 value1, 10:05 value2, and so on. If the function returns 10:03 valueX, for example, it gets dropped because 10:03 does not correspond to the requested start time and period. • Multi-line queries are not supported by the CloudWatch data source connectors. Every line feed is replaced with a space when the query is executed, or when you create an alarm or a dashboard widget with the query. In some cases, this might make your query not valid. GetMetricData event Request payload The following is an example of a GetMetricData request payload sent as input to the Lambda function. { "EventType": "GetMetricData", "GetMetricDataRequest": { "StartTime": 1697060700, "EndTime": 1697061600, "Period": 300, "Arguments": ["serviceregistry_external_http_requests{host_cluster!=\"prod\"}"] } } Create a custom data source from scratch 2482 Amazon CloudWatch User
acw-ug-710
acw-ug.pdf
710
requested start time and period. • Multi-line queries are not supported by the CloudWatch data source connectors. Every line feed is replaced with a space when the query is executed, or when you create an alarm or a dashboard widget with the query. In some cases, this might make your query not valid. GetMetricData event Request payload The following is an example of a GetMetricData request payload sent as input to the Lambda function. { "EventType": "GetMetricData", "GetMetricDataRequest": { "StartTime": 1697060700, "EndTime": 1697061600, "Period": 300, "Arguments": ["serviceregistry_external_http_requests{host_cluster!=\"prod\"}"] } } Create a custom data source from scratch 2482 Amazon CloudWatch User Guide • StartTime– The timestamp specifying the earliest data to return. The Type is timestamp epoch seconds. • EndTime– The timestamp specifying the latest data to return. The Type is timestamp epoch seconds. • Period– The number of seconds that each aggregation of the metrics data represents. The minimum is 60 seconds. The Type is Seconds. • Arguments– An array of arguments to pass to the Lambda metric math expression. For more information about passing arguments, see How to pass arguments to your Lambda function. Response payload The following is an example of a GetMetricData response payload returned by the Lambda function. { "MetricDataResults": [ { "StatusCode": "Complete", "Label": "CPUUtilization", "Timestamps": [ 1697060700, 1697061000, 1697061300 ], "Values": [ 15000, 14000, 16000 ] } ] } The response payload will contain either a MetricDataResults field or an Error field, but not both. A MetricDataResults field is a list of time-series fields of type MetricDataResult. Each of those time-series fields can include the following fields. • StatusCode– (Optional) Complete indicates that all data points in the requested time range were returned. PartialData means that an incomplete set of data points were returned. If this is omitted, the default is Complete. Valid Values: Complete | InternalError | PartialData | Forbidden • Messages– Optional list of messages with additional information about the data returned. Type: Array of MessageData objects with Code and Value strings. Create a custom data source from scratch 2483 Amazon CloudWatch User Guide • Label– The human-readable label associated with the data. Type: String • Timestamps– The timestamps for the data points, formatted in epoch time. The number of timestamps always matches the number of values and the value for Timestamps[x] is Values[x]. Type: Array of timestamps • Values– The data point values for the metric, corresponding to Timestamps. The number of values always matches the number of timestamps and the value for Timestamps[x] is Values[x]. Type: Array of doubles For more information about Error objects, see the following sections. Error response formats You can optionally use the error response to provide more information about errors. We recommend that you return an error with Code Validation when a validation error occurs, such as when a parameter is missing or is the wrong type. The following is an example of the response when the Lambda function wants to raise a GetMetricData validation exception. { "Error": { "Code": "Validation", "Value": "Invalid Prometheus cluster" } } The following is an example of the response when the Lambda function indicates that it's unable to return data because of an access issue. The response is translated into a single time series with a status code of Forbidden. { "Error": { "Code": "Forbidden", Create a custom data source from scratch 2484 Amazon CloudWatch User Guide "Value": "Unable to access ..." } } The following is an example of when the Lambda function raises an overall InternalError exception, which is translated into a single time series with a status code of InternalError and a message. Whenever an error code has a value other than Validation or Forbidden, CloudWatch assumes that it's a generic internal error. { "Error": { "Code": "PrometheusClusterUnreachable", "Value": "Unable to communicate with the cluster" } } DescribeGetMetricData event Request payload The following is an example of a DescribeGetMetricData request payload. { "EventType": "DescribeGetMetricData" } Response payload The following is an example of a DescribeGetMetricData response payload. { "Description": "Data source connector", "ArgumentDefaults": [{ Value: "default value" }] } • Description– A description of how to use the data source connector. This description will appear in the CloudWatch console. Markdown is supported. Type: String Create a custom data source from scratch 2485 Amazon CloudWatch User Guide • ArgumentDefaults– Optional array of argument default values used pre-populate the custom data source builder. If [{ Value: "default value 1"}, { Value: 10}], is returned, the query builder in the CloudWatch console displays two inputs, the first with “default value 1” and the second with 10. If ArgumentDefaults is not provided, a single input is displayed with type default set to String. Type: Array of objects containing Value and Type. • Error– (Optional) An error field can be included in any response. You can see examples in GetMetricData event.
acw-ug-711
acw-ug.pdf
711
custom data source from scratch 2485 Amazon CloudWatch User Guide • ArgumentDefaults– Optional array of argument default values used pre-populate the custom data source builder. If [{ Value: "default value 1"}, { Value: 10}], is returned, the query builder in the CloudWatch console displays two inputs, the first with “default value 1” and the second with 10. If ArgumentDefaults is not provided, a single input is displayed with type default set to String. Type: Array of objects containing Value and Type. • Error– (Optional) An error field can be included in any response. You can see examples in GetMetricData event. Important considerations for CloudWatch alarms If you are going to use the data source to set CloudWatch alarms, you should set it up to report data with timestamps every minute to CloudWatch. For more information and other considerations for creating alarms on metrics from connected data sources, see Create an alarm based on a connected data source. (Optional) Use AWS Secrets Manager to store credentials If your Lambda function needs to use credentials to access the data source, we recommend using AWS Secrets Manager to store these credentials instead of hardcoding them into your Lambda function. For more information about using AWS Secrets Manager with Lambda, see Use AWS Secrets Manager secrets in AWS Lambda functions. (Optional) Connect to a data source in a VPC If your data source is in a VPC managed by Amazon Virtual Private Cloud, you must configure your Lambda function to access it. For more information, see Connecting outbound networking to resources in a VPC. You might also need to configure VPC service endpoints to access services such as AWS Secrets Manager. For more information, see Access an AWS service using an interface VPC endpoint. Create a custom data source from scratch 2486 Amazon CloudWatch User Guide Step 2: Create a Lambda permissions policy You must use create a policy statement that grants CloudWatch permission to use the Lambda function that you created. You can use the AWS CLI or the Lambda console to create the policy statement. To use the AWS CLI to create the policy statement • Enter the following command. Replace 123456789012 with your account ID, replace my-data-source-function with the name of your Lambda function, and replace MyDataSource-DataSourcePermission1234 with an arbitrary unique value. aws lambda add-permission --function-name my-data-source-function --statement- id MyDataSource-DataSourcePermission1234 --action lambda:InvokeFunction --principal lambda.datasource.cloudwatch.amazonaws.com --source-account 123456789012 Step 3: Attach a resource tag to the Lambda function The CloudWatch console determines which of your Lambda functions are data source connectors by using a tag. When you create a data source using one of the wizards, the tag is automatically applied by the AWS CloudFormation stack that configures it. When you create a data source yourself, you can use the following tag for your Lambda function. This makes your connector appear in the Data source dropdown in the CloudWatch console when you query metrics. • A tag with cloudwatch:datasource as the key and custom as the value. Use your custom data source After you create a data source, you can use it to query and visualize data from that source, as well as to set alarms. If you used a template to create your custom data source connector or you added the tag listed in Step 3: Attach a resource tag to the Lambda function, you can follow the steps in Creating a graph of metrics from another data source to query it. You can also use the metric math function LAMBDA to query it, as explained in the following section. For information about creating alarms on metrics from your data source, see Create an alarm based on a connected data source. This topic describes how to pass arguments to your Lambda function to your custom data source. Use your custom data source 2487 Amazon CloudWatch User Guide How to pass arguments to your Lambda function The recommended way for you to pass arguments to your custom data source is to use the query builder in the CloudWatch console when you query the data source. You can also use your Lambda function to retrieve data from your data source by using the new LAMBDA expression in CloudWatch metric math. LAMBDA("LambdaFunctionName" [, optional-arg]*) optional-arg is up to 20 strings, numbers, or Booleans. For example, param, 3.14, or true. Note Multi-line strings are not supported by the CloudWatch data source connectors. Every line feed is replaced with a space when the query is executed, or when you create an alarm or a dashboard widget with the query. In some cases, this might make your query not valid. When you use the LAMBDA metric math function, you can provide the function name ("MyFunction"). If your resource policy allows, you can also use a specific version of the function ("MyFunction:22"), or a Lambda function alias ("MyFunction:MyAlias"). You
acw-ug-712
acw-ug.pdf
712
is up to 20 strings, numbers, or Booleans. For example, param, 3.14, or true. Note Multi-line strings are not supported by the CloudWatch data source connectors. Every line feed is replaced with a space when the query is executed, or when you create an alarm or a dashboard widget with the query. In some cases, this might make your query not valid. When you use the LAMBDA metric math function, you can provide the function name ("MyFunction"). If your resource policy allows, you can also use a specific version of the function ("MyFunction:22"), or a Lambda function alias ("MyFunction:MyAlias"). You can't use * The following are some examples of calling the LAMBDA function. LAMBDA("AmazonOpenSearchDataSource", "MyDomain", "some-query") LAMBDA("MyCustomDataSource", true, "fuzzy", 99.9) The LAMBDA metric math function returns a list of time series that can be returned to the requester or combined with other metric math functions. The following is an example of combining LAMBDA with other metric math functions. FILL(LAMBDA("AmazonOpenSearchDataSource", "MyDomain", "some-query"), 0) Delete a connector to a data source The instructions in this section describe how to delete a connector to a data source. How to pass arguments to your Lambda function 2488 Amazon CloudWatch User Guide To delete a connector to a data source 1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 2. In the navigation pane, choose Settings. 3. Choose the Metrics data sources tab. 4. Choose Manage in CloudFormation in the row of the data source that you want to delete. You are taken to the AWS CloudFormation console. In the section with the name of your data source, choose Delete. In the confirmation pop-up, choose Delete. 5. 6. Delete a connector to a data source 2489 Amazon CloudWatch User Guide Collect metrics, logs, and traces with the CloudWatch agent The unified CloudWatch agent enables you to do the following: • Collect internal system-level metrics from Amazon EC2 instances across operating systems. The metrics can include in-guest metrics, in addition to the metrics for EC2 instances. The additional metrics that can be collected are listed in Metrics collected by the CloudWatch agent. • Collect system-level metrics from on-premises servers. These can include servers in a hybrid environment as well as servers not managed by AWS. • Retrieve custom metrics from your applications or services using the StatsD and collectd protocols. StatsD is supported on both Linux servers and servers running Windows Server. collectd is supported only on Linux servers. • Collect logs from Amazon EC2 instances and on-premises servers, running either Linux or Windows Server. Note The CloudWatch agent does not support collecting logs from FIFO pipes. • Send the metrics to either CloudWatch or Amazon Managed Service for Prometheus, or to both. The CloudWatch agent configuration file contains a metrics_destinations parameter in the metrics section. You can specify cloudwatch, amp, or both in this parameter. • Version 1.300031.0 and later can be used to enable CloudWatch Application Signals. For more information, see Application Signals. • Version 1.300025.0 and later can collect traces from OpenTelemetry or X-Ray client SDKs, and send them to X-Ray. Using the CloudWatch agent allows you to collect traces without needing to run a separate trace collection daemon, helping to reduce the number of agents that you run and manage. Metrics sent to CloudWatch can be viewed in CloudWatch just as any other CloudWatch metrics. The default CloudWatch namespace for metrics collected by the CloudWatch agent is CWAgent, although you can specify a different namespace when you configure the agent. 2490 Amazon CloudWatch User Guide The logs collected by the unified CloudWatch agent are processed and stored in Amazon CloudWatch Logs, just like logs collected by the older CloudWatch Logs agent. For information about CloudWatch Logs pricing, see Amazon CloudWatch Pricing. Metrics collected by the CloudWatch agent are billed as custom metrics. For more information about CloudWatch metrics pricing, see Amazon CloudWatch Pricing. The CloudWatch agent is open-source under the MIT license, and is hosted on GitHub. If you would like to build, customize or contribute to the CloudWatch agent, see the GitHub repository for the latest instructions. If you think you’ve found a potential security issue, do not post it on GitHub or any public forum. Instead, please follow the instructions at Vulnerability Reporting or email AWS security directly. The steps in this section explain how to install the unified CloudWatch agent on Amazon EC2 instances and on-premises servers. For more information about the metrics that the CloudWatch agent can collect, see Metrics collected by the CloudWatch agent. Supported operating systems The CloudWatch agent is supported on x86-64 architecture on the following operating systems. It is also supported on all minor version updates for each of the major versions listed here. • Amazon Linux 2023 • Amazon Linux 2 • Ubuntu Server versions 24.04, 23.10, 22.04, 20.04, 18.04, 16.04, and 14.04 • CentOS
acw-ug-713
acw-ug.pdf
713
Reporting or email AWS security directly. The steps in this section explain how to install the unified CloudWatch agent on Amazon EC2 instances and on-premises servers. For more information about the metrics that the CloudWatch agent can collect, see Metrics collected by the CloudWatch agent. Supported operating systems The CloudWatch agent is supported on x86-64 architecture on the following operating systems. It is also supported on all minor version updates for each of the major versions listed here. • Amazon Linux 2023 • Amazon Linux 2 • Ubuntu Server versions 24.04, 23.10, 22.04, 20.04, 18.04, 16.04, and 14.04 • CentOS versions 9, 8, and 7 • Red Hat Enterprise Linux (RHEL) versions 9, 8, and 7 • Debian versions 12, 11 and 10 • SUSE Linux Enterprise Server (SLES) versions 15 and 12 • Oracle Linux versions 9, 8 and 7 • AlmaLinux versions 9 and 8 • Rocky Linux versions 9 and 8 • The following macOS computers: EC2 M1 Mac1 instances, and computers running macOS 14 (Sonoma), macOS 13 (Ventura), and macOS 12 (Monterey) • Windows Server 2025, Windows Server 2022, Windows Server 2019, and Windows Server 2016 • Windows 11 • 64-bit Windows 10 2491 Amazon CloudWatch User Guide The agent is supported on ARM64 architecture on the following operating systems. It is also supported on all minor version updates for each of the major versions listed here. • Amazon Linux 2023 • Amazon Linux 2 • Ubuntu Server versions 23.10, 22.04, 20.04, 18.04, and 16.04 • CentOS versions 9 and 8 • Red Hat Enterprise Linux (RHEL) versions 9, 8, and 7 • Debian versions 12, 11 and 10 • SUSE Linux Enterprise Server 15 • The following macOS computers: macOS 14 (Sonoma), macOS 13 (Ventura), and macOS 12 (Monterey) Installation process overview You can download and install the CloudWatch agent manually using the command line, or you can integrate it with SSM. The general flow of installing the CloudWatch agent using either method is as follows: 1. Create IAM roles or users that enable the agent to collect metrics from the server and optionally to integrate with AWS Systems Manager. 2. Download the agent package. 3. Modify the CloudWatch agent configuration file and specify the metrics that you want to collect. 4. Install and start the agent on your servers. As you install the agent on an EC2 instance, you attach the IAM role that you created in step 1. As you install the agent on an on-premises server, you specify a named profile that contains the credentials of the IAM user that you created in step 1. Contents • Install the CloudWatch agent • Install the CloudWatch agent on new instances using AWS CloudFormation • Set up the CloudWatch agent with security-enhanced Linux (SELinux) • CloudWatch agent credentials preference • Verifying the signature of the CloudWatch agent package 2492 Amazon CloudWatch User Guide • Create the CloudWatch agent configuration file • Install the CloudWatch agent with the Amazon CloudWatch Observability EKS add-on or the Helm chart • Metrics collected by the CloudWatch agent • Using the CloudWatch agent with related telemetry • Common scenarios with the CloudWatch agent • Troubleshooting the CloudWatch agent Install the CloudWatch agent The CloudWatch agent is available as a package in Amazon Linux 2023 and Amazon Linux 2. If you are using one of these operating systems, you can install the package by entering the following command. You must also make sure that the IAM role attached to the instance has the CloudWatchAgentServerPolicy attached. For more information, see Create IAM roles to use with the CloudWatch agent on Amazon EC2 instances. sudo yum install amazon-cloudwatch-agent On all supported operating systems including Linux and Windows Server, you can download and install the CloudWatch agent using either the command line with an Amazon S3 download link, using Amazon EC2 Systems Manager, or using an AWS CloudFormation template. See the following sections for details. Contents • Install the CloudWatch agent using the command line • Install the CloudWatch agent using AWS Systems Manager • Install the CloudWatch agent on on-premises servers Install the CloudWatch agent using the command line Use the following topics to download, configure, and install the CloudWatch agent package. Topics • Download and configure the CloudWatch agent using the command line • Create IAM roles and users for use with CloudWatch agent Install the CloudWatch agent 2493 Amazon CloudWatch User Guide • Install and run the CloudWatch agent on your servers Download and configure the CloudWatch agent using the command line You can use the following steps to download the CloudWatch agent package, create IAM roles or users, and optionally modify the common configuration file. Download the CloudWatch agent package Note To download the CloudWatch agent, your connection must use TLS 1.2 or later. The CloudWatch agent is available
acw-ug-714
acw-ug.pdf
714
Topics • Download and configure the CloudWatch agent using the command line • Create IAM roles and users for use with CloudWatch agent Install the CloudWatch agent 2493 Amazon CloudWatch User Guide • Install and run the CloudWatch agent on your servers Download and configure the CloudWatch agent using the command line You can use the following steps to download the CloudWatch agent package, create IAM roles or users, and optionally modify the common configuration file. Download the CloudWatch agent package Note To download the CloudWatch agent, your connection must use TLS 1.2 or later. The CloudWatch agent is available as a package in Amazon Linux 2023 and Amazon Linux 2. If you are using this operating system, you can install the package by entering the following command. You must also make sure that the IAM role attached to the instance has the CloudWatchAgentServerPolicy attached. For more information, see Create IAM roles and users for use with CloudWatch agent. sudo yum install amazon-cloudwatch-agent On all supported operating systems, you can download and install the CloudWatch agent using the command line. For each download link, there is a general link as well as links for each Region. For example, for Amazon Linux 2023 and Amazon Linux 2 and the x86-64 architecture, three of the valid download links are: • https://amazoncloudwatch-agent.s3.amazonaws.com/amazon_linux/amd64/ latest/amazon-cloudwatch-agent.rpm • https://amazoncloudwatch-agent-us-east-1.s3.us-east-1.amazonaws.com/ amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm • https://amazoncloudwatch-agent-eu-central-1.s3.eu- central-1.amazonaws.com/amazon_linux/amd64/latest/amazon-cloudwatch- agent.rpm Install the CloudWatch agent using the command line 2494 Amazon CloudWatch User Guide You can also download a README file about the latest changes to the agent, and a file that indicates the version number that is available for download. These files are in the following locations: • https://amazoncloudwatch-agent.s3.amazonaws.com/info/latest/RELEASE_NOTES or https://amazoncloudwatch-agent-region.s3.region.amazonaws.com/info/ latest/RELEASE_NOTES • https://amazoncloudwatch-agent.s3.amazonaws.com/info/ latest/CWAGENT_VERSION or https://amazoncloudwatch- agent-region.s3.region.amazonaws.com/info/latest/CWAGENT_VERSION Architecture Platform Download link Signature file link x86-64 Amazon Linux 2023 https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ and Amazon amazon_linux/amd64/latest/ amazon_linux/amd64/latest/ Linux 2 amazon-cloudwatch-agent.r amazon-cloudwatch-agent.r pm pm.sig x86-64 Centos https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/amazon_linux/amd64/ ent-region.s3.region.amazonaw s.com/amazon_linux/amd64/ latest/amazon-cloudwatch- latest/amazon-cloudwatch- agent.rpm agent.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ centos/amd64/latest/amaz on-cloudwatch-agent.rpm https://amazoncloudwatch- agent.s3.amazonaws.com/ centos/amd64/latest/amaz on-cloudwatch-agent.rpm.sig https://amazonclou dwatch-ag https://amazonclou dwatch-ag ent-region.s3.region.amazonaw s.com/centos/amd64/ ent-region.s3.region.amazonaw s.com/centos/amd64/ Install the CloudWatch agent using the command line 2495 Amazon CloudWatch User Guide Architecture Platform Download link Signature file link x86-64 Redhat x86-64 SUSE latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.rpm gent.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ redhat/amd64/latest/amaz redhat/amd64/latest/amaz on-cloudwatch-agent.rpm on-cloudwatch-agent.rpm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/redhat/amd64/ latest/amazon-cloudwatch-a ent-region.s3.region.amazonaw s.com/redhat/amd64/ latest/amazon-cloudwatch-a gent.rpm gent.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ suse/amd64/latest/amazon- suse/amd64/latest/amazon- cloudwatch-agent.rpm cloudwatch-agent.rpm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/suse/amd64/latest/ ent-region.s3.region.amazonaw s.com/suse/amd64/latest/ amazon-cloudwatch-age amazon-cloudwatch-age nt.rpm nt.rpm.sig Install the CloudWatch agent using the command line 2496 Amazon CloudWatch User Guide Architecture Platform Download link Signature file link x86-64 Debian x86-64 Ubuntu x86-64 Oracle https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ debian/amd64/latest/amaz debian/amd64/latest/amaz on-cloudwatch-agent.deb on-cloudwatch-agent.deb.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/debian/amd64/ ent-region.s3.region.amazonaw s.com/debian/amd64/ latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.deb gent.deb.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ ubuntu/amd64/latest/amaz ubuntu/amd64/latest/amaz on-cloudwatch-agent.deb on-cloudwatch-agent.deb.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/ubuntu/amd64/ ent-region.s3.region.amazonaw s.com/ubuntu/amd64/ latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.deb gent.deb.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ oracle_linux/amd64/latest/ amazon-cloudwatch-agent.r pm https://amazoncloudwatch- agent.s3.amazonaws.com/ oracle_linux/amd64/latest/ amazon-cloudwatch-agent.r pm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/oracle_linux/amd64/ ent-region.s3.region.amazonaw s.com/oracle_linux/amd64/ latest/amazon-cloudwatch- latest/amazon-cloudwatch- agent.rpm agent.rpm.sig Install the CloudWatch agent using the command line 2497 Amazon CloudWatch User Guide Architecture Platform Download link Signature file link x86-64 macOS x86-64 Windows https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ darwin/amd64/latest/amaz darwin/amd64/latest/amaz on-cloudwatch-agent.pkg on-cloudwatch-agent.pkg.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/darwin/amd64/ ent-region.s3.region.amazonaw s.com/darwin/amd64/ latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.pkg gent.pkg.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ windows/amd64/latest/ama windows/amd64/latest/ama zon-cloudwatch-agent.msi zon-cloudwatch-agent.msi.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/windows/amd64/ ent-region.s3.region.amazonaw s.com/windows/amd64/ latest/amazon-cloudwatch- latest/amazon-cloudwatch- agent.msi agent.msi.sig ARM64 Amazon Linux 2023 and Amazon Linux 2 https://amazoncloudwatch- agent.s3.amazonaws.com/ amazon_linux/arm64/latest/ amazon-cloudwatch-agent.r pm https://amazoncloudwatch- agent.s3.amazonaws.com/ amazon_linux/arm64/latest/ amazon-cloudwatch-agent.r pm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/amazon_linux/arm64/ ent-region.s3.region.amazonaw s.com/amazon_linux/arm64/ latest/amazon-cloudwatch- latest/amazon-cloudwatch- agent.rpm agent.rpm.sig Install the CloudWatch agent using the command line 2498 Amazon CloudWatch User Guide Architecture Platform Download link Signature file link ARM64 Redhat ARM64 Ubuntu ARM64 Debian https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ redhat/arm64/latest/amaz redhat/arm64/latest/amaz on-cloudwatch-agent.rpm on-cloudwatch-agent.rpm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/redhat/arm64/latest/ ent-region.s3.region.amazonaw s.com/redhat/arm64/latest/ amazon-cloudwatch-a amazon-cloudwatch-a gent.rpm gent.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ ubuntu/arm64/latest/amaz ubuntu/arm64/latest/amaz on-cloudwatch-agent.deb on-cloudwatch-agent.deb.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/ubuntu/arm64/ ent-region.s3.region.amazonaw s.com/ubuntu/arm64/ latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.deb gent.deb.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ debian/arm64/latest/amaz on-cloudwatch-agent.deb https://amazoncloudwatch- agent.s3.amazonaws.com/ debian/arm64/latest/amaz on-cloudwatch-agent.deb.sig https://amazonclou dwatch-ag https://amazonclou dwatch-ag ent-region.s3.region.amazonaw s.com/debian/arm64/latest/a ent-region.s3.region.amazonaw s.com/debian/arm64/latest/ mazon-cloudwatch-agent.deb amazon-cloudwatch-a gent.deb.sig Install the CloudWatch agent using the command line 2499 Amazon CloudWatch User Guide Architecture Platform Download link Signature file link ARM64 SUSE ARM64 MacOS https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ suse/arm64/latest/amazon- suse/arm64/latest/amazon- cloudwatch-agent.rpm cloudwatch-agent.rpm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/suse/arm64/latest/ ent-region.s3.region.amazonaw s.com/suse/arm64/latest/ amazon-cloudwatch-age amazon-cloudwatch-age nt.rpm nt.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ darwin/arm64/latest/amaz darwin/arm64/latest/amaz on-cloudwatch-agent.pkg on-cloudwatch-agent.pkg.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/darwin/arm64/latest/a ent-region.s3.region.amazonaw s.com/darwin/arm64/latest/ mazon-cloudwatch-agent.pkg amazon-cloudwatch-a gent.pkg.sig To use the command line to download and install the CloudWatch agent package 1. Download the CloudWatch agent. On a Linux server, enter the following. For download-link, use the appropriate download link from the previous table. wget download-link On a server running Windows Server, download the following file: Install the CloudWatch agent using the command line 2500 Amazon CloudWatch User Guide https://amazoncloudwatch-agent.s3.amazonaws.com/windows/amd64/latest/amazon-
acw-ug-715
acw-ug.pdf
715
agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ suse/arm64/latest/amazon- suse/arm64/latest/amazon- cloudwatch-agent.rpm cloudwatch-agent.rpm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/suse/arm64/latest/ ent-region.s3.region.amazonaw s.com/suse/arm64/latest/ amazon-cloudwatch-age amazon-cloudwatch-age nt.rpm nt.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ darwin/arm64/latest/amaz darwin/arm64/latest/amaz on-cloudwatch-agent.pkg on-cloudwatch-agent.pkg.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/darwin/arm64/latest/a ent-region.s3.region.amazonaw s.com/darwin/arm64/latest/ mazon-cloudwatch-agent.pkg amazon-cloudwatch-a gent.pkg.sig To use the command line to download and install the CloudWatch agent package 1. Download the CloudWatch agent. On a Linux server, enter the following. For download-link, use the appropriate download link from the previous table. wget download-link On a server running Windows Server, download the following file: Install the CloudWatch agent using the command line 2500 Amazon CloudWatch User Guide https://amazoncloudwatch-agent.s3.amazonaws.com/windows/amd64/latest/amazon- cloudwatch-agent.msi 2. After you have downloaded the package, you can optionally verify the package signature. For more information, see Verifying the signature of the CloudWatch agent package. 3. Install the package. If you downloaded an RPM package on a Linux server, change to the directory containing the package and enter the following: sudo rpm -U ./amazon-cloudwatch-agent.rpm If you downloaded a DEB package on a Linux server, change to the directory containing the package and enter the following: sudo dpkg -i -E ./amazon-cloudwatch-agent.deb If you downloaded an MSI package on a server running Windows Server, change to the directory containing the package and enter the following: msiexec /i amazon-cloudwatch-agent.msi This command also works from within PowerShell. For more information about MSI command options, see Command-Line Options in the Microsoft Windows documentation. If you downloaded a PKG package on a macOS server, change to the directory containing the package and enter the following: sudo installer -pkg ./amazon-cloudwatch-agent.pkg -target / Create and modify the agent configuration file After you have downloaded the CloudWatch agent, you must create the configuration file before you start the agent on any servers. For more information, see Create the CloudWatch agent configuration file. Install the CloudWatch agent using the command line 2501 Amazon CloudWatch User Guide Create IAM roles and users for use with CloudWatch agent Access to AWS resources requires permissions. You create an IAM role, an IAM user, or both to grant permissions that the CloudWatch agent needs to write metrics to CloudWatch. If you're going to use the agent on Amazon EC2 instances, you must create an IAM role. If you're going to use the agent on on-premises servers, you must create an IAM user. Note We recently modified the following procedures by using new CloudWatchAgentServerPolicy and CloudWatchAgentAdminPolicy policies created by Amazon, instead of requiring customers to create these policies themselves. For writing files to and downloading files from the Parameter Store, the policies created by Amazon support only files with names that start with AmazonCloudWatch-. If you have a CloudWatch agent configuration file with a file name that doesn't start with AmazonCloudWatch-, these policies can't be used to write the file to Parameter Store or download it from Parameter Store. If you're going to run the CloudWatch agent on Amazon EC2 instances, use the following steps to create the necessary IAM role. This role provides permissions for reading information from the instance and writing it to CloudWatch. To create the IAM role necessary to run the CloudWatch agent on EC2 instances 1. Sign in to the AWS Management Console and open the IAM console at https:// console.aws.amazon.com/iam/. 2. In the navigation pane on the left, choose Roles and then Create role. 3. Make sure that AWS service is selected under Trusted entity type. 4. For Use case, choose EC2 under Common use cases, 5. Choose Next. 6. 7. In the list of policies, select the check box next to CloudWatchAgentServerPolicy. If necessary, use the search box to find the policy. (Optional) If the agent is sending traces to X-Ray you need to also give the role the AWSXRayDaemonWriteAccess policy. To do so, find that policy in the list and select the check box next to it. Install the CloudWatch agent using the command line 2502 Amazon CloudWatch 8. Choose Next. User Guide 9. In Role name, enter a name for the role, such as CloudWatchAgentServerRole. Optionally give it a description. Then choose Create role. The role is now created. 10. (Optional) If the agent is going to send logs to CloudWatch Logs and you want the agent to be able to set retention policies for these log groups, you need to add the logs:PutRetentionPolicy permission to the role. For more information, see Allowing the CloudWatch agent to set log retention policy. If you're going to run the CloudWatch agent on on-premises servers, use the following steps to create the necessary IAM user. Warning This scenario requires IAM users with programmatic access and long-term credentials, which presents a security risk. To help mitigate this risk, we recommend that you provide these users with only the permissions they require to perform the task and that you remove these users when they are no longer needed. Access
acw-ug-716
acw-ug.pdf
716
for these log groups, you need to add the logs:PutRetentionPolicy permission to the role. For more information, see Allowing the CloudWatch agent to set log retention policy. If you're going to run the CloudWatch agent on on-premises servers, use the following steps to create the necessary IAM user. Warning This scenario requires IAM users with programmatic access and long-term credentials, which presents a security risk. To help mitigate this risk, we recommend that you provide these users with only the permissions they require to perform the task and that you remove these users when they are no longer needed. Access keys can be updated if necessary. For more information, see Update access keys in the IAM User Guide. To create the IAM user necessary for the CloudWatch agent to run on on-premises servers 1. Sign in to the AWS Management Console and open the IAM console at https:// console.aws.amazon.com/iam/. 2. 3. 4. In the navigation pane on the left, choose Users and then Add users. Enter the user name for the new user. Select Access key - Programmatic access and choose Next: Permissions. 5. Choose Attach existing policies directly. 6. 7. In the list of policies, select the check box next to CloudWatchAgentServerPolicy. If necessary, use the search box to find the policy. (Optional) If the agent is going to traces to X-Ray you need to also give the role the AWSXRayDaemonWriteAccess policy. To do so, find that policy in the list and select the check box next to it. 8. Choose Next: Tags. Install the CloudWatch agent using the command line 2503 Amazon CloudWatch User Guide 9. Optionally create tags for the new IAM user, and then choose Next:Review. 10. Confirm that the correct policy is listed, and choose Create user. 11. Next to the name of the new user, choose Show. Copy the access key and secret key to a file so that you can use them when installing the agent. Choose Close. Allowing the CloudWatch agent to set log retention policy You can configure the CloudWatch agent to set the retention policy for log groups that it sends log events to. If you do this, you must grant the logs:PutRetentionPolicy to the IAM role or user that the agent uses. The agent uses an IAM role to run on Amazon EC2 instances, and uses an IAM user for on-premises servers. To grant the CloudWatch agent's IAM role permission to set log retention policies 1. Sign in to the AWS Management Console and open the IAM console at https:// 2. 3. console.aws.amazon.com/iam/. In the left navigation pane, choose Roles. In the search box, Type the beginning of the name of the CloudWatch agent's IAM role. You chose this name when you created the role. It might be named CloudWatchAgentServerRole. When you see the role, choose the name of the role. 4. In the Permissions tab, choose Add permissions, Create inline policy. 5. Choose the JSON tab and copy the following policy into the box, replacing the default JSON in the box: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "logs:PutRetentionPolicy", "Resource": "*" } ] } 6. Choose Review policy. Install the CloudWatch agent using the command line 2504 Amazon CloudWatch User Guide 7. For Name, enter CloudWatchAgentPutLogsRetention or something similar, and choose Create policy. To grant the CloudWatch agent's IAM user permission to set log retention policies 1. Sign in to the AWS Management Console and open the IAM console at https:// 2. 3. console.aws.amazon.com/iam/. In the left navigation pane, choose Users. In the search box, Type the beginning of the name of the CloudWatch agent's IAM user. You chose this name when you created the user. When you see the user, choose the name of the user. 4. In the Permissions tab, choose Add inline policy. 5. Choose the JSON tab and copy the following policy into the box, replacing the default JSON in the box: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "logs:PutRetentionPolicy", "Resource": "*" } ] } 6. Choose Review policy. 7. For Name, enter CloudWatchAgentPutLogsRetention or something similar, and choose Create policy. Install and run the CloudWatch agent on your servers After you create your agent configuration file for an IAM role or IAM user, use the following steps to install and run the CloudWatch agent on your servers with that configuration. First, attach an IAM role or IAM user to the server that will run the agent. Then, on that server, download the agent package and start it using the agent configuration you created. Install the CloudWatch agent using the command line 2505 Amazon CloudWatch User Guide Download the CloudWatch agent package using an S3 download link Note To download the CloudWatch agent, your connection must use TLS 1.2 or later. You need to install the agent on each server
acw-ug-717
acw-ug.pdf
717
role or IAM user, use the following steps to install and run the CloudWatch agent on your servers with that configuration. First, attach an IAM role or IAM user to the server that will run the agent. Then, on that server, download the agent package and start it using the agent configuration you created. Install the CloudWatch agent using the command line 2505 Amazon CloudWatch User Guide Download the CloudWatch agent package using an S3 download link Note To download the CloudWatch agent, your connection must use TLS 1.2 or later. You need to install the agent on each server where you will run the agent. Amazon Linux AMIs The CloudWatch agent is available as a package in Amazon Linux 2023 and Amazon Linux 2. If you are using this operating system, you can install the package by entering the following command. You must also make sure that the IAM role attached to the instance has the CloudWatchAgentServerPolicy attached. For more information, see Create IAM roles to use with the CloudWatch agent on Amazon EC2 instances. sudo yum install amazon-cloudwatch-agent All operating systems On all supported operating systems, you can download and install the CloudWatch agent using the command line with an Amazon S3 download link as described in the following steps. For each download link, there is a general link as well as links for each Region. For example, for Amazon Linux 2023 and Amazon Linux 2 and the x86-64 architecture, three of the valid download links are: • https://amazoncloudwatch-agent.s3.amazonaws.com/amazon_linux/amd64/ latest/amazon-cloudwatch-agent.rpm • https://amazoncloudwatch-agent-us-east-1.s3.us-east-1.amazonaws.com/ amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm • https://amazoncloudwatch-agent-eu-central-1.s3.eu- central-1.amazonaws.com/amazon_linux/amd64/latest/amazon-cloudwatch- agent.rpm Install the CloudWatch agent using the command line 2506 Amazon CloudWatch User Guide Architecture Platform Download link Signature file link x86-64 Amazon Linux 2023 https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ and Amazon amazon_linux/amd64/latest/ amazon_linux/amd64/latest/ Linux 2 amazon-cloudwatch-agent.r amazon-cloudwatch-agent.r pm pm.sig x86-64 Centos x86-64 Redhat https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/amazon_linux/amd64/ ent-region.s3.region.amazonaw s.com/amazon_linux/amd64/ latest/amazon-cloudwatch- agent.rpm latest/amazon-cloudwatch- agent.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ centos/amd64/latest/amaz centos/amd64/latest/amaz on-cloudwatch-agent.rpm on-cloudwatch-agent.rpm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/centos/amd64/ ent-region.s3.region.amazonaw s.com/centos/amd64/ latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.rpm gent.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ redhat/amd64/latest/amaz on-cloudwatch-agent.rpm https://amazoncloudwatch- agent.s3.amazonaws.com/ redhat/amd64/latest/amaz on-cloudwatch-agent.rpm.sig https://amazonclou dwatch-ag https://amazonclou dwatch-ag ent-region.s3.region.amazonaw s.com/redhat/amd64/ ent-region.s3.region.amazonaw s.com/redhat/amd64/ Install the CloudWatch agent using the command line 2507 Amazon CloudWatch User Guide Architecture Platform Download link Signature file link x86-64 SUSE x86-64 Debian latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.rpm gent.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ suse/amd64/latest/amazon- suse/amd64/latest/amazon- cloudwatch-agent.rpm cloudwatch-agent.rpm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/suse/amd64/latest/ amazon-cloudwatch-age ent-region.s3.region.amazonaw s.com/suse/amd64/latest/ amazon-cloudwatch-age nt.rpm nt.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ debian/amd64/latest/amaz debian/amd64/latest/amaz on-cloudwatch-agent.deb on-cloudwatch-agent.deb.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/debian/amd64/ ent-region.s3.region.amazonaw s.com/debian/amd64/ latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.deb gent.deb.sig Install the CloudWatch agent using the command line 2508 Amazon CloudWatch User Guide Architecture Platform Download link Signature file link x86-64 Ubuntu x86-64 Oracle x86-64 macOS https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ ubuntu/amd64/latest/amaz ubuntu/amd64/latest/amaz on-cloudwatch-agent.deb on-cloudwatch-agent.deb.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/ubuntu/amd64/ ent-region.s3.region.amazonaw s.com/ubuntu/amd64/ latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.deb gent.deb.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ oracle_linux/amd64/latest/ oracle_linux/amd64/latest/ amazon-cloudwatch-agent.r amazon-cloudwatch-agent.r pm pm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/oracle_linux/amd64/ ent-region.s3.region.amazonaw s.com/oracle_linux/amd64/ latest/amazon-cloudwatch- latest/amazon-cloudwatch- agent.rpm agent.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ darwin/amd64/latest/amaz on-cloudwatch-agent.pkg https://amazoncloudwatch- agent.s3.amazonaws.com/ darwin/amd64/latest/amaz on-cloudwatch-agent.pkg.sig https://amazonclou dwatch-ag https://amazonclou dwatch-ag ent-region.s3.region.amazonaw s.com/darwin/amd64/ ent-region.s3.region.amazonaw s.com/darwin/amd64/ latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.pkg gent.pkg.sig Install the CloudWatch agent using the command line 2509 Amazon CloudWatch User Guide Architecture Platform Download link Signature file link x86-64 Windows https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ windows/amd64/latest/ama windows/amd64/latest/ama zon-cloudwatch-agent.msi zon-cloudwatch-agent.msi.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/windows/amd64/ ent-region.s3.region.amazonaw s.com/windows/amd64/ latest/amazon-cloudwatch- latest/amazon-cloudwatch- agent.msi agent.msi.sig ARM64 Amazon Linux 2023 https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ and Amazon amazon_linux/arm64/latest/ amazon_linux/arm64/latest/ Linux 2 amazon-cloudwatch-agent.r amazon-cloudwatch-agent.r pm pm.sig ARM64 Redhat https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/amazon_linux/arm64/ ent-region.s3.region.amazonaw s.com/amazon_linux/arm64/ latest/amazon-cloudwatch- latest/amazon-cloudwatch- agent.rpm agent.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ redhat/arm64/latest/amaz on-cloudwatch-agent.rpm https://amazoncloudwatch- agent.s3.amazonaws.com/ redhat/arm64/latest/amaz on-cloudwatch-agent.rpm.sig https://amazonclou dwatch-ag https://amazonclou dwatch-ag ent-region.s3.region.amazonaw s.com/redhat/arm64/latest/ ent-region.s3.region.amazonaw s.com/redhat/arm64/latest/ amazon-cloudwatch-a amazon-cloudwatch-a gent.rpm gent.rpm.sig Install the CloudWatch agent using the command line 2510 Amazon CloudWatch User Guide Architecture Platform Download link Signature file link ARM64 Ubuntu ARM64 Debian ARM64 SUSE https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ ubuntu/arm64/latest/amaz ubuntu/arm64/latest/amaz on-cloudwatch-agent.deb on-cloudwatch-agent.deb.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/ubuntu/arm64/ ent-region.s3.region.amazonaw s.com/ubuntu/arm64/ latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.deb gent.deb.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ debian/arm64/latest/amaz debian/arm64/latest/amaz on-cloudwatch-agent.deb on-cloudwatch-agent.deb.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/debian/arm64/latest/a ent-region.s3.region.amazonaw s.com/debian/arm64/latest/ mazon-cloudwatch-agent.deb amazon-cloudwatch-a gent.deb.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ suse/arm64/latest/amazon- cloudwatch-agent.rpm https://amazoncloudwatch- agent.s3.amazonaws.com/ suse/arm64/latest/amazon- cloudwatch-agent.rpm.sig https://amazonclou dwatch-ag https://amazonclou dwatch-ag ent-region.s3.region.amazonaw s.com/suse/arm64/latest/ ent-region.s3.region.amazonaw s.com/suse/arm64/latest/ amazon-cloudwatch-age amazon-cloudwatch-age nt.rpm nt.rpm.sig Install the CloudWatch agent using the command line 2511 Amazon CloudWatch User Guide To use the command line to install the CloudWatch agent on an Amazon EC2 instance 1. Download the CloudWatch agent. For a Linux server, enter the following. For download-link, use the appropriate download link from the previous table. wget download-link For a server running Windows Server, download the following file: https://amazoncloudwatch-agent.s3.amazonaws.com/windows/amd64/latest/amazon- cloudwatch-agent.msi 2. After you have downloaded the package, you can optionally verify the package signature. For more information, see Verifying the signature of the CloudWatch agent package. 3. Install the package. If you downloaded an RPM package on a Linux server, change to the directory containing the package and enter the following:
acw-ug-718
acw-ug.pdf
718
command line to install the CloudWatch agent on an Amazon EC2 instance 1. Download the CloudWatch agent. For a Linux server, enter the following. For download-link, use the appropriate download link from the previous table. wget download-link For a server running Windows Server, download the following file: https://amazoncloudwatch-agent.s3.amazonaws.com/windows/amd64/latest/amazon- cloudwatch-agent.msi 2. After you have downloaded the package, you can optionally verify the package signature. For more information, see Verifying the signature of the CloudWatch agent package. 3. Install the package. If you downloaded an RPM package on a Linux server, change to the directory containing the package and enter the following: sudo rpm -U ./amazon-cloudwatch-agent.rpm If you downloaded a DEB package on a Linux server, change to the directory containing the package and enter the following: sudo dpkg -i -E ./amazon-cloudwatch-agent.deb If you downloaded an MSI package on a server running Windows Server, change to the directory containing the package and enter the following: msiexec /i amazon-cloudwatch-agent.msi This command also works from within PowerShell. For more information about MSI command options, see Command-Line Options in the Microsoft Windows documentation. (Installing on an EC2 instance) Attaching an IAM role To enable the CloudWatch agent to send data from the instance, you must attach an IAM role to the instance. The role to attach is CloudWatchAgentServerRole. You should have created this role previously. For more information see Create IAM roles and users for use with CloudWatch agent. Install the CloudWatch agent using the command line 2512 Amazon CloudWatch User Guide For more information on attaching an IAM role to an instance, see Attaching an IAM Role to an Instance in the Amazon EC2 User Guide. (Installing on an on-premises server) Specify IAM credentials and AWS Region To enable the CloudWatch agent to send data from an on-premises server, you must specify the access key and secret key of the IAM user that you created earlier. For more information about creating this user, see Create IAM roles and users for use with CloudWatch agent. You also must specify the AWS Region to send the metrics to, using the region field in the [AmazonCloudWatchAgent] section of the AWS config file, as in the following example. [profile AmazonCloudWatchAgent] region = us-west-1 The following is an example of using the aws configure command to create a named profile for the CloudWatch agent. This example assumes that you are using the default profile name of AmazonCloudWatchAgent. To create the AmazonCloudWatchAgent profile for the CloudWatch agent 1. If you haven't already done so, install the AWS Command Line Interface on the server. For more information, see Installing the AWS CLI. 2. On Linux servers, enter the following command and follow the prompts: sudo aws configure --profile AmazonCloudWatchAgent On Windows Server, open PowerShell as an administrator, enter the following command, and follow the prompts. aws configure --profile AmazonCloudWatchAgent Verify internet access Your Amazon EC2 instances must have outbound internet access to send data to CloudWatch or CloudWatch Logs. For more information about how to configure internet access, see Internet Gateways in the Amazon VPC User Guide. The endpoints and ports to configure on your proxy are as follows: Install the CloudWatch agent using the command line 2513 Amazon CloudWatch User Guide • If you're using the agent to collect metrics, you must add the CloudWatch endpoints for the appropriate Regions to the allow list. These endpoints are listed in Amazon CloudWatch endpoints and quotas. • If you're using the agent to collect logs, you must add the CloudWatch Logs endpoints for the appropriate Regions to the allow list. These endpoints are listed in Amazon CloudWatch Logs endpoints and quotas. • If you're using Systems Manager to install the agent or Parameter Store to store your configuration file, you must add the Systems Manager endpoints for the appropriate Regions to the allow list. These endpoints are listed in AWS Systems Manager endpoints and quotas. (Optional) Modify the common configuration for proxy or Region information The CloudWatch agent includes a configuration file called common-config.toml. You can optionally use this file to specify proxy and Region information. On a server running Linux, this file is in the /opt/aws/amazon-cloudwatch-agent/etc directory. On a server running Windows Server, this file is in the C:\ProgramData\Amazon \AmazonCloudWatchAgent directory. Note We recommend that you use the common-config.toml file to provide shared configuration and credentials when you run the CloudWatch agent in an on-premise mode, and it can also be useful when you are running on Amazon EC2 and you want to reuse existing shared credential profiles and files. Enabling it via the common-config.toml has the added advantage that if your shared credentials file gets rotated with renewed credentials after they expire, the new credentials are automatically picked up by the agent without requiring a restart. The default common-config.toml is as follows. # This common-config is used to configure items
acw-ug-719
acw-ug.pdf
719
Note We recommend that you use the common-config.toml file to provide shared configuration and credentials when you run the CloudWatch agent in an on-premise mode, and it can also be useful when you are running on Amazon EC2 and you want to reuse existing shared credential profiles and files. Enabling it via the common-config.toml has the added advantage that if your shared credentials file gets rotated with renewed credentials after they expire, the new credentials are automatically picked up by the agent without requiring a restart. The default common-config.toml is as follows. # This common-config is used to configure items used for both ssm and cloudwatch access ## Configuration for shared credential. ## Default credential strategy will be used if it is absent here: ## Instance role is used for EC2 case by default. Install the CloudWatch agent using the command line 2514 Amazon CloudWatch User Guide ## AmazonCloudWatchAgent profile is used for the on-premises case by default. # [credentials] # shared_credential_profile = "{profile_name}" # shared_credential_file= "{file_name}" ## Configuration for proxy. ## System-wide environment-variable will be read if it is absent here. ## i.e. HTTP_PROXY/http_proxy; HTTPS_PROXY/https_proxy; NO_PROXY/no_proxy ## Note: system-wide environment-variable is not accessible when using ssm run-command. ## Absent in both here and environment-variable means no proxy will be used. # [proxy] # http_proxy = "{http_url}" # https_proxy = "{https_url}" # no_proxy = "{domain}" All lines are commented out initially. To set the credential profile or proxy settings, remove the # from that line and specify a value. You can edit this file manually or by using the RunShellScript Run Command in Systems Manager: • shared_credential_profile – For on-premises servers, this line specifies the IAM user credential profile to use to send data to CloudWatch. If you keep this line commented out, AmazonCloudWatchAgent is used. For more information about creating this profile, see (Installing on an on-premises server) Specify IAM credentials and AWS Region. On an EC2 instance, you can use this line to have the CloudWatch agent send data from this instance to CloudWatch in a different AWS Region. To do so, specify a named profile that includes a region field specifying the name of the Region to send to. If you specify a shared_credential_profile, you must also remove the # from the beginning of the [credentials] line. • shared_credential_file – To have the agent look for credentials in a file located in a path other than the default path, specify that complete path and file name here. The default path is / root/.aws on Linux and is C:\\Users\\Administrator\\.aws on Windows Server. The first example below shows the syntax of a valid shared_credential_file line for Linux servers, and the second example is valid for Windows Server. On Windows Server, you must escape the \ characters. shared_credential_file= "/usr/username/credentials" Install the CloudWatch agent using the command line 2515 Amazon CloudWatch User Guide shared_credential_file= "C:\\Documents and Settings\\username\\.aws\\credentials" If you specify a shared_credential_file, you must also remove the # from the beginning of the [credentials] line. • Proxy settings – If your servers use HTTP or HTTPS proxies to contact AWS services, specify those proxies in the http_proxy and https_proxy fields. If there are URLs that should be excluded from proxying, specify them in the no_proxy field, separated by commas. Start the CloudWatch agent using the command line Follow these steps to use the command line to start the CloudWatch agent on a server. For information about setting up the agent on a system that has security-enhanced Linux (SELinux) enabled, see Set up the CloudWatch agent with security-enhanced Linux (SELinux). To use the command line to start the CloudWatch agent on a server 1. Copy the agent configuration file that you want to use to the server where you're going to run the agent. Note the pathname where you copy it to. 2. In this command, -a fetch-config causes the agent to load the latest version of the CloudWatch agent configuration file, and -s starts the agent. Enter one of the following commands. Replace configuration-file-path with the path to the agent configuration file. This file is called config.json if you created it with the wizard, and might be called amazon-cloudwatch-agent.json if you created it manually. On an EC2 instance running Linux, enter the following command. sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch- config -m ec2 -s -c file:configuration-file-path On an on-premises server running Linux, enter the following: sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch- config -m onPremise -s -c file:configuration-file-path On an EC2 instance running Windows Server, enter the following from the PowerShell console: Install the CloudWatch agent using the command line 2516 Amazon CloudWatch User Guide & "C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1" - a fetch-config -m ec2 -s -c file:configuration-file-path On an on-premises server running Windows Server, enter the following from the PowerShell console: & "C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1" - a fetch-config -m onPremise -s -c file:configuration-file-path Install the CloudWatch agent using
acw-ug-720
acw-ug.pdf
720
the following command. sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch- config -m ec2 -s -c file:configuration-file-path On an on-premises server running Linux, enter the following: sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch- config -m onPremise -s -c file:configuration-file-path On an EC2 instance running Windows Server, enter the following from the PowerShell console: Install the CloudWatch agent using the command line 2516 Amazon CloudWatch User Guide & "C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1" - a fetch-config -m ec2 -s -c file:configuration-file-path On an on-premises server running Windows Server, enter the following from the PowerShell console: & "C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1" - a fetch-config -m onPremise -s -c file:configuration-file-path Install the CloudWatch agent using AWS Systems Manager Using AWS Systems Manager makes it easier to install the CloudWatch agent on a fleet of Amazon EC2 instances. You can download the agent into one server and create your CloudWatch agent configuration file for all servers in the fleet. Then you can use Systems Manager to install the agent on the other servers, using the configuration file that you created. Use the following topics to install and run the CloudWatch agent using AWS Systems Manager. Topics • Create IAM roles and users for use with the CloudWatch agent • Download, configure, and run the CloudWatch agent using SSM Create IAM roles and users for use with the CloudWatch agent Access to AWS resources requires permissions. You can create IAM roles and users that include the permissions that you need for the CloudWatch agent to write metrics to CloudWatch and for the CloudWatch agent to communicate with Amazon EC2 and AWS Systems Manager. You use IAM roles on Amazon EC2 instances, and you use IAM users with on-premises servers. One role or user enables CloudWatch agent to be installed on a server and send metrics to CloudWatch. The other role or user is needed to store your CloudWatch agent configuration in Systems Manager Parameter Store. Parameter Store enables multiple servers to use one CloudWatch agent configuration. The ability to write to Parameter Store is a broad and powerful permission. You should use it only when you need it, and it shouldn't be attached to multiple instances in your deployment. If you store your CloudWatch agent configuration in Parameter Store, we recommend the following: Install the CloudWatch agent using AWS Systems Manager 2517 Amazon CloudWatch User Guide • Set up one instance where you perform this configuration. • Use the IAM role with permissions to write to Parameter Store only on this instance. • Use the IAM role with permissions to write to Parameter Store only while you are working with and saving the CloudWatch agent configuration file. Note We recently modified the following procedures by using new CloudWatchAgentServerPolicy and CloudWatchAgentAdminPolicy policies created by Amazon, instead of requiring customers to create these policies themselves. To use these policies to write the agent configuration file to Parameter Store and then download it from Parameter Store, your agent configuration file must have a name that starts with AmazonCloudWatch-. If you have a CloudWatch agent configuration file with a file name that doesn't start with AmazonCloudWatch-, these policies can't be used to write the file to Parameter Store or to download the file from Parameter Store. Create IAM roles to use with the CloudWatch agent on Amazon EC2 instances The first procedure creates the IAM role that you must attach to each Amazon EC2 instance that runs the CloudWatch agent. This role provides permissions for reading information from the instance and writing it to CloudWatch. The second procedure creates the IAM role that you must attach to the Amazon EC2 instance being used to create the CloudWatch agent configuration file. This step is necessary if you're going to store this file in Systems Manager Parameter Store so that other servers can use it. This role provides permissions for writing to Parameter Store, in addition to the permissions for reading information from the instance and writing it to CloudWatch. This role includes permissions sufficient to run the CloudWatch agent as well as to write to Parameter Store. Note Parameter Store supports parameters in Standard and Advanced tiers. These parameter tiers are not related to the Basic, Standard, and Advanced levels of details available with the CloudWatch Agent predefined metric sets. Install the CloudWatch agent using AWS Systems Manager 2518 Amazon CloudWatch User Guide To create the IAM role necessary for each server to run the CloudWatch agent 1. Sign in to the AWS Management Console and open the IAM console at https:// console.aws.amazon.com/iam/. 2. In the navigation pane, choose Roles and then choose Create role. 3. Under Select type of trusted entity, choose AWS service. 4. 5. 6. Immediately under Common use cases, choose EC2,and then choose Next: Permissions. In the list of policies, select the check box next to CloudWatchAgentServerPolicy. If necessary, use the search box to find the policy. To
acw-ug-721
acw-ug.pdf
721
CloudWatch agent using AWS Systems Manager 2518 Amazon CloudWatch User Guide To create the IAM role necessary for each server to run the CloudWatch agent 1. Sign in to the AWS Management Console and open the IAM console at https:// console.aws.amazon.com/iam/. 2. In the navigation pane, choose Roles and then choose Create role. 3. Under Select type of trusted entity, choose AWS service. 4. 5. 6. Immediately under Common use cases, choose EC2,and then choose Next: Permissions. In the list of policies, select the check box next to CloudWatchAgentServerPolicy. If necessary, use the search box to find the policy. To use Systems Manager to install or configure the CloudWatch agent, select the box next to AmazonSSMManagedInstanceCore. This AWS managed policy enables an instance to use Systems Manager service core functionality. If necessary, use the search box to find the policy. This policy isn't necessary if you start and configure the agent only through the command line. 7. Choose Next: Tags. 8. 9. (Optional) Add one or more tag-key value pairs to organize, track, or control access for this role, and then choose Next: Review. For Role name, enter a name for your new role, such as CloudWatchAgentServerRole or another name that you prefer. 10. (Optional) For Role description, enter a description. 11. Confirm that CloudWatchAgentServerPolicy and optionally AmazonSSMManagedInstanceCore appear next to Policies. 12. Choose Create role. The role is now created. The following procedure creates the IAM role that can also write to Parameter Store. You can use this role to store the agent configuration file in Parameter Store so that other servers can retrieve it. The permissions for writing to Parameter Store provide broad access. This role shouldn't be attached to all your servers, and only administrators should use it. After you create the agent configuration file and copy it to Parameter Store, you should detach this role from the instance and use CloudWatchAgentServerRole instead. Install the CloudWatch agent using AWS Systems Manager 2519 Amazon CloudWatch User Guide To create the IAM role for an administrator to write to Parameter Store 1. Sign in to the AWS Management Console and open the IAM console at https:// console.aws.amazon.com/iam/. 2. In the navigation pane, choose Roles and then choose Create role. 3. Under Select type of trusted entity, choose AWS service. 4. 5. 6. Immediately under Choose the service that will use this role, choose EC2, and then choose Next: Permissions. In the list of policies, select the check box next to CloudWatchAgentAdminPolicy. If necessary, use the search box to find the policy. To use Systems Manager to install or configure the CloudWatch agent, select the box next to AmazonSSMManagedInstanceCore. This AWS managed policy enables an instance to use Systems Manager service core functionality. If necessary, use the search box to find the policy. This policy isn't necessary if you start and configure the agent only through the command line. 7. Choose Next: Tags. 8. 9. (Optional) Add one or more tag-key value pairs to organize, track, or control access for this role, and then choose Next: Review. For Role name, enter a name for your new role, such as CloudWatchAgentAdminRole or another name that you prefer. 10. (Optional) For Role description, enter a description. 11. Confirm that CloudWatchAgentAdminPolicy and optionally AmazonSSMManagedInstanceCore appear next to Policies. 12. Choose Create role. The role is now created. Create IAM users to use with the CloudWatch agent on on-premises servers The first procedure creates the IAM user that you need to run the CloudWatch agent. This user provides permissions to send data to CloudWatch. The second procedure creates the IAM user that you can use when creating the CloudWatch agent configuration file. Use this procedure to store this file in Systems Manager Parameter Store so that other servers can use it. This user provides permissions to write to Parameter Store, in addition to the permissions to write data to CloudWatch. Install the CloudWatch agent using AWS Systems Manager 2520 Amazon CloudWatch Note User Guide Parameter Store supports parameters in Standard and Advanced tiers. These parameter tiers are not related to the Basic, Standard, and Advanced levels of details available with the CloudWatch Agent predefined metric sets. To create the IAM user necessary for the CloudWatch agent to write data to CloudWatch 1. Sign in to the AWS Management Console and open the IAM console at https:// 2. 3. 4. 5. 6. 7. console.aws.amazon.com/iam/. In the navigation pane, choose Users, and then choose Add user. Enter the user name for the new user. For Access type, select Programmatic access, and then choose Next: Permissions. For Set permissions, choose Attach existing policies directly. In the list of policies, select the check box next to CloudWatchAgentServerPolicy. If necessary, use the search box to find the policy. To use Systems Manager to install or configure the CloudWatch agent,
acw-ug-722
acw-ug.pdf
722
CloudWatch agent to write data to CloudWatch 1. Sign in to the AWS Management Console and open the IAM console at https:// 2. 3. 4. 5. 6. 7. console.aws.amazon.com/iam/. In the navigation pane, choose Users, and then choose Add user. Enter the user name for the new user. For Access type, select Programmatic access, and then choose Next: Permissions. For Set permissions, choose Attach existing policies directly. In the list of policies, select the check box next to CloudWatchAgentServerPolicy. If necessary, use the search box to find the policy. To use Systems Manager to install or configure the CloudWatch agent, select the box next to AmazonSSMManagedInstanceCore. This AWS managed policy enables an instance to use Systems Manager service core functionality. (If necessary, use the search box to find the policy. This policy isn't necessary if you start and configure the agent only through the command line.) 8. Choose Next: Tags. 9. (Optional) Add one or more tag-key value pairs to organize, track, or control access for this role, and then choose Next: Review. 10. Confirm that the correct policies are listed, and then choose Create user. 11. In the row for the new user, choose Show. Copy the access key and secret key to a file so that you can use them when installing the agent. Choose Close. The following procedure creates the IAM user that can also write to Parameter Store. If you're going to store the agent configuration file in Parameter Store so that other servers can use it, you need to use this IAM user. This IAM user provides permissions for writing to Parameter Store. This user also provides the permissions for reading information from the instance and writing it to CloudWatch. The permissions for writing to Systems Manager Parameter Store provide broad Install the CloudWatch agent using AWS Systems Manager 2521 Amazon CloudWatch User Guide access. This IAM user shouldn't be attached to all your servers, and only administrators should use it. You should use this IAM user only when you are storing the agent configuration file in Parameter Store. To create the IAM user necessary to store the configuration file in Parameter Store and send information to CloudWatch 1. Sign in to the AWS Management Console and open the IAM console at https:// console.aws.amazon.com/iam/. 2. 3. 4. 5. 6. 7. In the navigation pane, choose Users, and then choose Add user. Enter the user name for the new user. For Access type, select Programmatic access, and then choose Next: Permissions. For Set permissions, choose Attach existing policies directly. In the list of policies, select the check box next to CloudWatchAgentAdminPolicy. If necessary, use the search box to find the policy. To use Systems Manager to install or configure the CloudWatch agent, select the check box next to AmazonSSMManagedInstanceCore. This AWS managed policy enables an instance to use Systems Manager service core functionality. (If necessary, use the search box to find the policy. This policy isn't necessary if you start and configure the agent only through the command line.) 8. Choose Next: Tags. 9. (Optional) Add one or more tag-key value pairs to organize, track, or control access for this role, and then choose Next: Review. 10. Confirm that the correct policies are listed, and then choose Create user. 11. In the row for the new user, choose Show. Copy the access key and secret key to a file so that you can use them when installing the agent. Choose Close. Download, configure, and run the CloudWatch agent using SSM This section explains how to use Systems Manager to download the agent and then how to create your agent configuration file. Before you can use Systems Manager to download the agent, you must make sure that the instance is configured correctly for Systems Manager. Install the CloudWatch agent using AWS Systems Manager 2522 Amazon CloudWatch Install or update the SSM Agent User Guide On an Amazon EC2 instance, the CloudWatch agent requires that the instance is running version 2.2.93.0 or later of the SSM Agent. Before you install the CloudWatch agent, update or install SSM Agent on the instance if you haven't already done so. For information about installing or updating SSM Agent on an instance running Linux, see Installing and Configuring SSM Agent on Linux Instances in the AWS Systems Manager User Guide. For information about installing or updating the SSM Agent, see Working with SSM Agent in the AWS Systems Manager User Guide. Verify Systems Manager prerequisites Before you use Systems Manager Run Command to install and configure the CloudWatch agent, verify that your instances meet the minimum Systems Manager requirements. For more information, see Systems Manager Prerequisites in the AWS Systems Manager User Guide. Verify internet access Your Amazon EC2 instances must be able to connect to CloudWatch endpoints. This can be by
acw-ug-723
acw-ug.pdf
723
running Linux, see Installing and Configuring SSM Agent on Linux Instances in the AWS Systems Manager User Guide. For information about installing or updating the SSM Agent, see Working with SSM Agent in the AWS Systems Manager User Guide. Verify Systems Manager prerequisites Before you use Systems Manager Run Command to install and configure the CloudWatch agent, verify that your instances meet the minimum Systems Manager requirements. For more information, see Systems Manager Prerequisites in the AWS Systems Manager User Guide. Verify internet access Your Amazon EC2 instances must be able to connect to CloudWatch endpoints. This can be by Internet Gateway, NAT gateway, or CloudWatch Interface VPC endpoints. For more information about how to configure internet access, see Internet Gateways in the Amazon VPC User Guide. The endpoints and ports to configure on your proxy are as follows: • If you're using the agent to collect metrics, you must allow list the CloudWatch endpoints for the appropriate Regions. These endpoints are listed in Amazon CloudWatch in the Amazon Web Services General Reference. • If you're using the agent to collect logs, you must allow list the CloudWatch Logs endpoints for the appropriate Regions. These endpoints are listed in Amazon CloudWatch Logs in the Amazon Web Services General Reference. • If you're using Systems Manager to install the agent or Parameter Store to store your configuration file, you must allow list the Systems Manager endpoints for the appropriate Regions. These endpoints are listed in AWS Systems Manager in the Amazon Web Services General Reference. Download the CloudWatch agent package to your first instance Use the following steps to download the CloudWatch agent package using Systems Manager. Install the CloudWatch agent using AWS Systems Manager 2523 Amazon CloudWatch User Guide To download the CloudWatch agent using Systems Manager 1. Open the Systems Manager console at https://console.aws.amazon.com/systems-manager/. 2. In the navigation pane, choose Run Command. -or- If the AWS Systems Manager home page opens, scroll down and choose Explore Run Command. 3. Choose Run command. 4. 5. 6. 7. In the Command document list, choose AWS-ConfigureAWSPackage. In the Targets area, choose the instance to install the CloudWatch agent on. If you don't see a specific instance, it might not be configured as a managed instance for use with Systems Manager. For more information, see Setting Up AWS Systems Manager for Hybrid Environments in the AWS Systems Manager User Guide. In the Action list, choose Install. In the Name field, enter AmazonCloudWatchAgent. 8. Keep Version set to latest to install the latest version of the agent. 9. Choose Run. 10. Optionally, in the Targets and outputs areas, select the button next to an instance name and choose View output. Systems Manager should show that the agent was successfully installed. Create and modify the agent configuration file After you have downloaded the CloudWatch agent, you must create the configuration file before you start the agent on any servers. If you're going to save your agent configuration file in the Systems Manager Parameter Store, you must use an EC2 instance to save to the Parameter Store. Additionally, you must first attach to that instance the CloudWatchAgentAdminRole IAM role. For more information about attaching roles, see Attaching an IAM Role to an Instance in the Amazon EC2 User Guide. For more information about creating the CloudWatch agent configuration file, see Create the CloudWatch agent configuration file. Install the CloudWatch agent using AWS Systems Manager 2524 Amazon CloudWatch User Guide Install and start the CloudWatch agent on additional EC2 instances using your agent configuration After you have a CloudWatch agent configuration saved in Parameter Store, you can use it when you install the agent on other servers. For each of these servers, follow the steps listed previously in this section to verify the Systems Manager prerequisites, the version of the SSM Agent, and internet access. Then use the following instructions to install the CloudWatch agent on the additional instances, using the CloudWatch agent configuration file that you have created. Step 1: Download and install the CloudWatch agent To be able to send the CloudWatch data to a different Region, make sure that the IAM role that you attached to this instance has permissions to write the CloudWatch data in that Region. Following is an example of using the aws configure command to create a named profile for the CloudWatch agent. This example assumes that you are using the default profile name of AmazonCloudWatchAgent. To create the AmazonCloudWatchAgent profile for the CloudWatch agent • On Linux servers, type the following command and follow the prompts: sudo aws configure --profile AmazonCloudWatchAgent On Windows Server, open PowerShell as an administrator, type the following command and follow the prompts. aws configure --profile AmazonCloudWatchAgent Install the CloudWatch agent on additional EC2 instances using your agent configuration After you have a CloudWatch agent
acw-ug-724
acw-ug.pdf
724
data in that Region. Following is an example of using the aws configure command to create a named profile for the CloudWatch agent. This example assumes that you are using the default profile name of AmazonCloudWatchAgent. To create the AmazonCloudWatchAgent profile for the CloudWatch agent • On Linux servers, type the following command and follow the prompts: sudo aws configure --profile AmazonCloudWatchAgent On Windows Server, open PowerShell as an administrator, type the following command and follow the prompts. aws configure --profile AmazonCloudWatchAgent Install the CloudWatch agent on additional EC2 instances using your agent configuration After you have a CloudWatch agent configuration saved in Parameter Store, you can use it when you install the agent on other servers. For each of these servers, follow the steps listed previously in this section to verify the Systems Manager prerequisites, the version of the SSM Agent, and internet access. Then use the following instructions to install the CloudWatch agent on the additional instances, using the CloudWatch agent configuration file that you have created. Install the CloudWatch agent using AWS Systems Manager 2525 Amazon CloudWatch User Guide Step 1: Download and install the CloudWatch agent You need to install the agent on each server where you will run the agent. The CloudWatch agent is available as a package in Amazon Linux 2023 and Amazon Linux 2. If you are using this operating system, you can use Systems Manager to install the package by using the following steps. Note You must also make sure that the IAM role attached to the instance has the CloudWatchAgentServerPolicy attached. For more information, see Create IAM roles to use with the CloudWatch agent on Amazon EC2 instances. To use Systems Manager to install the CloudWatch agent package 1. Open the Systems Manager console at https://console.aws.amazon.com/systems-manager/. 2. In the navigation pane, choose Run Command. -or- If the AWS Systems Manager home page opens, scroll down and choose Explore Run Command. 3. Choose Run command. 4. In the Command document list, select AWS-RunShellScript. Then paste the following into Command parameters. sudo yum install amazon-cloudwatch-agent 5. Choose Run On all supported operating systems, you can download the CloudWatch agent package using either Systems Manager Run Command or an Amazon S3 download link. For information about using an Amazon S3 download link, see Download the CloudWatch agent package. Note When you install or update the CloudWatch agent, only the Uninstall and reinstall option is supported. You can't use the In-place update option. Install the CloudWatch agent using AWS Systems Manager 2526 Amazon CloudWatch User Guide Systems Manager Run Command enables you to manage the configuration of your instances. You specify a Systems Manager document, specify parameters, and execute the command on one or more instances. SSM Agent on the instance processes the command and configures the instance as specified. To download the CloudWatch agent using Run Command 1. Open the Systems Manager console at https://console.aws.amazon.com/systems-manager/. 2. In the navigation pane, choose Run Command. -or- If the AWS Systems Manager home page opens, scroll down and choose Explore Run Command. 3. Choose Run command. 4. 5. 6. 7. In the Command document list, choose AWS-ConfigureAWSPackage. In the Targets area, choose the instance on which to install the CloudWatch agent. If you do not see a specific instance, it might not be configured for Run Command. For more information, see Setting Up AWS Systems Manager for Hybrid Environments in the AWS Systems Manager User Guide. In the Action list, choose Install. In the Name box, enter AmazonCloudWatchAgent. 8. Keep Version set to latest to install the latest version of the agent. 9. Choose Run. 10. Optionally, in the Targets and outputs areas, select the button next to an instance name and choose View output. Systems Manager should show that the agent was successfully installed. Step 2: Start the CloudWatch agent using your agent configuration file Follow these steps to start the agent using Systems Manager Run Command. For information about setting up the agent on a system that has security-enhanced Linux (SELinux) enabled, see Set up the CloudWatch agent with security-enhanced Linux (SELinux). To start the CloudWatch agent using Run Command 1. Open the Systems Manager console at https://console.aws.amazon.com/systems-manager/. Install the CloudWatch agent using AWS Systems Manager 2527 Amazon CloudWatch User Guide 2. In the navigation pane, choose Run Command. -or- If the AWS Systems Manager home page opens, scroll down and choose Explore Run Command. 3. Choose Run command. 4. 5. 6. 7. 8. In the Command document list, choose AmazonCloudWatch-ManageAgent. In the Targets area, choose the instance where you installed the CloudWatch agent. In the Action list, choose configure. In the Optional Configuration Source list, choose ssm. In the Optional Configuration Location box, enter the name of the Systems Manager parameter name of the agent configuration file that you created and saved to Systems
acw-ug-725
acw-ug.pdf
725
Manager 2527 Amazon CloudWatch User Guide 2. In the navigation pane, choose Run Command. -or- If the AWS Systems Manager home page opens, scroll down and choose Explore Run Command. 3. Choose Run command. 4. 5. 6. 7. 8. In the Command document list, choose AmazonCloudWatch-ManageAgent. In the Targets area, choose the instance where you installed the CloudWatch agent. In the Action list, choose configure. In the Optional Configuration Source list, choose ssm. In the Optional Configuration Location box, enter the name of the Systems Manager parameter name of the agent configuration file that you created and saved to Systems Manager Parameter Store, as explained in Create the CloudWatch agent configuration file. 9. In the Optional Restart list, choose yes to start the agent after you have finished these steps. 10. Choose Run. 11. Optionally, in the Targets and outputs areas, select the button next to an instance name and choose View output. Systems Manager should show that the agent was successfully started. (Optional) Modify the common configuration and named profile for CloudWatch agent The CloudWatch agent includes a configuration file called common-config.toml. You can use this file to optionally specify proxy and Region information. On a server running Linux, this file is in the /opt/aws/amazon-cloudwatch-agent/etc directory. On a server running Windows Server, this file is in the C:\ProgramData\Amazon \AmazonCloudWatchAgent directory. The default common-config.toml is as follows: # This common-config is used to configure items used for both ssm and cloudwatch access ## Configuration for shared credential. ## Default credential strategy will be used if it is absent here: ## Instance role is used for EC2 case by default. ## AmazonCloudWatchAgent profile is used for onPremise case by default. Install the CloudWatch agent using AWS Systems Manager 2528 Amazon CloudWatch # [credentials] # shared_credential_profile = "{profile_name}" # shared_credential_file= "{file_name}" User Guide ## Configuration for proxy. ## System-wide environment-variable will be read if it is absent here. ## i.e. HTTP_PROXY/http_proxy; HTTPS_PROXY/https_proxy; NO_PROXY/no_proxy ## Note: system-wide environment-variable is not accessible when using ssm run-command. ## Absent in both here and environment-variable means no proxy will be used. # [proxy] # http_proxy = "{http_url}" # https_proxy = "{https_url}" # no_proxy = "{domain}" All lines are commented out initially. To set the credential profile or proxy settings, remove the # from that line and specify a value. You can edit this file manually, or by using the RunShellScript Run Command in Systems Manager: • shared_credential_profile – For on-premises servers, this line specifies the IAM user credential profile to use to send data to CloudWatch. If you keep this line commented out, AmazonCloudWatchAgent is used. On an EC2 instance, you can use this line to have the CloudWatch agent send data from this instance to CloudWatch in a different AWS Region. To do so, specify a named profile that includes a region field specifying the name of the Region to send to. If you specify a shared_credential_profile, you must also remove the # from the beginning of the [credentials] line. • shared_credential_file – To have the agent look for credentials in a file located in a path other than the default path, specify that complete path and file name here. The default path is / root/.aws on Linux and is C:\\Users\\Administrator\\.aws on Windows Server. The first example below shows the syntax of a valid shared_credential_file line for Linux servers, and the second example is valid for Windows Server. On Windows Server, you must escape the \ characters. shared_credential_file= "/usr/username/credentials" shared_credential_file= "C:\\Documents and Settings\\username\\.aws\\credentials" Install the CloudWatch agent using AWS Systems Manager 2529 Amazon CloudWatch User Guide If you specify a shared_credential_file, you must also remove the # from the beginning of the [credentials] line. • Proxy settings – If your servers use HTTP or HTTPS proxies to contact AWS services, specify those proxies in the http_proxy and https_proxy fields. If there are URLs that should be excluded from proxying, specify them in the no_proxy field, separated by commas. Install the CloudWatch agent on on-premises servers If you downloaded the CloudWatch agent on a computer and created your agent configuration file, you can use that configuration file to install the agent in other on-premises servers. Download the CloudWatch agent on an on-premises server You can download the CloudWatch agent package using either Systems Manager Run Command or an Amazon S3 download link. For information about using an Amazon S3 download link, see Download the CloudWatch agent package. Download using Systems Manager To use Systems Manager Run Command, you must register your on-premises server with Amazon EC2 Systems Manager. For more information, see Setting Up Systems Manager in Hybrid Environments in the AWS Systems Manager User Guide. If you have already registered your server, update SSM Agent to the latest version. For information about updating SSM Agent on a server running Linux, see Install SSM Agent for
acw-ug-726
acw-ug.pdf
726
the CloudWatch agent package using either Systems Manager Run Command or an Amazon S3 download link. For information about using an Amazon S3 download link, see Download the CloudWatch agent package. Download using Systems Manager To use Systems Manager Run Command, you must register your on-premises server with Amazon EC2 Systems Manager. For more information, see Setting Up Systems Manager in Hybrid Environments in the AWS Systems Manager User Guide. If you have already registered your server, update SSM Agent to the latest version. For information about updating SSM Agent on a server running Linux, see Install SSM Agent for a Hybrid Environment (Linux) in the AWS Systems Manager User Guide. For information about updating the SSM Agent on a server running Windows Server, see Install SSM Agent for a Hybrid Environment (Windows) in the AWS Systems Manager User Guide. To use the SSM Agent to download the CloudWatch agent package on an on-premises server 1. Open the Systems Manager console at https://console.aws.amazon.com/systems-manager/. 2. In the navigation pane, choose Run Command. -or- If the AWS Systems Manager home page opens, scroll down and choose Explore Run Command. Install the CloudWatch agent on on-premises servers 2530 Amazon CloudWatch 3. Choose Run command. User Guide 4. 5. 6. 7. In the Command document list, select the button next to AWS-ConfigureAWSPackage. In the Targets area, select the server to install the CloudWatch agent on. If you don't see a specific server, it might not be configured for Run Command. For more information, see Setting Up AWS Systems Manager for Hybrid Environments in the AWS Systems Manager User Guide. In the Action list, choose Install. In the Name box, enter AmazonCloudWatchAgent. 8. Keep Version blank to install the latest version of the agent. 9. Choose Run. The agent package is downloaded, and the next steps are to configure and start it. (Installing on an on-premises server) Specify IAM credentials and AWS Region To enable the CloudWatch agent to send data from an on-premises server, you must specify the access key and secret key of the IAM user that you created earlier. For more information about creating this user, see Create IAM roles and users for use with the CloudWatch agent. You also must specify the AWS Region to send the metrics to, using the region field. Following is an example of this file. [AmazonCloudWatchAgent] aws_access_key_id=my_access_key aws_secret_access_key=my_secret_key region = us-west-1 For my_access_key and my_secret_key, use the keys from the IAM user that doesn't have the permissions to write to Systems Manager Parameter Store. For more information about the IAM users needed for CloudWatch agent, see Create IAM users to use with the CloudWatch agent on on- premises servers. If you name this profile AmazonCloudWatchAgent, you don't need to do anything more. Optionally, you can give it a different name and specify that name as the value for shared_credential_profile in the common-config.toml file, which is explained in the following section. Install the CloudWatch agent on on-premises servers 2531 Amazon CloudWatch User Guide Following is an example of using the aws configure command to create a named profile for the CloudWatch agent. This example assumes that you're using the default profile name of AmazonCloudWatchAgent. To create the AmazonCloudWatchAgent profile for the CloudWatch agent 1. If you haven't already done so, install the AWS Command Line Interface on the server. For more information, see Installing the AWS CLI. 2. On Linux servers, enter the following command and follow the prompts: sudo aws configure --profile AmazonCloudWatchAgent On Windows Server, open PowerShell as an administrator, enter the following command, and follow the prompts. aws configure --profile AmazonCloudWatchAgent (Optional) Modifying the common configuration and named profile for CloudWatch agent The CloudWatch agent includes a configuration file called common-config.toml. You can optionally use this file to specify proxy and Region information. On a server running Linux, this file is in the /opt/aws/amazon-cloudwatch-agent/etc directory. On a server running Windows Server, this file is in the C:\ProgramData\Amazon \AmazonCloudWatchAgent directory. The default common-config.toml is as follows: # This common-config is used to configure items used for both ssm and cloudwatch access ## Configuration for shared credential. ## Default credential strategy will be used if it is absent here: ## Instance role is used for EC2 case by default. ## AmazonCloudWatchAgent profile is used for onPremise case by default. # [credentials] # shared_credential_profile = "{profile_name}" # shared_credential_file= "{file_name}" Install the CloudWatch agent on on-premises servers 2532 Amazon CloudWatch User Guide ## Configuration for proxy. ## System-wide environment-variable will be read if it is absent here. ## i.e. HTTP_PROXY/http_proxy; HTTPS_PROXY/https_proxy; NO_PROXY/no_proxy ## Note: system-wide environment-variable is not accessible when using ssm run-command. ## Absent in both here and environment-variable means no proxy will be used. # [proxy] # http_proxy = "{http_url}" # https_proxy = "{https_url}" # no_proxy = "{domain}" All lines are commented out initially. To set
acw-ug-727
acw-ug.pdf
727
case by default. ## AmazonCloudWatchAgent profile is used for onPremise case by default. # [credentials] # shared_credential_profile = "{profile_name}" # shared_credential_file= "{file_name}" Install the CloudWatch agent on on-premises servers 2532 Amazon CloudWatch User Guide ## Configuration for proxy. ## System-wide environment-variable will be read if it is absent here. ## i.e. HTTP_PROXY/http_proxy; HTTPS_PROXY/https_proxy; NO_PROXY/no_proxy ## Note: system-wide environment-variable is not accessible when using ssm run-command. ## Absent in both here and environment-variable means no proxy will be used. # [proxy] # http_proxy = "{http_url}" # https_proxy = "{https_url}" # no_proxy = "{domain}" All lines are commented out initially. To set the credential profile or proxy settings, remove the # from that line and specify a value. You can edit this file manually, or by using the RunShellScript Run Command in Systems Manager: • shared_credential_profile – For on-premises servers, this line specifies the IAM user credential profile to use to send data to CloudWatch. If you keep this line commented out, AmazonCloudWatchAgent is used. For more information about creating this profile, see (Installing on an on-premises server) Specify IAM credentials and AWS Region. On an EC2 instance, you can use this line to have the CloudWatch agent send data from this instance to CloudWatch in a different AWS Region. To do so, specify a named profile that includes a region field specifying the name of the Region to send to. If you specify a shared_credential_profile, you must also remove the # from the beginning of the [credentials] line. • shared_credential_file – To have the agent look for credentials in a file located in a path other than the default path, specify that complete path and file name here. The default path is / root/.aws on Linux and is C:\\Users\\Administrator\\.aws on Windows Server. The first example below shows the syntax of a valid shared_credential_file line for Linux servers, and the second example is valid for Windows Server. On Windows Server, you must escape the \ characters. shared_credential_file= "/usr/username/credentials" shared_credential_file= "C:\\Documents and Settings\\username\\.aws\\credentials" Install the CloudWatch agent on on-premises servers 2533 Amazon CloudWatch User Guide If you specify a shared_credential_file, you must also remove the # from the beginning of the [credentials] line. • Proxy settings – If your servers use HTTP or HTTPS proxies to contact AWS services, specify those proxies in the http_proxy and https_proxy fields. If there are URLs that should be excluded from proxying, specify them in the no_proxy field, separated by commas. Starting the CloudWatch agent You can start the CloudWatch agent using either Systems Manager Run Command or the command line. For information about setting up the agent on a system that has security-enhanced Linux (SELinux) enabled, see Set up the CloudWatch agent with security-enhanced Linux (SELinux). To use SSM Agent to start the CloudWatch agent on an on-premises server 1. Open the Systems Manager console at https://console.aws.amazon.com/systems-manager/. 2. In the navigation pane, choose Run Command. -or- If the AWS Systems Manager home page opens, scroll down and choose Explore Run Command. 3. Choose Run command. 4. 5. 6. 7. 8. In the Command document list, select the button next to AmazonCloudWatch- ManageAgent. In the Targets area, select the instance where you installed the agent. In the Action list, choose configure. In the Mode list, choose onPremise. In the Optional Configuration Location box, enter the name of the agent configuration file that you created with the wizard and stored in the Parameter Store. 9. Choose Run. The agent starts with the configuration you specified in the configuration file. Install the CloudWatch agent on on-premises servers 2534 Amazon CloudWatch User Guide To use the command line to start the CloudWatch agent on an on-premises server • In this command, -a fetch-config causes the agent to load the latest version of the CloudWatch agent configuration file, and -s starts the agent. Linux: If you saved the configuration file in the Systems Manager Parameter Store, enter the following: sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch- config -m onPremise -s -c ssm:configuration-parameter-store-name Linux: If you saved the configuration file on the local computer, enter the following command. Replace configuration-file-path with the path to the agent configuration file. This file is called config.json if you created it with the wizard, and might be called amazon- cloudwatch-agent.json if you created it manually. sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch- config -m onPremise -s -c file:configuration-file-path Windows Server: If you saved the agent configuration file in Systems Manager Parameter Store, enter the following from the PowerShell console: & "C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1" - a fetch-config -m onPremise -s -c ssm:configuration-parameter-store-name Windows Server: If you saved the agent configuration file on the local computer, enter the following from the PowerShell console. Replace configuration-file-path with the path to the agent configuration file. This file is called config.json if you created it with the wizard, and might be called amazon-cloudwatch-agent.json if you created it manually.
acw-ug-728
acw-ug.pdf
728
cloudwatch-agent.json if you created it manually. sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch- config -m onPremise -s -c file:configuration-file-path Windows Server: If you saved the agent configuration file in Systems Manager Parameter Store, enter the following from the PowerShell console: & "C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1" - a fetch-config -m onPremise -s -c ssm:configuration-parameter-store-name Windows Server: If you saved the agent configuration file on the local computer, enter the following from the PowerShell console. Replace configuration-file-path with the path to the agent configuration file. This file is called config.json if you created it with the wizard, and might be called amazon-cloudwatch-agent.json if you created it manually. & "C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1" - a fetch-config -m onPremise -s -c file:configuration-file-path Install the CloudWatch agent on on-premises servers 2535 Amazon CloudWatch User Guide Install the CloudWatch agent on new instances using AWS CloudFormation This section describes how to install the CloudWatch agent on new Amazon EC2 instances using AWS CloudFormation. Note Amazon uploaded several AWS CloudFormation templates to GitHub that can help you install and update the CloudWatch agent on new Amazon EC2 instances. For more information about using AWS CloudFormation, see What is AWS CloudFormation?. The template location is Deploy the Amazon CloudWatch agent to EC2 instances using AWS CloudFormation. This location includes both inline and ssm directories. Each of these directories contains templates for both Linux and Windows instances. • The templates in the inline directory have the CloudWatch agent configuration embedded into the AWS CloudFormation template. By default, the Linux templates collect the metrics mem_used_percent and swap_used_percent, and the Windows templates collect Memory % Committed Bytes In Use and Paging File % Usage. To modify these templates to collect different metrics, modify the following section of the template. The following example is from the template for Linux servers. Follow the format and syntax of the agent configuration file to make these changes. For more information, see Manually create or edit the CloudWatch agent configuration file. { "metrics":{ "append_dimensions":{ "AutoScalingGroupName":"${!aws:AutoScalingGroupName}", "ImageId":"${!aws:ImageId}", "InstanceId":"${!aws:InstanceId}", "InstanceType":"${!aws:InstanceType}" }, "metrics_collected":{ "mem":{ "measurement":[ "mem_used_percent" Install the CloudWatch agent on new instances using AWS CloudFormation 2536 User Guide Amazon CloudWatch ] }, "swap":{ "measurement":[ "swap_used_percent" ] } } } } Note In the inline templates, all placeholder variables must have an exclamation mark (!) before them as an escape character. You can see this in the example template. If you add other placeholder variables, be sure to add an exclamation mark before the name. • The templates in the ssm directory load an agent configuration file from Parameter Store. To use these templates, you must first create a configuration file and upload it to Parameter Store. You then provide the Parameter Store name of the file in the template. You can create the configuration file manually or by using the wizard. For more information, see Create the CloudWatch agent configuration file. You can use both types of templates for installing the CloudWatch agent and for updating the agent configuration. For information about setting up the agent on a system that has security-enhanced Linux (SELinux) enabled, see Set up the CloudWatch agent with security-enhanced Linux (SELinux). Tutorial: Install and configure the CloudWatch agent using an AWS CloudFormation inline template This tutorial walks you through using AWS CloudFormation to install the CloudWatch agent on a new Amazon EC2 instance. This tutorial installs on a new instance running Amazon Linux 2 using the inline templates, which don't require the use of the JSON configuration file or Parameter Store. The inline template includes the agent configuration in the template. In this tutorial, you use the default agent configuration contained in the template. After the procedure for installing the agent, the tutorial continues with how to update the agent. Tutorial: Install using an AWS CloudFormation inline template 2537 Amazon CloudWatch User Guide To use AWS CloudFormation to install the CloudWatch agent on a new instance 1. Download the template from GitHub. In this tutorial, download the inline template for Amazon Linux 2 as follows: curl -O https://raw.githubusercontent.com/aws-cloudformation/aws-cloudformation- templates/main/Solutions/AmazonCloudWatchAgent/inline/amazon_linux.yaml 2. Open the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation. 3. Choose Create stack. 4. For Choose a template, select Upload a template to Amazon S3, choose the downloaded template, and choose Next. 5. On the Specify Details page, fill out the following parameters and choose Next: • Stack name: Choose a stack name for your AWS CloudFormation stack. • IAMRole: Choose an IAM role that has permissions to write CloudWatch metrics, logs, and traces. For more information, see Create IAM roles to use with the CloudWatch agent on Amazon EC2 instances. • InstanceAMI: Choose an AMI that is valid in the Region where you're going to launch your stack. • InstanceType: Choose a valid instance type. • KeyName: To enable SSH access to the new instance, choose an existing Amazon EC2 key pair. If you don't already have an Amazon EC2 key pair,
acw-ug-729
acw-ug.pdf
729
and choose Next: • Stack name: Choose a stack name for your AWS CloudFormation stack. • IAMRole: Choose an IAM role that has permissions to write CloudWatch metrics, logs, and traces. For more information, see Create IAM roles to use with the CloudWatch agent on Amazon EC2 instances. • InstanceAMI: Choose an AMI that is valid in the Region where you're going to launch your stack. • InstanceType: Choose a valid instance type. • KeyName: To enable SSH access to the new instance, choose an existing Amazon EC2 key pair. If you don't already have an Amazon EC2 key pair, you can create one in the AWS Management Console. For more information, see Amazon EC2 Key Pairs in the Amazon EC2 User Guide. • SSHLocation: Specifies the IP address range that can be used to connect to the instance using SSH. The default allows access from any IP address. 6. On the Options page, you can choose to tag your stack resources. Choose Next. 7. On the Review page, review your information, acknowledge that the stack might create IAM resources, and then choose Create. If you refresh the console, you see that the new stack has the CREATE_IN_PROGRESS status. 8. When the instance is created, you can see it in the Amazon EC2 console. Optionally, you can connect to the host and check the progress. Use the following command to confirm that the agent is installed: Tutorial: Install using an AWS CloudFormation inline template 2538 Amazon CloudWatch User Guide rpm -qa amazon-cloudwatch-agent Use the following command to confirm that the agent is running: ps aux | grep amazon-cloudwatch-agent The next procedure demonstrates using AWS CloudFormation to update the CloudWatch agent using an inline template. The default inline template collects the mem_used_percent metric. In this tutorial, you change the agent configuration to stop collecting that metric. To use AWS CloudFormation to update the CloudWatch agent 1. In the template that you downloaded in the previous procedure, remove the following lines and then save the template: "mem": { "measurement": [ "mem_used_percent" ] }, 2. Open the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation. 3. On the AWS CloudFormation dashboard, select the stack that you created and choose Update Stack. 4. For Select Template, select Upload a template to Amazon S3, choose the template that you modified, and choose Next. 5. On the Options page, choose Next and then Next. 6. On the Review page, review your information and choose Update. After some time, you see UPDATE_COMPLETE. Tutorial: Install using an AWS CloudFormation inline template 2539 Amazon CloudWatch User Guide Tutorial: Install the CloudWatch agent using AWS CloudFormation and Parameter Store This tutorial walks you through using AWS CloudFormation to install the CloudWatch agent on a new Amazon EC2 instance. This tutorial installs on a new instance running Amazon Linux 2 using an agent configuration file that you create and save in Parameter Store. After the procedure for installing the agent, the tutorial continues with how to update the agent. To use AWS CloudFormation to install the CloudWatch agent on a new instance using a configuration from Parameter Store 1. If you haven't done so already, download the CloudWatch agent package to one of your computers so that you can create the agent configuration file. For more information and downloading the agent using Parameter Store, see Download, configure, and run the CloudWatch agent using SSM. For more information on downloading the package using the command line, see Download and configure the CloudWatch agent using the command line. 2. Create the agent configuration file and save it in Parameter Store. For more information, see Create the CloudWatch agent configuration file. 3. Download the template from GitHub as follows: curl -O https://raw.githubusercontent.com/awslabs/aws-cloudformation-templates/ master/aws/solutions/AmazonCloudWatchAgent/ssm/amazon_linux.template 4. Open the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation. 5. Choose Create stack. 6. For Choose a template, select Upload a template to Amazon S3, choose the template that you downloaded, and choose Next. 7. On the Specify Details page, fill out the following parameters accordingly and choose Next: • Stack name: Choose a stack name for your AWS CloudFormation stack. • IAMRole: Choose an IAM role that has permissions to write CloudWatch metrics, logs, and traces. For more information, see Create IAM roles to use with the CloudWatch agent on Amazon EC2 instances. • InstanceAMI: Choose an AMI that is valid in the Region where you're going to launch your stack. • InstanceType: Choose a valid instance type. Tutorial: Install the CloudWatch agent using AWS CloudFormation and Parameter Store 2540 Amazon CloudWatch User Guide • KeyName: To enable SSH access to the new instance, choose an existing Amazon EC2 key pair. If you don't already have an Amazon EC2 key pair, you can create one in the AWS Management Console. For more information, see Amazon EC2 Key Pairs in the Amazon EC2 User Guide.
acw-ug-730
acw-ug.pdf
730
use with the CloudWatch agent on Amazon EC2 instances. • InstanceAMI: Choose an AMI that is valid in the Region where you're going to launch your stack. • InstanceType: Choose a valid instance type. Tutorial: Install the CloudWatch agent using AWS CloudFormation and Parameter Store 2540 Amazon CloudWatch User Guide • KeyName: To enable SSH access to the new instance, choose an existing Amazon EC2 key pair. If you don't already have an Amazon EC2 key pair, you can create one in the AWS Management Console. For more information, see Amazon EC2 Key Pairs in the Amazon EC2 User Guide. • SSHLocation: Specifies the IP address range that can be used to connect to the instance using SSH. The default allows access from any IP address. • SSMKey: Specifies the agent configuration file that you created and saved in Parameter Store. 8. On the Options page, you can choose to tag your stack resources. Choose Next. 9. On the Review page, review your information, acknowledge that the stack might create IAM resources, and then choose Create. If you refresh the console, you see that the new stack has the CREATE_IN_PROGRESS status. 10. When the instance is created, you can see it in the Amazon EC2 console. Optionally, you can connect to the host and check the progress. Use the following command to confirm that the agent is installed: rpm -qa amazon-cloudwatch-agent Use the following command to confirm that the agent is running: ps aux | grep amazon-cloudwatch-agent The next procedure demonstrates using AWS CloudFormation to update the CloudWatch agent, using an agent configuration that you saved in Parameter Store. To use AWS CloudFormation to update the CloudWatch agent using a configuration in Parameter Store 1. Change the agent configuration file stored in Parameter Store to the new configuration that you want. 2. In the AWS CloudFormation template that you downloaded in the the section called “Tutorial: Install the CloudWatch agent using AWS CloudFormation and Parameter Store” topic, change the version number. For example, you might change VERSION=1.0 to VERSION=2.0. 3. Open the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation. Tutorial: Install the CloudWatch agent using AWS CloudFormation and Parameter Store 2541 Amazon CloudWatch User Guide 4. On the AWS CloudFormation dashboard, select the stack that you created and choose Update Stack. 5. For Select Template, select Upload a template to Amazon S3, select the template that you just modified, and choose Next. 6. On the Options page, choose Next and then Next. 7. On the Review page, review your information and choose Update. After some time, you see UPDATE_COMPLETE. Troubleshooting installation of the CloudWatch agent with AWS CloudFormation This section helps you troubleshoot issues with installing and updating the CloudWatch agent using AWS CloudFormation. Detecting when an update fails If you use AWS CloudFormation to update your CloudWatch agent configuration, and use an invalid configuration, the agent stops sending any metrics to CloudWatch. A quick way to check whether an agent configuration update succeeded is to look at the cfn-init-cmd.log file. On a Linux server, the file is located at /var/log/cfn-init-cmd.log. On a Windows instance, the file is located at C:\cfn\log\cfn-init-cmd.log. Metrics are missing If you don't see metrics that you expect to see after installing or updating the agent, confirm that the agent is configured to collect that metric. To do this, check the amazon-cloudwatch- agent.json file to make sure that the metric is listed, and check that you are looking in the correct metric namespace. For more information, see CloudWatch agent files and locations. Set up the CloudWatch agent with security-enhanced Linux (SELinux) If your system has security-enhanced Linux (SELinux) enabled, you must apply the appropriate security policies to ensure that the CloudWatch agent runs in a confined domain. Troubleshooting installation of the CloudWatch agent with AWS CloudFormation 2542 Amazon CloudWatch Prerequisites User Guide Before you can configure SELinux for the agent, check the following prerequisites: To complete the prerequisites for using the CloudWatch agent with SELinux 1. If you haven't done so, install the following SELinux policy development packages: sudo yum update sudo yum install -y selinux-policy-devel policycoreutils-devel rpm-build git 2. Run the following command to check your system's SELinux status: sestatus Example output: SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: permissive Mode from config file: permissive Policy MLS status: enabled Policy deny_unknown status: allowed Memory protection checking: actual (secure) Max kernel policy version: 33 If you find that SELinux is currently disabled, do the following: a. Open the SELinux file by entering the following command: sudo vi /etc/selinux/config b. Set the SELINUX parameter to either permissive or enforcing. For example: SELINUX=enforcing c. Save the file and reboot the system to apply the changes. Prerequisites 2543 Amazon CloudWatch User Guide sudo reboot 3. Ensure that the CloudWatch agent is running
acw-ug-731
acw-ug.pdf
731
/sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: permissive Mode from config file: permissive Policy MLS status: enabled Policy deny_unknown status: allowed Memory protection checking: actual (secure) Max kernel policy version: 33 If you find that SELinux is currently disabled, do the following: a. Open the SELinux file by entering the following command: sudo vi /etc/selinux/config b. Set the SELINUX parameter to either permissive or enforcing. For example: SELINUX=enforcing c. Save the file and reboot the system to apply the changes. Prerequisites 2543 Amazon CloudWatch User Guide sudo reboot 3. Ensure that the CloudWatch agent is running as a systemd service. This is required to use it within a confined SELinux domain. sudo systemctl status amazon-cloudwatch-agent If the agent is correctly configured, the output should indicate that it is active (running) and enabled at startup. Configure SELinux for the agent After you complete the prerequisites, you can configure SELinux. To configure SELinux for the CloudWatch agent 1. Clone the SELinux policy for the CloudWatch agent by entering the following command: git clone https://github.com/aws/amazon-cloudwatch-agent-selinux.git 2. Navigate to the cloned repository and then update the script permissions by entering the following commands: cd amazon-cloudwatch-agent-selinux chmod +x amazon_cloudwatch_agent.sh 3. Use sudo to run the SELinux policy installation script by entering the following command. During execution, the script prompts you to enter y or n to allow automatic restart. This restart ensures that the agent transitions into the correct SELinux domain. sudo ./amazon_cloudwatch_agent.sh 4. If the CloudWatch agent hasn't been restarted yet, restart it to ensure that it transitions to the correct SELinux domain: sudo systemctl restart amazon-cloudwatch-agent 5. Verify that CloudWatch Agent is running in the confined domain by entering the following command: Configure SELinux for the agent 2544 Amazon CloudWatch User Guide ps -efZ | grep amazon-cloudwatch-agent If the agent is correctly confined, the output should indicate a SELinux-confined domain instead of unconfined_service_t. The following is an example of output when the agent is correctly confined. system_u:system_r:confined_t:s0 root 1234 1 0 12:00 ? 00:00:10 /opt/aws/amazon- cloudwatch-agent/bin/amazon-cloudwatch-agent After SELinux is configured, you can proceed to configure the agent to collect metrics, logs, and traces. For more information, see Manually create or edit the CloudWatch agent configuration file. CloudWatch agent credentials preference This section outlines the credentials provider chain the CloudWatch agent uses to obtain credentials when communicating with other AWS services and APIs. The ordering is as follows: Note The preferences listed in numbers two through five are the same preference order as defined in the AWS SDK. For more information, see Specifying Credentials in the SDK documentation. 1. Shared config and credentials files as defined in the CloudWatch agent’s common-config.toml file. For more information, see (Optional) Modify the common configuration for proxy or Region information. 2. AWS SDK environment variables Important On Linux, if you run the CloudWatch agent using the amazon-cloudwatch-agent- ctl script, the script starts the agent as a systemd service. In this case, environment variables such as HOME, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY are not accessible by the agent. CloudWatch agent credentials preference 2545 Amazon CloudWatch User Guide 3. Shared configuration and credentials files found in $HOME/%USERPROFILE% Note The CloudWatch agent looks for .aws/credentials in $HOME for Linux and MacOS and looks in %USERPROFILE% for Windows. Unlike the AWS SDK, the CloudWatch agent does not have fallback methods to determine the home directory if the environment variables are inaccessible. This difference in behavior is to maintain backwards compatibility with earlier implementations of the AWS SDK. Furthermore, unlike with the shared credentials found in common-config.toml, if the AWS SDK-derived shared credentials expire and are rotated, the renewed credentials are not automatically picked up by the CloudWatch agent and require a restart of the agent to do so. 4. An AWS Identity and Access Management role for tasks if an application is present that uses an Amazon Elastic Container Service task definition or a RunTask API operation. 5. An instance profile attached to an Amazon EC2 instance. As a best practice, we recommend that you specify credentials in the following order when you use the CloudWatch agent. 1. Use IAM roles for tasks if your application uses an Amazon Elastic Container Service task definition or a RunTask API operation. 2. Use IAM roles if your application runs on an Amazon EC2 instance. 3. Use the CloudWatch agent common-config.toml file to specify the credentials file. This credentials file is the same one used by other AWS SDKs and the AWS CLI. If you’re already using a shared credentials file, you can also use it for this purpose. If you provide it by using the CloudWatch agent’s common-config.toml file, you ensure that the agent will consume rotated credentials when they expire and get replaced without requiring you to restart the agent. 4. Use environment variables. Setting environment variables is useful if you’re
acw-ug-732
acw-ug.pdf
732
Use IAM roles if your application runs on an Amazon EC2 instance. 3. Use the CloudWatch agent common-config.toml file to specify the credentials file. This credentials file is the same one used by other AWS SDKs and the AWS CLI. If you’re already using a shared credentials file, you can also use it for this purpose. If you provide it by using the CloudWatch agent’s common-config.toml file, you ensure that the agent will consume rotated credentials when they expire and get replaced without requiring you to restart the agent. 4. Use environment variables. Setting environment variables is useful if you’re doing development work on a computer other than an Amazon EC2 instance. Note If you send telemetry to a different account as explained in Sending metrics, logs, and traces to a different account, the CloudWatch agent uses the credentials provider CloudWatch agent credentials preference 2546 Amazon CloudWatch User Guide chain described in this section to obtain the initial set of credentials. It then uses those credentials when assuming the IAM role specified by role_arn in the CloudWatch agent configuration file. Verifying the signature of the CloudWatch agent package GPG signature files are included for CloudWatch agent packages on Linux servers. You can use a public key to verify the agent download file is original and unmodified. For Windows Server, you can use the MSI to verify the signature. For macOS computers, the signature is included in the agent download package. To find the correct signature file, use the following table. For each architecture and operating system, you can see a general link and links for each Region. For example, for Amazon Linux 2023 and Amazon Linux 2 and the x86-64 architecture, three of the valid links are: • https://amazoncloudwatch-agent.s3.amazonaws.com/amazon_linux/amd64/ latest/amazon-cloudwatch-agent.rpm.sig • https://amazoncloudwatch-agent-us-east-1.s3.us-east-1.amazonaws.com/ amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm • https://amazoncloudwatch-agent-eu-central-1.s3.eu- central-1.amazonaws.com/amazon_linux/amd64/latest/amazon-cloudwatch- agent.rpm Note To download the CloudWatch agent, your connection must use TLS 1.2 or later. Architecture Platform Download link Signature file link x86-64 Amazon Linux 2023 and Amazon Linux 2 https://amazoncloudwatch- agent.s3.amazonaws.com/ amazon_linux/amd64/latest/ https://amazoncloudwatch- agent.s3.amazonaws.com/ amazon_linux/amd64/latest/ Verifying the signature of the CloudWatch agent package 2547 Amazon CloudWatch User Guide Architecture Platform Download link Signature file link x86-64 Centos x86-64 Redhat amazon-cloudwatch-agent.r amazon-cloudwatch-agent.r pm pm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/amazon_linux/amd64/ latest/amazon-cloudwatch- ent-region.s3.region.amazonaw s.com/amazon_linux/amd64/ latest/amazon-cloudwatch- agent.rpm agent.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ centos/amd64/latest/amaz https://amazoncloudwatch- agent.s3.amazonaws.com/ centos/amd64/latest/amaz on-cloudwatch-agent.rpm on-cloudwatch-agent.rpm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/centos/amd64/ ent-region.s3.region.amazonaw s.com/centos/amd64/ latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.rpm gent.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ redhat/amd64/latest/amaz redhat/amd64/latest/amaz on-cloudwatch-agent.rpm on-cloudwatch-agent.rpm.sig https://amazonclou dwatch-ag https://amazonclou dwatch-ag ent-region.s3.region.amazonaw s.com/redhat/amd64/ ent-region.s3.region.amazonaw s.com/redhat/amd64/ latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.rpm gent.rpm.sig Verifying the signature of the CloudWatch agent package 2548 Amazon CloudWatch User Guide Architecture Platform Download link Signature file link x86-64 SUSE x86-64 Debian x86-64 Ubuntu https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ suse/amd64/latest/amazon- suse/amd64/latest/amazon- cloudwatch-agent.rpm cloudwatch-agent.rpm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/suse/amd64/latest/ ent-region.s3.region.amazonaw s.com/suse/amd64/latest/ amazon-cloudwatch-age amazon-cloudwatch-age nt.rpm nt.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ debian/amd64/latest/amaz debian/amd64/latest/amaz on-cloudwatch-agent.deb on-cloudwatch-agent.deb.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/debian/amd64/ ent-region.s3.region.amazonaw s.com/debian/amd64/ latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.deb gent.deb.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ ubuntu/amd64/latest/amaz on-cloudwatch-agent.deb https://amazoncloudwatch- agent.s3.amazonaws.com/ ubuntu/amd64/latest/amaz on-cloudwatch-agent.deb.sig https://amazonclou dwatch-ag https://amazonclou dwatch-ag ent-region.s3.region.amazonaw s.com/ubuntu/amd64/ ent-region.s3.region.amazonaw s.com/ubuntu/amd64/ latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.deb gent.deb.sig Verifying the signature of the CloudWatch agent package 2549 Amazon CloudWatch User Guide Architecture Platform Download link Signature file link x86-64 Oracle x86-64 macOS x86-64 Windows https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ oracle_linux/amd64/latest/ oracle_linux/amd64/latest/ amazon-cloudwatch-agent.r amazon-cloudwatch-agent.r pm pm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/oracle_linux/amd64/ ent-region.s3.region.amazonaw s.com/oracle_linux/amd64/ latest/amazon-cloudwatch- latest/amazon-cloudwatch- agent.rpm agent.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ darwin/amd64/latest/amaz darwin/amd64/latest/amaz on-cloudwatch-agent.pkg on-cloudwatch-agent.pkg.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/darwin/amd64/ ent-region.s3.region.amazonaw s.com/darwin/amd64/ latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.pkg gent.pkg.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ windows/amd64/latest/ama zon-cloudwatch-agent.msi https://amazoncloudwatch- agent.s3.amazonaws.com/ windows/amd64/latest/ama zon-cloudwatch-agent.msi.sig https://amazonclou dwatch-ag https://amazonclou dwatch-ag ent-region.s3.region.amazonaw s.com/windows/amd64/ ent-region.s3.region.amazonaw s.com/windows/amd64/ latest/amazon-cloudwatch- latest/amazon-cloudwatch- agent.msi agent.msi.sig Verifying the signature of the CloudWatch agent package 2550 Amazon CloudWatch User Guide Architecture Platform Download link Signature file link ARM64 Amazon Linux 2023 https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ and Amazon amazon_linux/arm64/latest/ amazon_linux/arm64/latest/ Linux 2 amazon-cloudwatch-agent.r amazon-cloudwatch-agent.r pm pm.sig ARM64 Redhat ARM64 Ubuntu https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/amazon_linux/arm64/ ent-region.s3.region.amazonaw s.com/amazon_linux/arm64/ latest/amazon-cloudwatch- latest/amazon-cloudwatch- agent.rpm agent.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ redhat/arm64/latest/amaz redhat/arm64/latest/amaz on-cloudwatch-agent.rpm on-cloudwatch-agent.rpm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/redhat/arm64/latest/ ent-region.s3.region.amazonaw s.com/redhat/arm64/latest/ amazon-cloudwatch-a amazon-cloudwatch-a gent.rpm gent.rpm.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ ubuntu/arm64/latest/amaz on-cloudwatch-agent.deb https://amazoncloudwatch- agent.s3.amazonaws.com/ ubuntu/arm64/latest/amaz on-cloudwatch-agent.deb.sig https://amazonclou dwatch-ag https://amazonclou dwatch-ag ent-region.s3.region.amazonaw s.com/ubuntu/arm64/ ent-region.s3.region.amazonaw s.com/ubuntu/arm64/ latest/amazon-cloudwatch-a latest/amazon-cloudwatch-a gent.deb gent.deb.sig Verifying the signature of the CloudWatch agent package 2551 Amazon CloudWatch User Guide Architecture Platform Download link Signature file link ARM64 Debian ARM64 SUSE https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ debian/arm64/latest/amaz debian/arm64/latest/amaz on-cloudwatch-agent.deb on-cloudwatch-agent.deb.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/debian/arm64/latest/a ent-region.s3.region.amazonaw s.com/debian/arm64/latest/ mazon-cloudwatch-agent.deb amazon-cloudwatch-a gent.deb.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ suse/arm64/latest/amazon- suse/arm64/latest/amazon- cloudwatch-agent.rpm cloudwatch-agent.rpm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/suse/arm64/latest/ ent-region.s3.region.amazonaw s.com/suse/arm64/latest/ amazon-cloudwatch-age amazon-cloudwatch-age nt.rpm nt.rpm.sig To verify the CloudWatch agent package on a Linux server 1. Download the public key. shell$ wget https://amazoncloudwatch-agent.s3.amazonaws.com/assets/amazon- cloudwatch-agent.gpg 2. Import the public key into your keyring. shell$ gpg --import amazon-cloudwatch-agent.gpg gpg: key 3B789C72: public key "Amazon CloudWatch Agent" imported gpg: Total number processed: 1 Verifying the signature of the CloudWatch agent package 2552 Amazon CloudWatch User
acw-ug-733
acw-ug.pdf
733
ARM64 Debian ARM64 SUSE https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ debian/arm64/latest/amaz debian/arm64/latest/amaz on-cloudwatch-agent.deb on-cloudwatch-agent.deb.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/debian/arm64/latest/a ent-region.s3.region.amazonaw s.com/debian/arm64/latest/ mazon-cloudwatch-agent.deb amazon-cloudwatch-a gent.deb.sig https://amazoncloudwatch- agent.s3.amazonaws.com/ https://amazoncloudwatch- agent.s3.amazonaws.com/ suse/arm64/latest/amazon- suse/arm64/latest/amazon- cloudwatch-agent.rpm cloudwatch-agent.rpm.sig https://amazonclou https://amazonclou dwatch-ag dwatch-ag ent-region.s3.region.amazonaw s.com/suse/arm64/latest/ ent-region.s3.region.amazonaw s.com/suse/arm64/latest/ amazon-cloudwatch-age amazon-cloudwatch-age nt.rpm nt.rpm.sig To verify the CloudWatch agent package on a Linux server 1. Download the public key. shell$ wget https://amazoncloudwatch-agent.s3.amazonaws.com/assets/amazon- cloudwatch-agent.gpg 2. Import the public key into your keyring. shell$ gpg --import amazon-cloudwatch-agent.gpg gpg: key 3B789C72: public key "Amazon CloudWatch Agent" imported gpg: Total number processed: 1 Verifying the signature of the CloudWatch agent package 2552 Amazon CloudWatch User Guide gpg: imported: 1 (RSA: 1) Make a note of the key value, as you need it in the next step. In the preceding example, the key value is 3B789C72. 3. Verify the fingerprint by running the following command, replacing key-value with the value from the preceding step: shell$ gpg --fingerprint key-value pub 2048R/3B789C72 2017-11-14 Key fingerprint = 9376 16F3 450B 7D80 6CBD 9725 D581 6730 3B78 9C72 uid Amazon CloudWatch Agent The fingerprint string should be equal to the following: 9376 16F3 450B 7D80 6CBD 9725 D581 6730 3B78 9C72 If the fingerprint string doesn't match, don't install the agent. Contact Amazon Web Services. After you have verified the fingerprint, you can use it to verify the signature of the CloudWatch agent package. 4. Download the package signature file using wget. To determine the correct signature file, see the preceding table. wget Signature File Link 5. To verify the signature, run gpg --verify. shell$ gpg --verify signature-filename agent-download-filename gpg: Signature made Wed 29 Nov 2017 03:00:59 PM PST using RSA key ID 3B789C72 gpg: Good signature from "Amazon CloudWatch Agent" gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: 9376 16F3 450B 7D80 6CBD 9725 D581 6730 3B78 9C72 If the output includes the phrase BAD signature, check whether you performed the procedure correctly. If you continue to get this response, contact Amazon Web Services and avoid using the downloaded file. Verifying the signature of the CloudWatch agent package 2553 Amazon CloudWatch User Guide Note the warning about trust. A key is trusted only if you or someone who you trust has signed it. This doesn't mean that the signature is invalid, only that you have not verified the public key. To verify the CloudWatch agent package on a server running Windows Server 1. Download and install GnuPG for Windows from https://gnupg.org/download/. When installing, include the Shell Extension (GpgEx) option. You can perform the remaining steps in Windows PowerShell. 2. Download the public key. PS> wget https://amazoncloudwatch-agent.s3.amazonaws.com/assets/amazon-cloudwatch- agent.gpg -OutFile amazon-cloudwatch-agent.gpg 3. Import the public key into your keyring. PS> gpg --import amazon-cloudwatch-agent.gpg gpg: key 3B789C72: public key "Amazon CloudWatch Agent" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1) Make a note of the key value because you need it in the next step. In the preceding example, the key value is 3B789C72. 4. Verify the fingerprint by running the following command, replacing key-value with the value from the preceding step: PS> gpg --fingerprint key-value pub rsa2048 2017-11-14 [SC] 9376 16F3 450B 7D80 6CBD 9725 D581 6730 3B78 9C72 uid [ unknown] Amazon CloudWatch Agent The fingerprint string should be equal to the following: 9376 16F3 450B 7D80 6CBD 9725 D581 6730 3B78 9C72 If the fingerprint string doesn't match, don't install the agent. Contact Amazon Web Services. Verifying the signature of the CloudWatch agent package 2554 Amazon CloudWatch User Guide After you have verified the fingerprint, you can use it to verify the signature of the CloudWatch agent package. 5. Download the package signature file using wget. To determine the correct signature file, see CloudWatch Agent Download Links. 6. To verify the signature, run gpg --verify. PS> gpg --verify sig-filename agent-download-filename gpg: Signature made 11/29/17 23:00:45 Coordinated Universal Time gpg: using RSA key D58167303B789C72 gpg: Good signature from "Amazon CloudWatch Agent" [unknown] gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: 9376 16F3 450B 7D80 6CBD 9725 D581 6730 3B78 9C72 If the output includes the phrase BAD signature, check whether you performed the procedure correctly. If you continue to get this response, contact Amazon Web Services and avoid using the downloaded file. Note the warning about trust. A key is trusted only if you or someone who you trust has signed it. This doesn't mean that the signature is invalid, only that you have not verified the public key. To verify the CloudWatch agent package on a macOS computer • There are two methods for signature verification on macOS. • Verify the fingerprint by running the following command. pkgutil --check-signature amazon-cloudwatch-agent.pkg
acw-ug-734
acw-ug.pdf
734
the output includes the phrase BAD signature, check whether you performed the procedure correctly. If you continue to get this response, contact Amazon Web Services and avoid using the downloaded file. Note the warning about trust. A key is trusted only if you or someone who you trust has signed it. This doesn't mean that the signature is invalid, only that you have not verified the public key. To verify the CloudWatch agent package on a macOS computer • There are two methods for signature verification on macOS. • Verify the fingerprint by running the following command. pkgutil --check-signature amazon-cloudwatch-agent.pkg You should see a result similar to the following. Package "amazon-cloudwatch-agent.pkg": Status: signed by a developer certificate issued by Apple for distribution Signed with a trusted timestamp on: 2020-10-02 18:13:24 +0000 Certificate Chain: 1. Developer ID Installer: AMZN Mobile LLC (94KV3E626L) Expires: 2024-10-18 22:31:30 +0000 Verifying the signature of the CloudWatch agent package 2555 Amazon CloudWatch User Guide SHA256 Fingerprint: 81 B4 6F AF 1C CA E1 E8 3C 6F FB 9E 52 5E 84 02 6E 7F 17 21 8E FB 0C 40 79 13 66 8D 9F 1F 10 1C ------------------------------------------------------------------------ 2. Developer ID Certification Authority Expires: 2027-02-01 22:12:15 +0000 SHA256 Fingerprint: 7A FC 9D 01 A6 2F 03 A2 DE 96 37 93 6D 4A FE 68 09 0D 2D E1 8D 03 F2 9C 88 CF B0 B1 BA 63 58 7F ------------------------------------------------------------------------ 3. Apple Root CA Expires: 2035-02-09 21:40:36 +0000 SHA256 Fingerprint: B0 B1 73 0E CB C7 FF 45 05 14 2C 49 F1 29 5E 6E DA 6B CA ED 7E 2C 68 C5 BE 91 B5 A1 10 01 F0 24 • Or, download and use the .sig file To use this method, follow these steps. • Install the GPG application to your macOS host by entering the following command. brew install GnuPG • • Download the package signature file using curl. To determine the correct signature file, see CloudWatch Agent Download Links. To verify the signature, run gpg --verify. PS> gpg --verify sig-filename agent-download-filename gpg: Signature made 11/29/17 23:00:45 Coordinated Universal Time gpg: using RSA key D58167303B789C72 gpg: Good signature from "Amazon CloudWatch Agent" [unknown] gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: 9376 16F3 450B 7D80 6CBD 9725 D581 6730 3B78 9C72 If the output includes the phrase BAD signature, check whether you performed the procedure correctly. If you continue to get this response, contact Amazon Web Services and avoid using the downloaded file. Verifying the signature of the CloudWatch agent package 2556 Amazon CloudWatch User Guide Note the warning about trust. A key is trusted only if you or someone who you trust has signed it. This doesn't mean that the signature is invalid, only that you have not verified the public key. Create the CloudWatch agent configuration file Before running the CloudWatch agent on any servers, you must create one or more CloudWatch agent configuration files. The agent configuration file is a JSON file that specifies the metrics, logs, and traces that the agent is to collect, including custom metrics. You can create it by using the wizard or by creating it yourself from scratch. You could also use the wizard to initially create the configuration file and then modify it manually. If you create or modify the file manually, the process is more complex, but you have more control over the metrics collected and can specify metrics not available through the wizard. Any time you change the agent configuration file, you must then restart the agent to have the changes take effect. To restart the agent, follow the instructions in (Optional) Modify the common configuration and named profile for CloudWatch agent. After you have created a configuration file, you can save it manually as a JSON file and then use this file when installing the agent on your servers. Alternatively, you can store it in Systems Manager Parameter Store if you're going to use Systems Manager when you install the agent on servers. The CloudWatch agent supports using multiple configuration files. For more information, see Multiple CloudWatch agent configuration files. Metrics, logs, and traces collected by the CloudWatch agent incur charges. For more information about pricing, see Amazon CloudWatch Pricing. Contents • Create the CloudWatch agent configuration file with the wizard • Manually create or edit the CloudWatch agent configuration file Create the CloudWatch agent configuration file 2557 Amazon CloudWatch User Guide Create the CloudWatch agent configuration file with the wizard The agent configuration file wizard, amazon-cloudwatch-agent-config-wizard, asks a series of questions to help you configure the CloudWatch agent for your needs. This section describes the credentials required for the configuration file. It describes how to run the CloudWatch
acw-ug-735
acw-ug.pdf
735
files. Metrics, logs, and traces collected by the CloudWatch agent incur charges. For more information about pricing, see Amazon CloudWatch Pricing. Contents • Create the CloudWatch agent configuration file with the wizard • Manually create or edit the CloudWatch agent configuration file Create the CloudWatch agent configuration file 2557 Amazon CloudWatch User Guide Create the CloudWatch agent configuration file with the wizard The agent configuration file wizard, amazon-cloudwatch-agent-config-wizard, asks a series of questions to help you configure the CloudWatch agent for your needs. This section describes the credentials required for the configuration file. It describes how to run the CloudWatch agent configuration wizard. It also describes the metrics that are predefined in the wizard. Required credentials The wizard can autodetect the credentials and AWS Region to use if you have the AWS credentials and configuration files in place before you start the wizard. For more information about these files, see Configuration and Credential Files in the AWS Systems Manager User Guide. In the AWS credentials file, the wizard checks for default credentials and also looks for an AmazonCloudWatchAgent section such as the following: [AmazonCloudWatchAgent] aws_access_key_id = my_access_key aws_secret_access_key = my_secret_key The wizard displays the default credentials, the credentials from the AmazonCloudWatchAgent, and an Others option. You can select which credentials to use. If you choose Others, you can input credentials. For my_access_key and my_secret_key, use the keys from the IAM user that has the permissions to write to Systems Manager Parameter Store. For more information about the IAM users needed for the CloudWatch agent, see Create IAM users to use with the CloudWatch agent on on-premises servers. In the AWS configuration file, you can specify the Region that the agent sends metrics to if it's different than the [default] section. The default is to publish the metrics to the Region where the Amazon EC2 instance is located. If the metrics should be published to a different Region, specify the Region here. In the following example, the metrics are published to the us-west-1 Region. [AmazonCloudWatchAgent] region = us-west-1 Create the CloudWatch agent configuration file with the wizard 2558 Amazon CloudWatch User Guide Run the CloudWatch agent configuration wizard To create the CloudWatch agent configuration file 1. Start the CloudWatch agent configuration wizard by entering the following: sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard On a server running Windows Server, run the following commands to launch the wizard: cd "C:\Program Files\Amazon\AmazonCloudWatchAgent" .\amazon-cloudwatch-agent-config-wizard.exe 2. Answer the questions to customize the configuration file for your server. 3. If you're storing the configuration file locally, the configuration file config.json is stored in /opt/aws/amazon-cloudwatch-agent/bin/ on Linux servers, and is stored in C: \Program Files\Amazon\AmazonCloudWatchAgent on Windows Server. You can then copy this file to other servers where you want to install the agent. If you're going to use Systems Manager to install and configure the agent, be sure to answer Yes when prompted whether to store the file in Systems Manager Parameter Store. You can also choose to store the file in Parameter Store even if you aren't using the SSM Agent to install the CloudWatch agent. To be able to store the file in Parameter Store, you must use an IAM role with sufficient permissions. For more information, see Create IAM roles and users for use with the CloudWatch agent. CloudWatch agent predefined metric sets The wizard is configured with predefined sets of metrics, with different detail levels. These sets of metrics are shown in the following tables. For more information about these metrics, see Metrics collected by the CloudWatch agent. Create the CloudWatch agent configuration file with the wizard 2559 Amazon CloudWatch Note User Guide Parameter Store supports parameters in Standard and Advanced tiers. These parameter tiers are not related to the Basic, Standard, and Advanced levels of metric details that are described in these tables. Amazon EC2 instances running Linux Detail level Metrics included Basic Mem: mem_used_percent Disk: disk_used_percent The disk metrics such as disk_used_percent have a dimension for Partition , which means that the number of custom metrics generated is dependent on the number of partitions associated with your instance. The number of disk partitions you have depends on which AMI you are using and the number of Amazon EBS volumes you attach to the server. Standard CPU: cpu_usage_idle , cpu_usage_iowait , cpu_usage_user , cpu_usage_system Disk: disk_used_percent , disk_inodes_free Diskio: diskio_io_time Mem: mem_used_percent Swap: swap_used_percent Advanced CPU: cpu_usage_idle , cpu_usage_iowait , cpu_usage_user , cpu_usage_system Disk: disk_used_percent , disk_inodes_free Diskio: diskio_io_time , diskio_write_bytes ad_bytes , diskio_writes , diskio_reads , diskio_re Create the CloudWatch agent configuration file with the wizard 2560 Amazon CloudWatch User Guide Detail level Metrics included Mem: mem_used_percent Netstat: netstat_tcp_established , netstat_tcp_time_wait Swap: swap_used_percent On-premises servers running Linux Detail level Metrics included Basic Disk: disk_used_percent Diskio: diskio_write_bytes , diskio_read_bytes , diskio_wr ites , diskio_reads Mem: mem_used_percent Net: net_bytes_sent , net_bytes_recv , net_packets_sent , net_packets_recv Swap: swap_used_percent
acw-ug-736
acw-ug.pdf
736
CPU: cpu_usage_idle , cpu_usage_iowait , cpu_usage_user , cpu_usage_system Disk: disk_used_percent , disk_inodes_free Diskio: diskio_io_time Mem: mem_used_percent Swap: swap_used_percent Advanced CPU: cpu_usage_idle , cpu_usage_iowait , cpu_usage_user , cpu_usage_system Disk: disk_used_percent , disk_inodes_free Diskio: diskio_io_time , diskio_write_bytes ad_bytes , diskio_writes , diskio_reads , diskio_re Create the CloudWatch agent configuration file with the wizard 2560 Amazon CloudWatch User Guide Detail level Metrics included Mem: mem_used_percent Netstat: netstat_tcp_established , netstat_tcp_time_wait Swap: swap_used_percent On-premises servers running Linux Detail level Metrics included Basic Disk: disk_used_percent Diskio: diskio_write_bytes , diskio_read_bytes , diskio_wr ites , diskio_reads Mem: mem_used_percent Net: net_bytes_sent , net_bytes_recv , net_packets_sent , net_packets_recv Swap: swap_used_percent Standard CPU: cpu_usage_idle , cpu_usage_iowait Disk: disk_used_percent , disk_inodes_free Diskio: diskio_io_time , diskio_write_bytes ad_bytes , diskio_writes , diskio_reads , diskio_re Mem: mem_used_percent Net: net_bytes_sent , net_bytes_recv , net_packets_sent , net_packets_recv Swap: swap_used_percent Advanced CPU: cpu_usage_guest , cpu_usage_idle , cpu_usage_iowait , cpu_usage_steal , cpu_usage_user , cpu_usage_system Create the CloudWatch agent configuration file with the wizard 2561 Amazon CloudWatch User Guide Detail level Metrics included Disk: disk_used_percent , disk_inodes_free Diskio: diskio_io_time , diskio_write_bytes ad_bytes , diskio_writes , diskio_reads , diskio_re Mem: mem_used_percent Net: net_bytes_sent , net_bytes_recv , net_packets_sent , net_packets_recv Netstat: netstat_tcp_established , netstat_tcp_time_wait Swap: swap_used_percent Amazon EC2 instances running Windows Server Note The metric names listed in this table display how the metric appears when viewed in the console. The actual metric name might not include the first word. For example, the actual metric name for LogicalDisk % Free Space is just % Free Space. Detail level Metrics included Basic Memory: Memory % Committed Bytes In Use LogicalDisk: LogicalDisk % Free Space Standard Memory: Memory % Committed Bytes In Use Paging: Paging File % Usage Processor: Processor % Idle Time, Processor % Interrupt Time, Processor % User Time PhysicalDisk: PhysicalDisk % Disk Time Create the CloudWatch agent configuration file with the wizard 2562 Amazon CloudWatch User Guide Detail level Metrics included LogicalDisk: LogicalDisk % Free Space Advanced Memory: Memory % Committed Bytes In Use Paging: Paging File % Usage Processor: Processor % Idle Time, Processor % Interrupt Time, Processor % User Time LogicalDisk: LogicalDisk % Free Space PhysicalDisk: PhysicalDisk % Disk Time , PhysicalDisk Disk Write Bytes/sec , PhysicalDisk Disk Read Bytes/sec , PhysicalDisk Disk Writes/sec , PhysicalDisk Disk Reads/ sec TCP: TCPv4 Connections Established , TCPv6 Connections Established On-premises server running Windows Server Note The metric names listed in this table display how the metric appears when viewed in the console. The actual metric name might not include the first word. For example, the actual metric name for LogicalDisk % Free Space is just % Free Space. Detail level Metrics included Basic Paging: Paging File % Usage Processor: Processor % Processor Time LogicalDisk:LogicalDisk % Free Space Create the CloudWatch agent configuration file with the wizard 2563 Amazon CloudWatch User Guide Detail level Metrics included PhysicalDisk: PhysicalDisk Disk Write Bytes/sec , PhysicalD , PhysicalDisk Disk Writes/sec , isk Disk Read Bytes/sec PhysicalDisk Disk Reads/sec Memory: Memory % Committed Bytes In Use Network Interface: Network Interface Bytes Sent/sec, Network Interface Bytes Received/sec , Network Interface Packets Sent/sec, Network Interface Packets Received/sec Standard Paging: Paging File % Usage Processor: Processor % Processor Time, Processor % Idle Time, Processor % Interrupt Time LogicalDisk: LogicalDisk % Free Space PhysicalDisk: PhysicalDisk % Disk Time , PhysicalDisk Disk Write Bytes/sec , PhysicalDisk Disk Read Bytes/sec , PhysicalDisk Disk Writes/sec , PhysicalDisk Disk Reads/ sec Memory: Memory % Committed Bytes In Use Network Interface: Network Interface Bytes Sent/sec, Network Interface Bytes Received/sec , Network Interface Packets Sent/sec, Network Interface Packets Received/sec Create the CloudWatch agent configuration file with the wizard 2564 Amazon CloudWatch User Guide Detail level Metrics included Advanced Paging:Paging File % Usage Processor: Processor % Processor Time, Processor % Idle Time, Processor % Interrupt Time, Processor % User Time LogicalDisk: LogicalDisk % Free Space PhysicalDisk: PhysicalDisk % Disk Time , PhysicalDisk Disk Write Bytes/sec , PhysicalDisk Disk Read Bytes/sec , PhysicalDisk Disk Writes/sec , PhysicalDisk Disk Reads/ sec Memory: Memory % Committed Bytes In Use Network Interface: Network Interface Bytes Sent/sec, Network Interface Bytes Received/sec , Network Interface Packets Sent/sec, Network Interface Packets Received/sec TCP: TCPv4 Connections Established , TCPv6 Connections Established Manually create or edit the CloudWatch agent configuration file The CloudWatch agent configuration file is a JSON file with four sections: agent, metrics, logs, and traces. • The agent section includes fields for the overall configuration of the agent. • The metrics section specifies the custom metrics for collection and publishing to CloudWatch. If you're using the agent only to collect logs, you can omit the metrics section from the file. • The logs section specifies what log files are published to CloudWatch Logs. This can include events from the Windows Event Log if the server runs Windows Server. • The traces section specifies the sources for traces that are collected and sent to
acw-ug-737
acw-ug.pdf
737
is a JSON file with four sections: agent, metrics, logs, and traces. • The agent section includes fields for the overall configuration of the agent. • The metrics section specifies the custom metrics for collection and publishing to CloudWatch. If you're using the agent only to collect logs, you can omit the metrics section from the file. • The logs section specifies what log files are published to CloudWatch Logs. This can include events from the Windows Event Log if the server runs Windows Server. • The traces section specifies the sources for traces that are collected and sent to AWS X-Ray. This section explains the structure and fields of the CloudWatch agent configuration file. You can view the schema definition for this configuration file. The schema definition is located at Manually create or edit the CloudWatch agent configuration file 2565 Amazon CloudWatch User Guide installation-directory/doc/amazon-cloudwatch-agent-schema.json on Linux servers and at installation-directory/amazon-cloudwatch-agent-schema.json on servers running Windows Server. If you create or edit the agent configuration file manually, you can give it any name. For simplicity in troubleshooting, we recommend that you name it /opt/aws/amazon-cloudwatch- agent/etc/cloudwatch-agent.json on a Linux server and $Env:ProgramData\Amazon \AmazonCloudWatchAgent\amazon-cloudwatch-agent.json on servers running Windows Server. After you have created the file, you can copy it to other servers where you want to install the agent. When the agent is started, it creates a copy of each configuration file in /opt/aws/amazon- cloudwatch/etc/amazon-cloudwatch-agent.d directory, with the filename prefixed with either file_ (for local file sources) or ssm_ (for Systems Manager parameter store sources) to indicate the configuration origin. Note Metrics, logs, and traces collected by the CloudWatch agent incur charges. For more information about pricing, see Amazon CloudWatch Pricing. CloudWatch agent configuration file: Agent section The agent section can include the following fields. The wizard doesn't create an agent section. Instead, the wizard omits it and uses the default values for all fields in this section. • metrics_collection_interval – Optional. Specifies how often all metrics specified in this configuration file are to be collected. You can override this value for specific types of metrics. This value is specified in seconds. For example, specifying 10 causes metrics to be collected every 10 seconds, and setting it to 300 specifies metrics to be collected every 5 minutes. If you set this value below 60 seconds, each metric is collected as a high-resolution metric. For more information about high-resolution metrics, see High-resolution metrics. The default value is 60. • region – Specifies the Region to use for the CloudWatch endpoint when an Amazon EC2 instance is being monitored. The metrics collected are sent to this Region, such as us-west-1. Manually create or edit the CloudWatch agent configuration file 2566 Amazon CloudWatch User Guide If you omit this field, the agent sends metrics to the Region where the Amazon EC2 instance is located. If you are monitoring an on-premises server, this field isn't used, and the agent reads the Region from the AmazonCloudWatchAgent profile of the AWS configuration file. • credentials – Specifies an IAM role to use when sending metrics, logs, and traces to a different AWS account. If specified, this field contains one parameter, role_arn. • role_arn – Specifies the Amazon Resource Name (ARN) of an IAM role to use for authentication when sending metrics, logs, and traces to a different AWS account. For more information, see Sending metrics, logs, and traces to a different account. • debug – Optional. Specifies running the CloudWatch agent with debug log messages. The default value is false. • aws_sdk_log_level – Optional. Supported only in versions 1.247350.0 and later of the CloudWatch agent. You can specify this field to have the agent perform logging for AWS SDK endpoints. The value for this field can include one or more of the following options. Separate multiple options with the | character. • LogDebug • LogDebugWithSigning • LogDebugWithHTTPBody • LogDebugRequestRetries • LogDebugWithEventStreamBody For more information about these options, see LogLevelType. • logfile – Specifies the location where the CloudWatch agent writes log messages. If you specify an empty string, the log goes to stderr. If you don't specify this option, the default locations are the following: • Linux: /opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log • Windows Server: c:\\ProgramData\\Amazon\\CloudWatchAgent\\Logs\\amazon- cloudwatch-agent.log The CloudWatch agent automatically rotates the log file that it creates. A log file is rotated out when it reaches 100 MB in size. The agent keeps the rotated log files for up to seven days, and it keeps as many as five backup log files that have been rotated out. Manually create or edit the CloudWatch agent configuration file 2567 Amazon CloudWatch User Guide Backup log files have a timestamp appended to their filename. The timestamp shows the date and time that the file was rotated out: for example, amazon-cloudwatch- agent-2018-06-08T21-01-50.247.log.gz. • omit_hostname – Optional. By default, the hostname is published as a dimension
acw-ug-738
acw-ug.pdf
738
the log file that it creates. A log file is rotated out when it reaches 100 MB in size. The agent keeps the rotated log files for up to seven days, and it keeps as many as five backup log files that have been rotated out. Manually create or edit the CloudWatch agent configuration file 2567 Amazon CloudWatch User Guide Backup log files have a timestamp appended to their filename. The timestamp shows the date and time that the file was rotated out: for example, amazon-cloudwatch- agent-2018-06-08T21-01-50.247.log.gz. • omit_hostname – Optional. By default, the hostname is published as a dimension of metrics that are collected by the agent, unless you are using the append_dimensions field in the metrics section. Set omit_hostname to true to prevent the hostname from being published as a dimension even if you are not using append_dimensions. The default value is false. • run_as_user – Optional. Specifies a user to use to run the CloudWatch agent. If you don't specify this parameter, the root user is used. This option is valid only on Linux servers. If you specify this option, the user must exist before you start the CloudWatch agent. For more information, see Running the CloudWatch agent as a different user. • user_agent – Optional. Specifies the user-agent string that is used by the CloudWatch agent when it makes API calls to the CloudWatch backend. The default value is a string consisting of the agent version, the version of the Go programming language that was used to compile the agent, the runtime operating system and architecture, the build time, and the plugins enabled. • usage_data – Optional. By default, the CloudWatch agent sends health and performance data about itself to CloudWatch whenever it publishes metrics or logs to CloudWatch. This data incurs no costs to you. You can prevent the agent from sending this data by specifying false for usage_data. If you omit this parameter, the default of true is used and the agent sends the health and performance data. If you set this value to false, you must stop and restart the agent for it to take effect. • service.name – Optional. Specifies the service name to be used to populate the entity for finding related telemetry. • deployment.environment – Optional. Specifies the environment name to be used to populate the entity for finding related telemetry. The following is an example of an agent section. "agent": { "metrics_collection_interval": 60, "region": "us-west-1", "logfile": "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log", "debug": false, "run_as_user": "cwagent" Manually create or edit the CloudWatch agent configuration file 2568 Amazon CloudWatch } User Guide CloudWatch agent configuration file: Metrics section Fields common to Linux and Windows On servers running either Linux or Windows Server, the metrics section includes the following fields: • namespace – Optional. The namespace to use for the metrics collected by the agent. The default value is CWAgent. The maximum length is 255 characters. The following is an example: { "metrics": { "namespace": "Development/Product1Metrics", ...... }, } • append_dimensions – Optional. Adds Amazon EC2 metric dimensions to all metrics collected by the agent. This also causes the agent to not publish the hostname as a dimension. The only supported key-value pairs for append_dimensions are shown in the following list. Any other key-value pairs are ignored. The agent supports these key-value pairs exactly as they are shown in the following list. You can't change the key values to publish different dimension names for them. • "ImageId":"${aws:ImageId}" sets the instance's AMI ID as the value of the ImageId dimension. • "InstanceId":"${aws:InstanceId}" sets the instance's instance ID as the value of the InstanceId dimension. • "InstanceType":"${aws:InstanceType}" sets the instance's instance type as the value of the InstanceType dimension. • "AutoScalingGroupName":"${aws:AutoScalingGroupName}" sets the instance's Auto Scaling group name as the value of the AutoScalingGroupName dimension. If you want to append dimensions to metrics with arbitrary key-value pairs, use the append_dimensions parameter in the field for that particular type of metric. Manually create or edit the CloudWatch agent configuration file 2569 Amazon CloudWatch User Guide If you specify a value that depends on Amazon EC2 metadata and you use proxies, you must make sure that the server can access the endpoint for Amazon EC2. For more information about these endpoints, see Amazon Elastic Compute Cloud (Amazon EC2) in the Amazon Web Services General Reference. • aggregation_dimensions – Optional. Specifies the dimensions that collected metrics are to be aggregated on. For example, if you roll up metrics on the AutoScalingGroupName dimension, the metrics from all instances in each Auto Scaling group are aggregated and can be viewed as a whole. You can roll up metrics along single or multiple dimensions. For example, specifying [["InstanceId"], ["InstanceType"], ["InstanceId","InstanceType"]] aggregates metrics for instance ID singly, instance type singly, and for the combination of the two dimensions. You can also specify [] to roll
acw-ug-739
acw-ug.pdf
739
endpoints, see Amazon Elastic Compute Cloud (Amazon EC2) in the Amazon Web Services General Reference. • aggregation_dimensions – Optional. Specifies the dimensions that collected metrics are to be aggregated on. For example, if you roll up metrics on the AutoScalingGroupName dimension, the metrics from all instances in each Auto Scaling group are aggregated and can be viewed as a whole. You can roll up metrics along single or multiple dimensions. For example, specifying [["InstanceId"], ["InstanceType"], ["InstanceId","InstanceType"]] aggregates metrics for instance ID singly, instance type singly, and for the combination of the two dimensions. You can also specify [] to roll up all metrics into one collection, disregarding all dimensions. • endpoint_override – Specifies a FIPS endpoint or private link to use as the endpoint where the agent sends metrics. Specifying this and setting a private link enables you to send the metrics to an Amazon VPC endpoint. For more information, see What Is Amazon VPC?. The value of endpoint_override must be a string that is a URL. For example, the following part of the metrics section of the configuration file sets the agent to use a VPC Endpoint when sending metrics. { "metrics": { "endpoint_override": "vpce-XXXXXXXXXXXXXXXXXXXXXXXXX.monitoring.us- east-1.vpce.amazonaws.com", ...... }, } • metrics_collected – Required. Specifies which metrics are to be collected, including custom metrics collected through StatsD or collectd. This section includes several subsections. The contents of the metrics_collected section depend on whether this configuration file is for a server running Linux or Windows Server. Manually create or edit the CloudWatch agent configuration file 2570 Amazon CloudWatch User Guide • metrics_destinations – Optional. Specifies one or more destinations for all metrics defined in metrics_collected. If specified here, it overrides the default destination of cloudwatch. • cloudwatch – Amazon CloudWatch. • amp – Amazon Managed Service for Prometheus. • workspace_id – The ID corresponding to the Amazon Managed Service for Prometheus workspace. { "metrics": { "metrics_destinations": { "cloudwatch": {}, "amp": { "workspace_id": "ws-abcd1234-ef56-7890-ab12-example" } } } } • force_flush_interval – Specifies in seconds the maximum amount of time that metrics remain in the memory buffer before being sent to the server. No matter the setting for this, if the size of the metrics in the buffer reaches 1 MB or 1000 different metrics, the metrics are immediately sent to the server. The default value is 60. • credentials – Specifies an IAM role to use when sending metrics to a different account. If specified, this field contains one parameter, role_arn. • role_arn – Specifies the ARN of an IAM role to use for authentication when sending metrics to a different account. For more information, see Sending metrics, logs, and traces to a different account. If specified here, this value overrides the role_arn specified in the agent section of the configuration file, if any. • service.name – Optional. Specifies the service name to be used to populate the entity for finding related telemetry. • deployment.environment – Optional. Specifies the environment name to be used to populate the entity for finding related telemetry. Manually create or edit the CloudWatch agent configuration file 2571 Amazon CloudWatch Linux section User Guide On servers running Linux, the metrics_collected section of the configuration file can also contain the following fields. Many of these fields can include a measurement sections that lists the metrics you want to collect for that resource. These measurement sections can either specify the complete metric name such as swap_used, or just the part of the metric name that will be appended to the type of resource. For example, specifying reads in the measurement section of the diskio section causes the diskio_reads metric to be collected. • collectd – Optional. Specifies that you want to retrieve custom metrics using the collectd protocol. You use collectd software to send the metrics to the CloudWatch agent. For more information about the configuration options available for collectd, see Retrieve custom metrics with collectd. • cpu – Optional. Specifies that CPU metrics are to be collected. This section is valid only for Linux instances. You must include at least one of the resources and totalcpu fields for any CPU metrics to be collected. This section can include the following fields: • drop_original_metrics – Optional. If you are using the aggregation_dimensions field in the metrics section to roll up metrics into aggregated results, then by default the agent sends both the aggregated metrics and the original metrics that are separated for each value of the dimension. If you don't want the original metrics to be sent to CloudWatch, you can specify this parameter with a list of metrics. The metrics specified along with this parameter don't have their metrics by dimension reported to CloudWatch. Instead, only the aggregated metrics are reported. This reduces the number of metrics that the agent collects, reducing your costs. • resources – Optional. Specify
acw-ug-740
acw-ug.pdf
740
the aggregation_dimensions field in the metrics section to roll up metrics into aggregated results, then by default the agent sends both the aggregated metrics and the original metrics that are separated for each value of the dimension. If you don't want the original metrics to be sent to CloudWatch, you can specify this parameter with a list of metrics. The metrics specified along with this parameter don't have their metrics by dimension reported to CloudWatch. Instead, only the aggregated metrics are reported. This reduces the number of metrics that the agent collects, reducing your costs. • resources – Optional. Specify this field with a value of * to cause per-cpu metrics to be collected. The only allowed value is *. • totalcpu – Optional. Specifies whether to report cpu metrics aggregated across all cpu cores. The default is true. • measurement – Specifies the array of cpu metrics to be collected. Possible values are time_active, time_guest, time_guest_nice, time_idle, time_iowait, time_irq, time_nice, time_softirq, time_steal, time_system, time_user, usage_active, usage_guest, usage_guest_nice, usage_idle, usage_iowait, usage_irq, usage_nice, usage_softirq, usage_steal, usage_system, and usage_user. This field is required if you include cpu. Manually create or edit the CloudWatch agent configuration file 2572 Amazon CloudWatch User Guide By default, the unit for cpu_usage_* metrics is Percent, and cpu_time_* metrics don't have a unit. Within the entry for each individual metric, you might optionally specify one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit of None for the metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. • metrics_collection_interval – Optional. Specifies how often to collect the cpu metrics, overriding the global metrics_collection_interval specified in the agent section of the configuration file. This value is specified in seconds. For example, specifying 10 causes metrics to be collected every 10 seconds, and setting it to 300 specifies metrics to be collected every 5 minutes. If you set this value below 60 seconds, each metric is collected as a high-resolution metric. For more information about high-resolution metrics, see High-resolution metrics. • append_dimensions – Optional. Additional dimensions to use for only the cpu metrics. If you specify this field, it's used in addition to dimensions specified in the global append_dimensions field that is used for all types of metrics that the agent collects. • disk – Optional. Specifies that disk metrics are to be collected. Collects metrics only for mounted volumes. This section is valid only for Linux instances. This section can include the following fields: • drop_original_metrics – Optional. If you are using the aggregation_dimensions field in the metrics section to roll up metrics into aggregated results, then by default the agent sends both the aggregated metrics and the original metrics that are separated for each value of the dimension. If you don't want the original metrics to be sent to CloudWatch, you can specify this parameter with a list of metrics. The metrics specified along with this parameter don't have their metrics by dimension reported to CloudWatch. Instead, only the aggregated metrics are reported. This reduces the number of metrics that the agent collects, reducing your costs. • resources – Optional. Specifies an array of disk mount points. This field limits CloudWatch to collect metrics from only the listed mount points. You can specify * as the value to collect metrics from all mount points. The default value is to collect metrics from all mount points. Manually create or edit the CloudWatch agent configuration file 2573 Amazon CloudWatch User Guide • measurement – Specifies the array of disk metrics to be collected. Possible values are free, total, used, used_percent, inodes_free, inodes_used, and inodes_total. This field is required if you include disk. Note The disk metrics have a dimension for Partition, which means that the number of custom metrics generated is dependent on the number of partitions associated with your instance. The number of disk partitions you have depends on which AMI you are using and the number of Amazon EBS volumes you attach to the server. To see the default units for each disk metric, see Metrics collected by the CloudWatch agent on Linux and macOS instances. Within the entry for each individual metric, you might optionally specify one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit of None of None for the metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. • ignore_file_system_types – Specifies file system types to exclude when collecting disk metrics. Valid values include sysfs, devtmpfs, and so
acw-ug-741
acw-ug.pdf
741
Metrics collected by the CloudWatch agent on Linux and macOS instances. Within the entry for each individual metric, you might optionally specify one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit of None of None for the metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. • ignore_file_system_types – Specifies file system types to exclude when collecting disk metrics. Valid values include sysfs, devtmpfs, and so on. • drop_device – Setting this to true causes Device to not be included as a dimension for disk metrics. Preventing Device from being used as a dimension can be useful on instances that use the Nitro system because on those instances the device names change for each disk mount when the instance is rebooted. This can cause inconsistent data in your metrics and cause alarms based on these metrics to go to INSUFFICIENT DATA state. The default is false. • metrics_collection_interval – Optional. Specifies how often to collect the disk metrics, overriding the global metrics_collection_interval specified in the agent section of the configuration file. This value is specified in seconds. Manually create or edit the CloudWatch agent configuration file 2574 Amazon CloudWatch User Guide If you set this value below 60 seconds, each metric is collected as a high-resolution metric. For more information, see High-resolution metrics. • append_dimensions – Optional. Specify key-value pairs to use as additional dimensions for only the disk metrics. If you specify this field, it is used in addition to dimensions specified in the append_dimensions field that is used for all types of metrics collected by the agent. One key-value pair that you can use is the following. You can also specify other custom key- value pairs. • "VolumeId":"${aws:VolumeId}" adds a VolumeId dimension to your block device disk metrics. For Amazon EBS volumes, this will be the Amazon EBS Volume ID. For EC2 instance store, this will be the device serial. Using this requires the drop_device parameter to be set to false. • diskio – Optional. Specifies that disk i/o metrics are to be collected. This section is valid only for Linux instances. This section can include the following fields: • drop_original_metrics – Optional. If you are using the aggregation_dimensions field in the metrics section to roll up metrics into aggregated results, then by default the agent sends both the aggregated metrics and the original metrics that are separated for each value of the dimension. If you don't want the original metrics to be sent to CloudWatch, you can specify this parameter with a list of metrics. The metrics specified along with this parameter don't have their metrics by dimension reported to CloudWatch. Instead, only the aggregated metrics are reported. This reduces the number of metrics that the agent collects, reducing your costs. • resources – Optional. If you specify an array of devices, CloudWatch collects metrics from only those devices. Otherwise, metrics for all devices are collected. You can also specify * as the value to collect metrics from all devices. • measurement – Specifies the array of diskio metrics to be collected. Possible values are reads, writes, read_bytes, write_bytes, read_time, write_time, io_time, and iops_in_progress. This field is required if you include diskio. Within the entry for each individual metric, you might optionally specify one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit of None of None for the metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. Manually create or edit the CloudWatch agent configuration file 2575 Amazon CloudWatch User Guide • metrics_collection_interval – Optional. Specifies how often to collect the diskio metrics, overriding the global metrics_collection_interval specified in the agent section of the configuration file. This value is specified in seconds. If you set this value below 60 seconds, each metric is collected as a high-resolution metric. For more information about high-resolution metrics, see High-resolution metrics. • append_dimensions – Optional. Additional dimensions to use for only the diskio metrics. If you specify this field, it is used in addition to dimensions specified in the append_dimensions field that is used for all types of metrics collected by the agent. • swap – Optional. Specifies that swap memory metrics are to be collected. This section is valid only for Linux instances. This section can include the following fields: • drop_original_metrics – Optional. If you are using the aggregation_dimensions field in the metrics section to roll up metrics into aggregated results, then by default the agent sends both the aggregated metrics
acw-ug-742
acw-ug.pdf
742
– Optional. Additional dimensions to use for only the diskio metrics. If you specify this field, it is used in addition to dimensions specified in the append_dimensions field that is used for all types of metrics collected by the agent. • swap – Optional. Specifies that swap memory metrics are to be collected. This section is valid only for Linux instances. This section can include the following fields: • drop_original_metrics – Optional. If you are using the aggregation_dimensions field in the metrics section to roll up metrics into aggregated results, then by default the agent sends both the aggregated metrics and the original metrics that are separated for each value of the dimension. If you don't want the original metrics to be sent to CloudWatch, you can specify this parameter with a list of metrics. The metrics specified along with this parameter don't have their metrics by dimension reported to CloudWatch. Instead, only the aggregated metrics are reported. This reduces the number of metrics that the agent collects, reducing your costs. • measurement – Specifies the array of swap metrics to be collected. Possible values are free, used, and used_percent. This field is required if you include swap. To see the default units for each swap metric, see Metrics collected by the CloudWatch agent on Linux and macOS instances. Within the entry for each individual metric, you might optionally specify one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit of None of None for the metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. • metrics_collection_interval – Optional. Specifies how often to collect the swap metrics, overriding the global metrics_collection_interval specified in the agent section of the configuration file. Manually create or edit the CloudWatch agent configuration file 2576 Amazon CloudWatch User Guide This value is specified in seconds. If you set this value below 60 seconds, each metric is collected as a high-resolution metric. For more information about high-resolution metrics, see High-resolution metrics. • append_dimensions – Optional. Additional dimensions to use for only the swap metrics. If you specify this field, it is used in addition to dimensions specified in the global append_dimensions field that is used for all types of metrics collected by the agent. It's collected as a high-resolution metric. • mem – Optional. Specifies that memory metrics are to be collected. This section is valid only for Linux instances. This section can include the following fields: • drop_original_metrics – Optional. If you are using the aggregation_dimensions field in the metrics section to roll up metrics into aggregated results, then by default the agent sends both the aggregated metrics and the original metrics that are separated for each value of the dimension. If you don't want the original metrics to be sent to CloudWatch, you can specify this parameter with a list of metrics. The metrics specified along with this parameter don't have their metrics by dimension reported to CloudWatch. Instead, only the aggregated metrics are reported. This reduces the number of metrics that the agent collects, reducing your costs. • measurement – Specifies the array of memory metrics to be collected. Possible values are active, available, available_percent, buffered, cached, free, inactive, total, used, and used_percent. This field is required if you include mem. To see the default units for each mem metric, see Metrics collected by the CloudWatch agent on Linux and macOS instances. Within the entry for each individual metric, you might optionally specify one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit of None for the metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. • metrics_collection_interval – Optional. Specifies how often to collect the mem metrics, overriding the global metrics_collection_interval specified in the agent section of the configuration file. This value is specified in seconds. Manually create or edit the CloudWatch agent configuration file 2577 Amazon CloudWatch User Guide If you set this value below 60 seconds, each metric is collected as a high-resolution metric. For more information about high-resolution metrics, see High-resolution metrics. • append_dimensions – Optional. Additional dimensions to use for only the mem metrics. If you specify this field, it's used in addition to dimensions specified in the append_dimensions field that is used for all types of metrics that the agent collects. • net – Optional. Specifies that networking metrics are to be collected. This section is valid only for Linux instances. This section can include the following fields: • drop_original_metrics –
acw-ug-743
acw-ug.pdf
743
Amazon CloudWatch User Guide If you set this value below 60 seconds, each metric is collected as a high-resolution metric. For more information about high-resolution metrics, see High-resolution metrics. • append_dimensions – Optional. Additional dimensions to use for only the mem metrics. If you specify this field, it's used in addition to dimensions specified in the append_dimensions field that is used for all types of metrics that the agent collects. • net – Optional. Specifies that networking metrics are to be collected. This section is valid only for Linux instances. This section can include the following fields: • drop_original_metrics – Optional. If you are using the aggregation_dimensions field in the metrics section to roll up metrics into aggregated results, then by default the agent sends both the aggregated metrics and the original metrics that are separated for each value of the dimension. If you don't want the original metrics to be sent to CloudWatch, you can specify this parameter with a list of metrics. The metrics specified along with this parameter don't have their metrics by dimension reported to CloudWatch. Instead, only the aggregated metrics are reported. This reduces the number of metrics that the agent collects, reducing your costs. • resources – Optional. If you specify an array of network interfaces, CloudWatch collects metrics from only those interfaces. Otherwise, metrics for all devices are collected. You can also specify * as the value to collect metrics from all interfaces. • measurement – Specifies the array of networking metrics to be collected. Possible values are bytes_sent, bytes_recv, drop_in, drop_out, err_in, err_out, packets_sent, and packets_recv. This field is required if you include net. To see the default units for each net metric, see Metrics collected by the CloudWatch agent on Linux and macOS instances. Within the entry for each individual metric, you might optionally specify one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit of None for the metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. • metrics_collection_interval – Optional. Specifies how often to collect the net metrics, overriding the global metrics_collection_interval specified in the agent section of the configuration file. Manually create or edit the CloudWatch agent configuration file 2578 Amazon CloudWatch User Guide This value is specified in seconds. For example, specifying 10 causes metrics to be collected every 10 seconds, and setting it to 300 specifies metrics to be collected every 5 minutes. If you set this value below 60 seconds, each metric is collected as a high-resolution metric. For more information about high-resolution metrics, see High-resolution metrics. • append_dimensions – Optional. Additional dimensions to use for only the net metrics. If you specify this field, it's used in addition to dimensions specified in the append_dimensions field that is used for all types of metrics collected by the agent. • netstat – Optional. Specifies that TCP connection state and UDP connection metrics are to be collected. This section is valid only for Linux instances. This section can include the following fields: • drop_original_metrics – Optional. If you are using the aggregation_dimensions field in the metrics section to roll up metrics into aggregated results, then by default the agent sends both the aggregated metrics and the original metrics that are separated for each value of the dimension. If you don't want the original metrics to be sent to CloudWatch, you can specify this parameter with a list of metrics. The metrics specified along with this parameter don't have their metrics by dimension reported to CloudWatch. Instead, only the aggregated metrics are reported. This reduces the number of metrics that the agent collects, reducing your costs. • measurement – Specifies the array of netstat metrics to be collected. Possible values are tcp_close, tcp_close_wait, tcp_closing, tcp_established, tcp_fin_wait1, tcp_fin_wait2, tcp_last_ack, tcp_listen, tcp_none, tcp_syn_sent, tcp_syn_recv, tcp_time_wait, and udp_socket. This field is required if you include netstat. To see the default units for each netstat metric, see Metrics collected by the CloudWatch agent on Linux and macOS instances. Within the entry for each individual metric, you might optionally specify one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit of None for the metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. Manually create or edit the CloudWatch agent configuration file 2579 Amazon CloudWatch User Guide • metrics_collection_interval – Optional. Specifies how often to collect the netstat metrics, overriding the global metrics_collection_interval specified in the agent section of the configuration file. This value is specified in
acw-ug-744
acw-ug.pdf
744
one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit of None for the metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. Manually create or edit the CloudWatch agent configuration file 2579 Amazon CloudWatch User Guide • metrics_collection_interval – Optional. Specifies how often to collect the netstat metrics, overriding the global metrics_collection_interval specified in the agent section of the configuration file. This value is specified in seconds. If you set this value below 60 seconds, each metric is collected as a high-resolution metric. For more information about high-resolution metrics, see High-resolution metrics. • append_dimensions – Optional. Additional dimensions to use for only the netstat metrics. If you specify this field, it's used in addition to dimensions specified in the append_dimensions field that is used for all types of metrics collected by the agent. • processes – Optional. Specifies that process metrics are to be collected. This section is valid only for Linux instances. This section can include the following fields: • drop_original_metrics – Optional. If you are using the aggregation_dimensions field in the metrics section to roll up metrics into aggregated results, then by default the agent sends both the aggregated metrics and the original metrics that are separated for each value of the dimension. If you don't want the original metrics to be sent to CloudWatch, you can specify this parameter with a list of metrics. The metrics specified along with this parameter don't have their metrics by dimension reported to CloudWatch. Instead, only the aggregated metrics are reported. This reduces the number of metrics that the agent collects, reducing your costs. • measurement – Specifies the array of processes metrics to be collected. Possible values are blocked, dead, idle, paging, running, sleeping, stopped, total, total_threads, wait, and zombies. This field is required if you include processes. For all processes metrics, the default unit is None. Within the entry for each individual metric, you might optionally specify one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit of None for the metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. • metrics_collection_interval – Optional. Specifies how often to collect the processes metrics, overriding the global metrics_collection_interval specified in the agent section of the configuration file. Manually create or edit the CloudWatch agent configuration file 2580 Amazon CloudWatch User Guide This value is specified in seconds. For example, specifying 10 causes metrics to be collected every 10 seconds, and setting it to 300 specifies metrics to be collected every 5 minutes. If you set this value below 60 seconds, each metric is collected as a high-resolution metric. For more information, see High-resolution metrics. • append_dimensions – Optional. Additional dimensions to use for only the process metrics. If you specify this field, it's used in addition to dimensions specified in the append_dimensions field that is used for all types of metrics collected by the agent. • nvidia_gpu – Optional. Specifies that NVIDIA GPU metrics are to be collected. This section is valid only for Linux instances on hosts that are configured with a NVIDIA GPU accelerator and have the NVIDIA System Management Interface (nvidia-smi) installed. The NVIDIA GPU metrics that are collected are prefixed with the string nvidia_smi_ to distinguish them from the metrics collected for other accelerator types. This section can include the following fields: • drop_original_metrics – Optional. If you are using the aggregation_dimensions field in the metrics section to roll up metrics into aggregated results, then by default the agent sends both the aggregated metrics and the original metrics that are separated for each value of the dimension. If you don't want the original metrics to be sent to CloudWatch, you can specify this parameter with a list of metrics. The metrics specified along with this parameter don't have their metrics by dimension reported to CloudWatch. Instead, only the aggregated metrics are reported. This reduces the number of metrics that the agent collects, reducing your costs. • measurement – Specifies the array of NVIDIA GPU metrics to be collected. For a list of the possible values to use here, see the Metric column in the table in Collect NVIDIA GPU metrics. Within the entry for each individual metric, you can optionally specify one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit of None for the metric. The unit that
acw-ug-745
acw-ug.pdf
745
are reported. This reduces the number of metrics that the agent collects, reducing your costs. • measurement – Specifies the array of NVIDIA GPU metrics to be collected. For a list of the possible values to use here, see the Metric column in the table in Collect NVIDIA GPU metrics. Within the entry for each individual metric, you can optionally specify one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit of None for the metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. • metrics_collection_interval – Optional. Specifies how often to collect the NVIDIA GPU metrics, overriding the global metrics_collection_interval specified in the agent section of the configuration file. Manually create or edit the CloudWatch agent configuration file 2581 Amazon CloudWatch User Guide • jmx – Optional. Specifies that you want to retrieve Java Management Extensions (JMX) metrics from the instance. For more information about the parameters that you can use in this section and the metrics that you can collect, see Collect Java Management Extensions (JMX) metrics. • otlp – Optional. Specifies that you want to collect metrics from the OpenTelemetry SDK. For more information about the fields that you can use in this section, see Collect metrics and traces with OpenTelemetry. • procstat – Optional. Specifies that you want to retrieve metrics from individual processes. For more information about the configuration options available for procstat, see Collect process metrics with the procstat plugin. • statsd – Optional. Specifies that you want to retrieve custom metrics using the StatsD protocol. The CloudWatch agent acts as a daemon for the protocol. You use any standard StatsD client to send the metrics to the CloudWatch agent. For more information about the configuration options available for StatsD, see Retrieve custom metrics with StatsD. • ethtool – Optional. Specifies that you want to retrieve network metrics using the ethtool plugin. This plugin can import both the metrics collected by the standard ethtool utility, as well as network performance metrics from Amazon EC2 instances. For more information about the configuration options available for ethtool, see Collect network performance metrics. The following is an example of a metrics section for a Linux server. In this example, three CPU metrics, three netstat metrics, three process metrics, and one disk metric are collected, and the agent is set up to receive additional metrics from a collectd client. "metrics": { "aggregation_dimensions" : [["AutoScalingGroupName"], ["InstanceId", "InstanceType"],[]], "metrics_collected": { "collectd": {}, "cpu": { "resources": [ "*" ], "measurement": [ {"name": "cpu_usage_idle", "rename": "CPU_USAGE_IDLE", "unit": "Percent"}, {"name": "cpu_usage_nice", "unit": "Percent"}, "cpu_usage_guest" ], "totalcpu": false, "drop_original_metrics": [ "cpu_usage_guest" ], Manually create or edit the CloudWatch agent configuration file 2582 Amazon CloudWatch User Guide "metrics_collection_interval": 10, "append_dimensions": { "test": "test1", "date": "2017-10-01" } }, "netstat": { "measurement": [ "tcp_established", "tcp_syn_sent", "tcp_close" ], "metrics_collection_interval": 60 }, "disk": { "measurement": [ "used_percent" ], "resources": [ "*" ], "drop_device": true }, "processes": { "measurement": [ "running", "sleeping", "dead" ] } }, "append_dimensions": { "ImageId": "${aws:ImageId}", "InstanceId": "${aws:InstanceId}", "InstanceType": "${aws:InstanceType}", "AutoScalingGroupName": "${aws:AutoScalingGroupName}" } } Windows Server In the metrics_collected section for Windows Server, you can have subsections for each Windows performance object, such as Memory, Processor, and LogicalDisk. For information Manually create or edit the CloudWatch agent configuration file 2583 Amazon CloudWatch User Guide about what objects and counters are available, see Performance Counters in the Microsoft Windows documentation. Within the subsection for each object, you specify a measurement array of the counters to collect. The measurement array is required for each object that you specify in the configuration file. You can also specify a resources field to name the instances to collect metrics from. You can also specify * for resources to collect separate metrics for every instance. If you omit resources for counters that have instances, the data for all instances is aggregated into one set. If you omit resources for counters that don't have instances, the counters are not collected by the CloudWatch agent. To determine whether counters have instances, you can use one of the following commands. Powershell: Get-Counter -ListSet * Command line (not Powershell): TypePerf.exe –q Within each object section, you can also specify the following optional fields: • metrics_collection_interval – Optional. Specifies how often to collect the metrics for this object, overriding the global metrics_collection_interval specified in the agent section of the configuration file. This value is specified in seconds. For example, specifying 10 causes metrics to be collected every 10 seconds, and setting it to 300 specifies metrics to be collected every 5 minutes. If you set this value below 60 seconds, each metric is collected as a high-resolution metric. For more information, see High-resolution metrics.
acw-ug-746
acw-ug.pdf
746
-ListSet * Command line (not Powershell): TypePerf.exe –q Within each object section, you can also specify the following optional fields: • metrics_collection_interval – Optional. Specifies how often to collect the metrics for this object, overriding the global metrics_collection_interval specified in the agent section of the configuration file. This value is specified in seconds. For example, specifying 10 causes metrics to be collected every 10 seconds, and setting it to 300 specifies metrics to be collected every 5 minutes. If you set this value below 60 seconds, each metric is collected as a high-resolution metric. For more information, see High-resolution metrics. • append_dimensions – Optional. Specifies additional dimensions to use for only the metrics for this object. If you specify this field, it's used in addition to dimensions specified in the global append_dimensions field that is used for all types of metrics collected by the agent. • drop_original_metrics – Optional. If you are using the aggregation_dimensions field in the metrics section to roll up metrics into aggregated results, then by default the agent sends both the aggregated metrics and the original metrics that are separated for each value of the dimension. If you don't want the original metrics to be sent to CloudWatch, you can specify Manually create or edit the CloudWatch agent configuration file 2584 Amazon CloudWatch User Guide this parameter with a list of metrics. The metrics specified along with this parameter don't have their metrics by dimension reported to CloudWatch. Instead, only the aggregated metrics are reported. This reduces the number of metrics that the agent collects, reducing your costs. Within each counter section, you can also specify the following optional fields: • rename – Specifies a different name to be used in CloudWatch for this metric. • unit – Specifies the unit to use for this metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. There are other optional sections that you can include in metrics_collected: • statsd – Enables you to retrieve custom metrics using the StatsD protocol. The CloudWatch agent acts as a daemon for the protocol. You use any standard StatsD client to send the metrics to the CloudWatch agent. For more information, see Retrieve custom metrics with StatsD. • procstat – Enables you to retrieve metrics from individual processes. For more information, see Collect process metrics with the procstat plugin. • jmx – Optional. Specifies that you want to retrieve Java Management Extensions (JMX) metrics from the instance. For more information about the fields that you can use in this section and the metrics that you can collect, see Collect Java Management Extensions (JMX) metrics. • otlp – Optional. Specifies that you want to collect metrics from the OpenTelemetry SDK. For more information about the fields that you can use in this section, see Collect metrics and traces with OpenTelemetry. The following is an example metrics section for use on Windows Server. In this example, many Windows metrics are collected, and the computer is also set to receive additional metrics from a StatsD client. "metrics": { "metrics_collected": { "statsd": {}, "Processor": { "measurement": [ {"name": "% Idle Time", "rename": "CPU_IDLE", "unit": "Percent"}, "% Interrupt Time", "% User Time", "% Processor Time" Manually create or edit the CloudWatch agent configuration file 2585 User Guide Amazon CloudWatch ], "resources": [ "*" ], "append_dimensions": { "d1": "win_foo", "d2": "win_bar" } }, "LogicalDisk": { "measurement": [ {"name": "% Idle Time", "unit": "Percent"}, {"name": "% Disk Read Time", "rename": "DISK_READ"}, "% Disk Write Time" ], "resources": [ "*" ] }, "Memory": { "metrics_collection_interval": 5, "measurement": [ "Available Bytes", "Cache Faults/sec", "Page Faults/sec", "Pages/sec" ], "append_dimensions": { "d3": "win_bo" } }, "Network Interface": { "metrics_collection_interval": 5, "measurement": [ "Bytes Received/sec", "Bytes Sent/sec", "Packets Received/sec", "Packets Sent/sec" ], "resources": [ "*" ], "append_dimensions": { "d3": "win_bo" Manually create or edit the CloudWatch agent configuration file 2586 User Guide Amazon CloudWatch } }, "System": { "measurement": [ "Context Switches/sec", "System Calls/sec", "Processor Queue Length" ], "append_dimensions": { "d1": "win_foo", "d2": "win_bar" } } }, "append_dimensions": { "ImageId": "${aws:ImageId}", "InstanceId": "${aws:InstanceId}", "InstanceType": "${aws:InstanceType}", "AutoScalingGroupName": "${aws:AutoScalingGroupName}" }, "aggregation_dimensions" : [["ImageId"], ["InstanceId", "InstanceType"], ["d1"],[]] } } CloudWatch agent configuration file: Logs section The logs section includes the following fields: • service.name – Optional. Specifies the service name to be used to populate the entity for finding related telemetry. • deployment.environment – Optional. Specifies the environment name to be used to populate the entity for finding related telemetry. • logs_collected – Required if the logs section is included. Specifies which log files and Windows event logs are to be collected from the server. It can include two fields, files and windows_events. • files – Specifies which regular log files the CloudWatch agent is to collect. It contains one field, collect_list, which further defines
acw-ug-747
acw-ug.pdf
747
The logs section includes the following fields: • service.name – Optional. Specifies the service name to be used to populate the entity for finding related telemetry. • deployment.environment – Optional. Specifies the environment name to be used to populate the entity for finding related telemetry. • logs_collected – Required if the logs section is included. Specifies which log files and Windows event logs are to be collected from the server. It can include two fields, files and windows_events. • files – Specifies which regular log files the CloudWatch agent is to collect. It contains one field, collect_list, which further defines these files. • collect_list – Required if files is included. Contains an array of entries, each of which specifies one log file to collect. Each of these entries can include the following fields: Manually create or edit the CloudWatch agent configuration file 2587 Amazon CloudWatch User Guide • file_path – Specifies the path of the log file to upload to CloudWatch Logs. Standard Unix glob matching rules are accepted, with the addition of ** as a super asterisk. For example, specifying /var/log/**.log causes all .log files in the /var/log directory tree to be collected. For more examples, see Glob Library. You can also use the standard asterisk as a standard wildcard. For example, /var/log/ system.log* matches files such as system.log_1111, system.log_2222, and so on in /var/log. Only the latest file is pushed to CloudWatch Logs based on file modification time. We recommend that you use wildcards to specify a series of files of the same type, such as access_log.2018-06-01-01 and access_log.2018-06-01-02, but not multiple kinds of files, such as access_log_80 and access_log_443. To specify multiple kinds of files, add another log stream entry to the agent configuration file so that each kind of log file goes to a different log stream. • auto_removal – Optional. If this is true, the CloudWatch agent automatically deletes this log file after reading it and it has been rotated. Usually the log files are deleted after their entire contents are uploaded to CloudWatch Logs, but if the agent reaches the EOF (end of file) and also detects another newer log file that matches the same file_path, the agent deletes the OLD file, so you must make sure that you are done writing to the OLD file before creating the NEW file. The RUST tracing library has a known incompatibility because it will potentially create a NEW log file and then still attempt to write to the OLD log file. The agent only removes complete files from logs that create multiple files, such as logs that create separate files for each date. If a log continuously writes to a single file, it is not removed. If you already have a log file rotation or removal method in place, we recommend that you omit this field or set it to false. If you omit this field, the default value of false is used. • log_group_name – Optional. Specifies what to use as the log group name in CloudWatch Logs. We recommend that you use this field to specify a log group name to prevent confusion. If you omit log_group_name, the value of file_path up to the final dot is used as the log Manually create or edit the CloudWatch agent configuration file 2588 Amazon CloudWatch User Guide group name. For example, if the file path is /tmp/TestLogFile.log.2017-07-11-14, the log group name is /tmp/TestLogFile.log. If you specify a log group name, you can use {instance_id}, {hostname}, {local_hostname}, and {ip_address} as variables within the name. {hostname} retrieves the hostname from the EC2 metadata, and {local_hostname} uses the hostname from the network configuration file. If you use these variables to create many different log groups, keep in mind the limit of 1,000,000 log groups per Region per account. Allowed characters include a–z, A–Z, 0–9, '_' (underscore), '-' (hyphen), '/' (forward slash), and '.' (period). • log_group_class – Optional. Specifies which log group class to use for the new log group. For more information about log group classes, see Log classes. Valid values are STANDARD and INFREQUENT_ACCESS. If you omit this field, the default of STANDARD is used. Important After a log group is created, its class can't be changed. • log_stream_name – Optional. Specifies what to use as the log stream name in CloudWatch Logs. As part of the name, you can use {instance_id}, {hostname}, {local_hostname}, and {ip_address} as variables within the name. {hostname} retrieves the hostname from the EC2 metadata, and {local_hostname} uses the hostname from the network configuration file. If you omit this field, the value of the log_stream_name parameter in the global logs section is used. If that is also omitted, the default value of {instance_id} is used. If a log stream doesn't already exist, it's created automatically. • retention_in_days – Optional. Specifies the number of
acw-ug-748
acw-ug.pdf
748
• log_stream_name – Optional. Specifies what to use as the log stream name in CloudWatch Logs. As part of the name, you can use {instance_id}, {hostname}, {local_hostname}, and {ip_address} as variables within the name. {hostname} retrieves the hostname from the EC2 metadata, and {local_hostname} uses the hostname from the network configuration file. If you omit this field, the value of the log_stream_name parameter in the global logs section is used. If that is also omitted, the default value of {instance_id} is used. If a log stream doesn't already exist, it's created automatically. • retention_in_days – Optional. Specifies the number of days to retain the log events in the specified log group. • If the agent is creating this log group now, and you omit this field, the retention of this new log group is set to never expire. Manually create or edit the CloudWatch agent configuration file 2589 Amazon CloudWatch User Guide • If this log group already exists and you specify this field, the new retention that you specify is used. If you omit this field for a log group that already exists, the log group's retention is not changed. The CloudWatch agent wizard uses -1 as the default value for this field when it is used to create the agent configuration file and you don't specify a value for log retention. This -1 value set by the wizard specifies that the events in the log group will never expire. However, manually editing this value to -1 has no effect. Valid values are 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 2192, 2557, 2922, 3288, and 3653. If you configure the agent to write multiple log streams to the same log group, specifying the retention_in_days in one place will set the log retention for the entire log group. If you specify retention_in_days for the same log group in multiple places, the retention is set if all of those values are equal. However, if different retention_in_days values are specified for the same log group in multiple places, the log retention will not be set and the agent will stop, returning an error. Note The agent's IAM role or IAM user must have the logs:PutRetentionPolicy for it to be able to set retention policies. For more information, see Allowing the CloudWatch agent to set log retention policy. Warning If you set retention_in_days for a log group that already exists, all logs in that log group that were published before the number of days that you specify are deleted. For example, setting it to 3 would cause all logs from 3 days ago and before to be deleted. • filters – Optional. Can contain an array of entries, each of which specifies a regular expression and a filter type to specify whether to publish or drop log entries that match the filter. If you omit this field, all logs in the log file are published to CloudWatch Logs. If you include this field, the agent processes each log message with all of the filters that you specify, and only the log events that pass all of the filters are published to CloudWatch Manually create or edit the CloudWatch agent configuration file 2590 Amazon CloudWatch User Guide Logs. The log entries that don’t pass all of the filters will still remain in the host's log file, but will not be sent to CloudWatch Logs. Each entry in the filters array can include the following fields: • type– Denotes the type of filter. Valid values are include and exclude. With include, the log entry must match the expression to be published to CloudWatch Logs. With exclude, each log entry that matches the filter is not sent to CloudWatch Logs. • expression– A regular expression string that follows the RE2 Syntax. Note The CloudWatch agent doesn't check the performance of any regular expression that you supply, or restrict the run time of the evaluation of the regular expressions. We recommend that you are careful not to write an expression that is expensive to evaluate. For more information about possible issues, see Regular expression Denial of Service - ReDoS For example, the following excerpt of the CloudWatch agent configuration file publishes logs that are PUT and POST requests to CloudWatch Logs, but excluding logs that come from Firefox. "collect_list": [ { "file_path": "/opt/aws/amazon-cloudwatch-agent/logs/test.log", "log_group_name": "test.log", "log_stream_name": "test.log", "filters": [ { "type": "exclude", "expression": "Firefox" }, { "type": "include", "expression": "P(UT|OST)" } ] }, ..... ] Manually create or edit the CloudWatch agent configuration file 2591 Amazon CloudWatch User Guide Note The order of the filters in the configuration file matters for performance. In the preceding example, the agent drops all the logs that match Firefox before it starts evaluating the second filter. To cause fewer log entries to
acw-ug-749
acw-ug.pdf
749
configuration file publishes logs that are PUT and POST requests to CloudWatch Logs, but excluding logs that come from Firefox. "collect_list": [ { "file_path": "/opt/aws/amazon-cloudwatch-agent/logs/test.log", "log_group_name": "test.log", "log_stream_name": "test.log", "filters": [ { "type": "exclude", "expression": "Firefox" }, { "type": "include", "expression": "P(UT|OST)" } ] }, ..... ] Manually create or edit the CloudWatch agent configuration file 2591 Amazon CloudWatch User Guide Note The order of the filters in the configuration file matters for performance. In the preceding example, the agent drops all the logs that match Firefox before it starts evaluating the second filter. To cause fewer log entries to be evaluated by more than one filter, put the filter that you expect to rule out more logs first in the configuration file. • timezone – Optional. Specifies the time zone to use when putting timestamps on log events. The valid values are UTC and Local. The default value is Local. This parameter is ignored if you don't specify a value for timestamp_format. • timestamp_format – Optional. Specifies the timestamp format, using plaintext and special symbols that start with %. If you omit this field, the current time is used. If you use this field, you can use the symbols in the following list as part of the format. Note This parameter is not considered when the file_path is set to amazon- cloudwatch-agent.log If a single log entry contains two time stamps that match the format, the first time stamp is used. This list of symbols is different than the list used by the older CloudWatch Logs agent. For a summary of these differences, see Timestamp differences between the unified CloudWatch agent and the earlier CloudWatch Logs agent %y %Y Year without century as a zero-padded decimal number. For example, 19 to represent 2019. Year with century as a decimal number. For example, 2019. Manually create or edit the CloudWatch agent configuration file 2592 Amazon CloudWatch User Guide %b %B %m Month as the locale's abbreviated name Month as the locale's full name Month as a zero-padded decimal number %-m Month as a decimal number (not zero-padded) %d Day of the month as a zero-padded decimal number %-d Day of the month as a decimal number (not zero-padded) %A %a %H %I Full name of weekday, such as Monday Abbreviation of weekday, such as Mon Hour (in a 24-hour clock) as a zero-padded decimal number Hour (in a 12-hour clock) as a zero-padded decimal number %-I Hour (in a 12-hour clock) as a decimal number (not zero-padded) %p AM or PM Manually create or edit the CloudWatch agent configuration file 2593 Amazon CloudWatch %M User Guide Minutes as a zero-padded decimal number %-M Minutes as a decimal number (not zero-padded) %S Seconds as a zero-padded decimal number %-S Seconds as a decimal number (not zero padded) %f %Z %z Fractional seconds as a decimal number (1-9 digits), zero-padded on the left. Time zone, for example PST Time zone, expressed as the offset between the local time zone and UTC. For example, -0700. Only this format is supported. For example, -07:00 isn't a valid format. • multi_line_start_pattern – Specifies the pattern for identifying the start of a log message. A log message is made of a line that matches the pattern and any subsequent lines that don't match the pattern. If you omit this field, multi-line mode is disabled, and any line that begins with a non- whitespace character closes the previous log message and starts a new log message. If you include this field, you can specify {timestamp_format} to use the same regular expression as your timestamp format. Otherwise, you can specify a different regular expression for CloudWatch Logs to use to determine the start lines of multi-line entries. • encoding – Specified the encoding of the log file so that it can be read correctly. If you specify an incorrect coding, there might be data loss because characters that can't be decoded are replaced with other characters. Manually create or edit the CloudWatch agent configuration file The default value is utf-8. The following are all possible values: 2594 Amazon CloudWatch User Guide ascii, big5, euc-jp, euc-kr, gbk, gb18030, ibm866, iso2022-jp, iso8859-2, iso8859-3, iso8859-4, iso8859-5, iso8859-6, iso8859-7, iso8859-8, iso8859-8-i, iso8859-10, iso8859-13, iso8859-14, iso8859-15, iso8859-16, koi8-r, koi8-u, macintosh, shift_jis, utf-8, utf-16, utf-16le, UTF-16, UTF-16LE, windows-874, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, x-mac- cyrillic • service.name – Optional. Specifies the service name to be used to populate the entity for finding related telemetry. • deployment.environment – Optional. Specifies the environment name to be used to populate the entity for finding related telemetry. • The windows_events section specifies the type of Windows events to collect from servers running Windows Server. It includes the following fields: • collect_list – Required if windows_events is included. Specifies the types and levels of Windows
acw-ug-750
acw-ug.pdf
750
iso8859-13, iso8859-14, iso8859-15, iso8859-16, koi8-r, koi8-u, macintosh, shift_jis, utf-8, utf-16, utf-16le, UTF-16, UTF-16LE, windows-874, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, x-mac- cyrillic • service.name – Optional. Specifies the service name to be used to populate the entity for finding related telemetry. • deployment.environment – Optional. Specifies the environment name to be used to populate the entity for finding related telemetry. • The windows_events section specifies the type of Windows events to collect from servers running Windows Server. It includes the following fields: • collect_list – Required if windows_events is included. Specifies the types and levels of Windows events to be collected. Each log to be collected has an entry in this section, which can include the following fields: • event_name – Specifies the type of Windows events to log. This is equivalent to the Windows event log channel name: for example, System, Security, Application, and so on. This field is required for each type of Windows event to log. Note When CloudWatch retrieves messages from a Windows log channel, it looks up the log channel based on its Full Name property. Meanwhile, the Windows Event Viewer navigation pane displays the Log Name property of log channels. The Full Name and Log Name do not always match. To confirm the Full Name of a channel, right-click on it in the Windows Event viewer and open Properties. • event_levels – Specifies the levels of event to log. You must specify each level to log. Possible values include INFORMATION, WARNING, ERROR, CRITICAL, and VERBOSE. This field is required for each type of Windows event to log. • log_group_name – Required. Specifies what to use as the log group name in CloudWatch Logs. Manually create or edit the CloudWatch agent configuration file 2595 Amazon CloudWatch User Guide • log_stream_name – Optional. Specifies what to use as the log stream name in CloudWatch Logs. As part of the name, you can use {instance_id}, {hostname}, {local_hostname}, and {ip_address} as variables within the name. {hostname} retrieves the hostname from the EC2 metadata, and {local_hostname} uses the hostname from the network configuration file. If you omit this field, the value of the log_stream_name parameter in the global logs section is used. If that is also omitted, the default value of {instance_id} is used. If a log stream doesn't already exist, it's created automatically. • event_format – Optional. Specifies the format to use when storing Windows events in CloudWatch Logs. xml uses the XML format as in Windows Event Viewer. text uses the legacy CloudWatch Logs agent format. • retention_in_days – Optional. Specifies the number of days to retain the Windows events in the specified log group. • If the agent is creating this log group now, and you omit this field, the retention of this new log group is set to never expire. • If this log group already exists and you specify this field, the new retention that you specify is used. If you omit this field for a log group that already exists, the log group's retention is not changed. The CloudWatch agent wizard uses -1 as the default value for this field when it is used to create the agent configuration file and you don't specify a value for log retention. This -1 value specifies set by the wizard specifies that the events in the log group don't expire. However, manually editing this value to -1 has no effect. Valid values are 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 2192, 2557, 2922, 3288, and 3653. If you configure the agent to write multiple log streams to the same log group, specifying the retention_in_days in one place will set the log retention for the entire log group. If you specify retention_in_days for the same log group in multiple places, the retention is set if all of those values are equal. However, if different retention_in_days values are specified for the same log group in multiple places, the log retention will not be set and the agent will stop, returning an error. Manually create or edit the CloudWatch agent configuration file 2596 Amazon CloudWatch User Guide Note The agent's IAM role or IAM user must have the logs:PutRetentionPolicy for it to be able to set retention policies. For more information, see Allowing the CloudWatch agent to set log retention policy. Warning If you set retention_in_days for a log group that already exists, all logs in that log group that were published before the number of days that you specify are deleted. For example, setting it to 3 would cause all logs from 3 days ago and before to be deleted. • log_stream_name – Optional. Specifies the default log stream name to be used for any logs or Windows events that don't have individual log stream names
acw-ug-751
acw-ug.pdf
751
the logs:PutRetentionPolicy for it to be able to set retention policies. For more information, see Allowing the CloudWatch agent to set log retention policy. Warning If you set retention_in_days for a log group that already exists, all logs in that log group that were published before the number of days that you specify are deleted. For example, setting it to 3 would cause all logs from 3 days ago and before to be deleted. • log_stream_name – Optional. Specifies the default log stream name to be used for any logs or Windows events that don't have individual log stream names defined in the log_stream_name parameter within their entry in collect_list. • endpoint_override – Specifies a FIPS endpoint or private link to use as the endpoint where the agent sends logs. Specifying this field and setting a private link enables you to send the logs to an Amazon VPC endpoint. For more information, see What Is Amazon VPC?. The value of endpoint_override must be a string that is a URL. For example, the following part of the logs section of the configuration file sets the agent to use a VPC Endpoint when sending logs. { "logs": { "endpoint_override": "vpce-XXXXXXXXXXXXXXXXXXXXXXXXX.logs.us- east-1.vpce.amazonaws.com", ...... }, } • force_flush_interval – Specifies in seconds the maximum amount of time that logs remain in the memory buffer before being sent to the server. No matter the setting for this field, if the size of the logs in the buffer reaches 1 MB, the logs are immediately sent to the server. The default value is 5. Manually create or edit the CloudWatch agent configuration file 2597 Amazon CloudWatch User Guide If you are using the agent to report high-resolution metrics in embedded metric format, and you are setting alarms on those metrics, keep this parameter set to the default value of 5. Otherwise, the metrics are reported with a delay that can cause alarming on partial or incomplete data. • credentials – Specifies an IAM role to use when sending logs to a different AWS account. If specified, this field contains one parameter, role_arn. • role_arn – Specifies the ARN of an IAM role to use for authentication when sending logs to a different AWS account. For more information, see Sending metrics, logs, and traces to a different account. If specified here, this overrides the role_arn specified in the agent section of the configuration file, if any. • metrics_collected – This field can contain sections to specify that the agent is to collect logs to enable use cases such as CloudWatch Application Signals and Container Insights with enhanced observability for Amazon EKS. • application_signals (Optional) Specifies that you want to enable CloudWatch Application Signals For more information about this configuration, see Enable CloudWatch Application Signals. • kubernetes – This field can contain an enhanced_container_insights parameter, which you can use to enable Container Insights with enhanced observability for Amazon EKS. • enhanced_container_insights – Set this to true to enable Container Insights with enhanced observability for Amazon EKS. For more information, see Container Insights with enhanced observability for Amazon EKS. • accelerated_compute_metrics – Set this to false to opt out of collecting Nvidia GPU metrics on Amazon EKS clusters. For more information, see NVIDIA GPU metrics. • emf – To collect metrics embedded in logs, it is no longer necessary to add this emf field. This is a legacy field that specified that the agent is to collect logs that are in embedded metric format. You can generate metric data from these logs. For more information, see Embedding metrics within logs. • otlp – Optional. Specifies that you want to collect metrics from the OpenTelemetry SDK. For more information about the fields that you can use in this section, see Collect metrics and traces with OpenTelemetry. The following is an example of a logs section. "logs": { Manually create or edit the CloudWatch agent configuration file 2598 Amazon CloudWatch User Guide "logs_collected": { "files": { "collect_list": [ { "file_path": "c:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\ \Logs\\amazon-cloudwatch-agent.log", "log_group_name": "amazon-cloudwatch-agent.log", "log_stream_name": "my_log_stream_name_1" }, { "file_path": "c:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\ \Logs\\test.log", "log_group_name": "test.log", "log_stream_name": "my_log_stream_name_2" } ] }, "windows_events": { "collect_list": [ { "event_name": "System", "event_levels": [ "INFORMATION", "ERROR" ], "log_group_name": "System", "log_stream_name": "System" }, { "event_name": "CustomizedName", "event_levels": [ "INFORMATION", "ERROR" ], "log_group_name": "CustomizedLogGroup", "log_stream_name": "CustomizedLogStream" } ] } }, "log_stream_name": "my_log_stream_name", "metrics_collected": { "kubernetes": { "enhanced_container_insights": true Manually create or edit the CloudWatch agent configuration file 2599 Amazon CloudWatch } } } User Guide CloudWatch agent configuration file: Traces section By adding a traces section to the CloudWatch agent configuration file, you can enable CloudWatch Application Signals or collect traces from X-Ray and from the OpenTelemetry instrumentation SDK and send them to X-Ray. Important The agent's IAM role or IAM user must have the AWSXrayWriteOnlyAccess policy to send trace data to X-Ray. For more information, see Create IAM roles
acw-ug-752
acw-ug.pdf
752
"ERROR" ], "log_group_name": "CustomizedLogGroup", "log_stream_name": "CustomizedLogStream" } ] } }, "log_stream_name": "my_log_stream_name", "metrics_collected": { "kubernetes": { "enhanced_container_insights": true Manually create or edit the CloudWatch agent configuration file 2599 Amazon CloudWatch } } } User Guide CloudWatch agent configuration file: Traces section By adding a traces section to the CloudWatch agent configuration file, you can enable CloudWatch Application Signals or collect traces from X-Ray and from the OpenTelemetry instrumentation SDK and send them to X-Ray. Important The agent's IAM role or IAM user must have the AWSXrayWriteOnlyAccess policy to send trace data to X-Ray. For more information, see Create IAM roles and users for use with CloudWatch agent. For a quick start for collecting traces, you can add just the following to the CloudWatch agent configuration file. "traces_collected": { "xray": { }, "otlp": { } } If you add the previous section to the CloudWatch agent configuration file and restart the agent, this causes the agent to start collecting traces using the following default options and values. For more information about these parameters, see the parameter definitions later in this section. "traces_collected": { "xray": { "bind_address": "127.0.0.1:2000", "tcp_proxy": { "bind_address": "127.0.0.1:2000" } }, "otlp": { "grpc_endpoint": "127.0.0.1:4317", "http_endpoint": "127.0.0.1:4318" Manually create or edit the CloudWatch agent configuration file 2600 Amazon CloudWatch } } User Guide The traces section can include the following fields: • traces_collected – Required if the traces section is included. Specifies which SDKs to collect traces from. It can include the following fields: • application_signals – Optional. Specifies that you want to enable CloudWatch Application Signals For more information about this configuration, see Enable CloudWatch Application Signals. • xray – Optional. Specifies that you want to collect traces from the X-Ray SDK. This section can include the following fields: • bind_address – Optional. Specifies the UDP address for the CloudWatch agent to use to listen for X-Ray traces. The format is ip:port. This address must match the address set in the X-Ray SDK. If you omit this field, the default of 127.0.0.1:2000 is used. • tcp_proxy – Optional. Configures the address for a proxy used to support X-Ray remote sampling. For more information, see Configuring sampling rules in the X-Ray documentation. This section can contain the following field. • bind_address – Optional. Specifies the TCP address to which the CloudWatch agent should set up the proxy. The format is ip:port. This address must match the address set in the X-Ray SDK. If you omit this field, the default of 127.0.0.1:2000 is used. • otlp – Optional. Specifies that you want to collect traces from the OpenTelemetry SDK. For more information about the fields that you can use in this section, see Collect metrics and traces with OpenTelemetry). For more information about the AWS Distro for OpenTelemetry, see AWS Distro for OpenTelemetry. For more information about the AWS Distro for OpenTelemetry SDKs, see Introduction. This section can include the following fields: • grpc_endpoint – Optional. Specifies the address for the CloudWatch agent to use to listen for OpenTelemetry traces sent using gRPC Remote Procedure Calls. The format is ip:port. This address must match the address set for the gRPC exporter in the OpenTelemetry SDK. Manually create or edit the CloudWatch agent configuration file 2601 Amazon CloudWatch User Guide If you omit this field, the default of 127.0.0.1:4317 is used. • http_endpoint – Optional. Specifies the address for the CloudWatch agent to use to listen for OTLP traces sent over HTTP. The format is ip:port. This address must match the address set for the HTTP exporter in the OpenTelemetry SDK. If you omit this field, the default of 127.0.0.1:4318 is used. • concurrency – Optional. Specifies the maximum number of concurrent calls to X-Ray that can be used to upload traces. The default value is 8 • local_mode – Optional. If true, the agent doesn't collect Amazon EC2 instance metadata. The default is false • endpoint_override – Optional. Specifies a FIPS endpoint or private link to use as the endpoint where the CloudWatch agent sends traces. Specifying this field and setting a private link enables you to send the traces to an Amazon VPC endpoint. For more information, see What is Amazon VPC The value of endpoint_override must be a string that is a URL. • region_override – Optional. Specifies the Region to use for the X-Ray endpoint. The CloudWatch agent sends the traces to X-Ray in the specified Region. If you omit this field, the agent sends the traces to the Region where the Amazon EC2 instance is located. If you specify a Region here, it takes precedence over the setting of the region parameter in the agent section of the configuration file. • proxy_override – Optional. Specifies the proxy server address for the CloudWatch agent to use when sending requests to X-Ray. The proxy server's protocol must be
acw-ug-753
acw-ug.pdf
753
string that is a URL. • region_override – Optional. Specifies the Region to use for the X-Ray endpoint. The CloudWatch agent sends the traces to X-Ray in the specified Region. If you omit this field, the agent sends the traces to the Region where the Amazon EC2 instance is located. If you specify a Region here, it takes precedence over the setting of the region parameter in the agent section of the configuration file. • proxy_override – Optional. Specifies the proxy server address for the CloudWatch agent to use when sending requests to X-Ray. The proxy server's protocol must be specified as part of this address. • credentials – Specifies an IAM role to use when sending traces to a different AWS account. If specified, this field contains one parameter, role_arn. • role_arn – Specifies the ARN of an IAM role to use for authentication when sending traces to a different AWS account. For more information, see Sending metrics, logs, and traces to a different account. If specified here, this overrides the role_arn specified in the agent section of the configuration file, if any. • transit_spans_in_otlp_format – Optional. If true, sends traces to X-Ray in the OpenTelemetry Protocol format, which supports span events in Transaction Search. For more information, see Adding custom attributes. The default is false. Manually create or edit the CloudWatch agent configuration file 2602 Amazon CloudWatch User Guide CloudWatch agent configuration file: Complete examples The following is an example of a complete CloudWatch agent configuration file for a Linux server. The items listed in the measurement sections for the metrics you want to collect can either specify the complete metric name such or just the part of the metric name that will be appended to the type of resource. For example, specifying either reads or diskio_reads in the measurement section of the diskio section will cause the diskio_reads metric to be collected. This example includes both ways of specifying metrics in the measurement section. { "agent": { "metrics_collection_interval": 10, "logfile": "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log" }, "metrics": { "namespace": "MyCustomNamespace", "metrics_collected": { "cpu": { "resources": [ "*" ], "measurement": [ {"name": "cpu_usage_idle", "rename": "CPU_USAGE_IDLE", "unit": "Percent"}, {"name": "cpu_usage_nice", "unit": "Percent"}, "cpu_usage_guest" ], "totalcpu": false, "metrics_collection_interval": 10, "append_dimensions": { "customized_dimension_key_1": "customized_dimension_value_1", "customized_dimension_key_2": "customized_dimension_value_2" } }, "disk": { "resources": [ "/", "/tmp" ], "measurement": [ {"name": "free", "rename": "DISK_FREE", "unit": "Gigabytes"}, Manually create or edit the CloudWatch agent configuration file 2603 Amazon CloudWatch "total", "used" ], "ignore_file_system_types": [ "sysfs", "devtmpfs" ], "metrics_collection_interval": 60, "append_dimensions": { "customized_dimension_key_3": "customized_dimension_value_3", "customized_dimension_key_4": "customized_dimension_value_4" User Guide } }, "diskio": { "resources": [ "*" ], "measurement": [ "reads", "writes", "read_time", "write_time", "io_time" ], "metrics_collection_interval": 60 }, "swap": { "measurement": [ "swap_used", "swap_free", "swap_used_percent" ] }, "mem": { "measurement": [ "mem_used", "mem_cached", "mem_total" ], "metrics_collection_interval": 1 }, "net": { "resources": [ "eth0" ], Manually create or edit the CloudWatch agent configuration file 2604 Amazon CloudWatch User Guide "measurement": [ "bytes_sent", "bytes_recv", "drop_in", "drop_out" ] }, "netstat": { "measurement": [ "tcp_established", "tcp_syn_sent", "tcp_close" ], "metrics_collection_interval": 60 }, "processes": { "measurement": [ "running", "sleeping", "dead" ] } }, "append_dimensions": { "ImageId": "${aws:ImageId}", "InstanceId": "${aws:InstanceId}", "InstanceType": "${aws:InstanceType}", "AutoScalingGroupName": "${aws:AutoScalingGroupName}" }, "aggregation_dimensions" : [["ImageId"], ["InstanceId", "InstanceType"], ["d1"],[]], "force_flush_interval" : 30 }, "logs": { "logs_collected": { "files": { "collect_list": [ { "file_path": "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch- agent.log", "log_group_name": "amazon-cloudwatch-agent.log", "log_stream_name": "amazon-cloudwatch-agent.log", "timezone": "UTC" }, Manually create or edit the CloudWatch agent configuration file 2605 Amazon CloudWatch { User Guide "file_path": "/opt/aws/amazon-cloudwatch-agent/logs/test.log", "log_group_name": "test.log", "log_stream_name": "test.log", "timezone": "Local" } ] } }, "log_stream_name": "my_log_stream_name", "force_flush_interval" : 15, "metrics_collected": { "kubernetes": { "enhanced_container_insights": true } } } } The following is an example of a complete CloudWatch agent configuration file for a server running Windows Server. { "agent": { "metrics_collection_interval": 60, "logfile": "c:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\\Logs\\amazon- cloudwatch-agent.log" }, "metrics": { "namespace": "MyCustomNamespace", "metrics_collected": { "Processor": { "measurement": [ {"name": "% Idle Time", "rename": "CPU_IDLE", "unit": "Percent"}, "% Interrupt Time", "% User Time", "% Processor Time" ], "resources": [ "*" ], "append_dimensions": { "customized_dimension_key_1": "customized_dimension_value_1", Manually create or edit the CloudWatch agent configuration file 2606 Amazon CloudWatch User Guide "customized_dimension_key_2": "customized_dimension_value_2" } }, "LogicalDisk": { "measurement": [ {"name": "% Idle Time", "unit": "Percent"}, {"name": "% Disk Read Time", "rename": "DISK_READ"}, "% Disk Write Time" ], "resources": [ "*" ] }, "customizedObjectName": { "metrics_collection_interval": 60, "customizedCounterName": [ "metric1", "metric2" ], "resources": [ "customizedInstances" ] }, "Memory": { "metrics_collection_interval": 5, "measurement": [ "Available Bytes", "Cache Faults/sec", "Page Faults/sec", "Pages/sec" ] }, "Network Interface": { "metrics_collection_interval": 5, "measurement": [ "Bytes Received/sec", "Bytes Sent/sec", "Packets Received/sec", "Packets Sent/sec" ], "resources": [ "*" ], "append_dimensions": { Manually create or edit the CloudWatch agent configuration file 2607 Amazon CloudWatch User Guide "customized_dimension_key_3": "customized_dimension_value_3" } }, "System": { "measurement": [ "Context Switches/sec", "System Calls/sec", "Processor Queue Length" ] } }, "append_dimensions": { "ImageId": "${aws:ImageId}", "InstanceId": "${aws:InstanceId}", "InstanceType": "${aws:InstanceType}", "AutoScalingGroupName": "${aws:AutoScalingGroupName}" }, "aggregation_dimensions" : [["ImageId"], ["InstanceId", "InstanceType"], ["d1"],[]] }, "logs": { "logs_collected":
acw-ug-754
acw-ug.pdf
754
"customizedCounterName": [ "metric1", "metric2" ], "resources": [ "customizedInstances" ] }, "Memory": { "metrics_collection_interval": 5, "measurement": [ "Available Bytes", "Cache Faults/sec", "Page Faults/sec", "Pages/sec" ] }, "Network Interface": { "metrics_collection_interval": 5, "measurement": [ "Bytes Received/sec", "Bytes Sent/sec", "Packets Received/sec", "Packets Sent/sec" ], "resources": [ "*" ], "append_dimensions": { Manually create or edit the CloudWatch agent configuration file 2607 Amazon CloudWatch User Guide "customized_dimension_key_3": "customized_dimension_value_3" } }, "System": { "measurement": [ "Context Switches/sec", "System Calls/sec", "Processor Queue Length" ] } }, "append_dimensions": { "ImageId": "${aws:ImageId}", "InstanceId": "${aws:InstanceId}", "InstanceType": "${aws:InstanceType}", "AutoScalingGroupName": "${aws:AutoScalingGroupName}" }, "aggregation_dimensions" : [["ImageId"], ["InstanceId", "InstanceType"], ["d1"],[]] }, "logs": { "logs_collected": { "files": { "collect_list": [ { "file_path": "c:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\\Logs\ \amazon-cloudwatch-agent.log", "log_group_name": "amazon-cloudwatch-agent.log", "timezone": "UTC" }, { "file_path": "c:\\ProgramData\\Amazon\\AmazonCloudWatchAgent\\Logs\ \test.log", "log_group_name": "test.log", "timezone": "Local" } ] }, "windows_events": { "collect_list": [ { "event_name": "System", "event_levels": [ "INFORMATION", Manually create or edit the CloudWatch agent configuration file 2608 Amazon CloudWatch User Guide "ERROR" ], "log_group_name": "System", "log_stream_name": "System", "event_format": "xml" }, { "event_name": "CustomizedName", "event_levels": [ "WARNING", "ERROR" ], "log_group_name": "CustomizedLogGroup", "log_stream_name": "CustomizedLogStream", "event_format": "xml" } ] } }, "log_stream_name": "example_log_stream_name" } } Save the CloudWatch agent configuration file manually If you create or edit the CloudWatch agent configuration file manually, you can give it any name. After you have created the file, you can copy it to other servers where you want to run the agent. Uploading the CloudWatch agent configuration file to Systems Manager Parameter Store If you plan to use the SSM Agent to install the CloudWatch agent on servers, after you manually edit the CloudWatch agent configuration file, you can upload it to Systems Manager Parameter Store. To do so, use the Systems Manager put-parameter command. To be able to store the file in Parameter Store, you must use an IAM role with sufficient permissions. For more information, see Create IAM roles and users for use with the CloudWatch agent. Use the following command, where parameter name is the name to be used for this file in Parameter Store and configuration_file_pathname is the path and file name of the configuration file that you edited. Manually create or edit the CloudWatch agent configuration file 2609 Amazon CloudWatch User Guide aws ssm put-parameter --name "parameter name" --type "String" --value file://configuration_file_pathname Enable CloudWatch Application Signals Use CloudWatch Application Signals to automatically instrument your applications on AWS so that you can track application performance against your business objectives. Application Signals provides you a unified, application-centric view of your Java applications, their dependencies, and their edges. For more information, see Application Signals. CloudWatch Application Signals leverages the CloudWatch agent to receive metrics and traces from your auto-instrumented applications, optionally apply rules to reduce high cardinality, and then publish the processed telemetry to CloudWatch. You can provide custom configuration to the CloudWatch agent specifically for Application Signals using the agent configuration file. To start with, the presence of an application_signals section under the metrics_collected section within the logs section of the agent configuration file specifies that the CloudWatch agent will receive metrics from your auto-instrumented applications. Similarly, the presence of an application_signals section under the traces_collected section within the traces section of the agent configuration file specifies that the CloudWatch agent is enabled to receive traces from your auto-instrumented applications. In addition, you can optionally pass in custom configuration rules to reduce publishing high-cardinality telemetry as outlined in this section. • For Amazon EKS clusters, when you install the Amazon CloudWatch Observability EKS add-on, the CloudWatch agent is by default enabled to receive both metrics and traces from your auto- instrumented applications. If you would like to optionally pass in custom configuration rules, you can do so by passing in a custom agent configuration to the Amazon EKS add-on when you create or update it by using additional configuration, as outlined in (Optional) Additional configuration. • For RedHat for OpenShift on AWS (ROSA), when you install the CloudWatch agent operator using helm charts, the CloudWatch agent is by default enabled to receive both metrics and traces from your auto-instrumented applications. If you would like to optionally pass in custom configuration rules, you can do so by passing in a custom agent configuration by using the Helm chart, as outlined in (Optional) [Additional configuration], as outlined in (Optional) Additional configuration. • For other supported platforms including Amazon EC2, you must start the CloudWatch agent with an agent configuration that enables Application Signals by specifying the Manually create or edit the CloudWatch agent configuration file 2610 Amazon CloudWatch User Guide application_signals sections and optionally any custom configuration rules as outlined later in this section. The following is an overview of the fields in the CloudWatch agent configuration file that are related to CloudWatch Application Signals. • logs • metrics_collected – This field can contain sections to specify that the agent is to collect logs to enable use
acw-ug-755
acw-ug.pdf
755
in (Optional) Additional configuration. • For other supported platforms including Amazon EC2, you must start the CloudWatch agent with an agent configuration that enables Application Signals by specifying the Manually create or edit the CloudWatch agent configuration file 2610 Amazon CloudWatch User Guide application_signals sections and optionally any custom configuration rules as outlined later in this section. The following is an overview of the fields in the CloudWatch agent configuration file that are related to CloudWatch Application Signals. • logs • metrics_collected – This field can contain sections to specify that the agent is to collect logs to enable use cases such as CloudWatch Application Signals and Container Insights with enhanced observability for Amazon EKS. Note Previously this section was also used to specify that the agent is to collect logs that are in embedded metric format. Those settings are no longer needed. • application_signals (Optional) Specifies that you want to enable CloudWatch Application Signals to receive metrics from your auto-instrumented applications to facilitate CloudWatch Application Signals. • rules (Optional) An array of rules to conditionally select metrics and traces and apply actions to handle high-cardinality scenarios. Each rule can contain the following fields: • rule_name (Optional) The name of the rule. • selectors (Optional) An array of metrics and traces dimension matchers. Each selector must provide the following fields: • dimension Required if selectors is not empty. This specifies the dimension of metrics and traces to use as a filter. • match Required if selectors is not empty. A wildcard pattern used for matching values of the specified dimension. • action (Optional) The action to be applied to metrics and traces that match the specified selectors. The value of action must be one of the following keywords: • keep Specifies to send only the metrics and traces to CloudWatch if matched by the selectors. • drop Specifies to drop the metric and traces that match the selectors. Manually create or edit the CloudWatch agent configuration file 2611 Amazon CloudWatch User Guide • replace Specifies to replace the dimensions of the metrics and traces that match selectors. They are replaced according to the replacements section. • replacements Required if action is replace. An array of dimension and value pairs that will be applied to metrics and traces that match the specified selectors when the action is replace. Each replacement must provide the following fields: • target_dimension Required if replacements is not empty. Specifies the dimension that needs to be replace. • value Required if replacements is not empty. The value to replace the original value of target_dimension with. • limiter (Optional) Use this section to limit how many metrics and dimensions Application Signals sends to CloudWatch, to optimize your costs. • disabled (Optional) If true, the metric limiting feature is disabled. The default is false • drop_threshold (Optional) The maximum number of distinct metrics per service in one rotation interval that can be exported by one CloudWatch agent. The default is 500. • rotation_interval (Optional) The interval at which the limiter resets the metric records for distinction counting. This is expressed as a string with a sequence of numbers and a unit suffix. Fractions are supported. The supported unit suffixes are s, m, h, ms, us, and ns The default is 1h for one hour. • log_dropped_metrics (Optional) Specifies whether the agent should write logs to the CloudWatch agent logs when Application Signals metrics are dropped. The default is false. Note To activate this logging, the debug parameter in the agent section must also be set to true. • traces • traces_collected • application_signals Optional. Specify this to enable the CloudWatch agent to receive traces from your auto-instrumented applications for facilitating CloudWatch Application Signals. Manually create or edit the CloudWatch agent configuration file 2612 Amazon CloudWatch Note User Guide Even though the custom application_signals rules are specified under the metrics_collected section that is contained in the logs section, they also implicitly apply to the traces_collected section as well. The same set of rules will apply to both metrics and traces. When there are multiple rules with different actions, they apply in the following sequence: keep, then drop, then replace. The following is an example of a full CloudWatch agent configuration file that applies custom rules. { "logs": { "metrics_collected": { "application_signals": { "rules": [ { "rule_name": "keep01", "selectors": [ { "dimension": "Service", "match": "pet-clinic-frontend" }, { "dimension": "RemoteService", "match": "customers-service" } ], "action": "keep" }, { "rule_name": "drop01", "selectors": [ { "dimension": "Operation", "match": "GET /api/customer/owners/*" } ], "action": "drop" Manually create or edit the CloudWatch agent configuration file 2613 User Guide Amazon CloudWatch }, { "rule_name": "replace01", "selectors": [ { "dimension": "Operation", "match": "PUT /api/customer/owners/*/pets/*" }, { "dimension": "RemoteOperation", "match": "PUT /owners" } ], "replacements": [ { "target_dimension": "Operation", "value": "PUT /api/customer/owners/{ownerId}/pets{petId}" } ], "action": "replace" } ] }
acw-ug-756
acw-ug.pdf
756
file that applies custom rules. { "logs": { "metrics_collected": { "application_signals": { "rules": [ { "rule_name": "keep01", "selectors": [ { "dimension": "Service", "match": "pet-clinic-frontend" }, { "dimension": "RemoteService", "match": "customers-service" } ], "action": "keep" }, { "rule_name": "drop01", "selectors": [ { "dimension": "Operation", "match": "GET /api/customer/owners/*" } ], "action": "drop" Manually create or edit the CloudWatch agent configuration file 2613 User Guide Amazon CloudWatch }, { "rule_name": "replace01", "selectors": [ { "dimension": "Operation", "match": "PUT /api/customer/owners/*/pets/*" }, { "dimension": "RemoteOperation", "match": "PUT /owners" } ], "replacements": [ { "target_dimension": "Operation", "value": "PUT /api/customer/owners/{ownerId}/pets{petId}" } ], "action": "replace" } ] } } }, "traces": { "traces_collected": { "application_signals": {} } } } For the previous example configuration file, the rules are processed as follows: 1. Rule keep01 ensures that any metrics and traces with the dimension Service as pet-clinic- frontend and the dimension RemoteService as customers-service are kept. 2. For the processed metrics and traces after applying keep01, the drop01 rule ensures that metrics and traces with the dimension Operation as GET /api/customer/owners/* are dropped. 3. For the processed metrics and traces after applying drop01, the replace01 rule updates metrics and traces that have the dimension Operation as PUT /api/customer/owners/*/ Manually create or edit the CloudWatch agent configuration file 2614 Amazon CloudWatch User Guide pets/* and the dimension RemoteOperation as PUT /owners such that their Operation dimension is now replaced to be PUT /api/customer/owners/{ownerId}/pets{petId}. The following is a complete example of a CloudWatch configuration file that manages cardinality in Application Signals by changing the metric limit to 100, enabling the logging of dropped metrics, and setting the rotation interval to two hours. { "logs": { "metrics_collected": { "application_signals": { "limiter": { "disabled": false, "drop_threshold": 100, "rotation_interval": "2h", "log_dropped_metrics": true } } }, "traces": { "traces_collected": { "application_signals": {} } } } } Collect network performance metrics EC2 instances running on Linux that use the Elastic Network Adapter (ENA) publish network performance metrics. Version 1.246396.0 and later of the CloudWatch agent enable you to import these network performance metrics into CloudWatch. When you import these network performance metrics into CloudWatch, they are charged as CloudWatch custom metrics. For more information about the ENA driver, see Enabling enhanced networking with the Elastic Network Adapter (ENA) on Linux instances and Enabling enhanced networking with the Elastic Network Adapter (ENA) on Windows instances. How you set up the collection of network performance metrics differs on Linux servers and Windows servers. Manually create or edit the CloudWatch agent configuration file 2615 Amazon CloudWatch User Guide The following table lists these network performance metrics enabled by the ENA adapter. When the CloudWatch agent imports these metrics into CloudWatch from Linux instances, it prepends ethtool_ at the beginning of each of these metric names. Metric Description Name on Linux servers: bw_in_all owance_exceeded The number of packets queued and/or dropped because the inbound aggregate bandwidth exceeded the maximum for the instance. Name on Windows servers: Aggregate inbound BW allowance exceeded This metric is collected only if you have listed it in the ethtool subsection of the metrics_c ollected section of the CloudWatch agent configuration file. For more information, see Collect network performance metrics Unit: None Name on Linux servers: bw_out_al lowance_exceeded The number of packets queued and/or dropped because the outbound aggregate bandwidth exceeded the maximum for the instance. Name on Windows servers: Aggregate outbound BW allowance exceeded Name on Linux servers:conntrack _allowance_available Name on Windows servers: Available connection tracking allowance This metric is collected only if you have listed it in the ethtool subsection of the metrics_c ollected section of the CloudWatch agent configuration file. For more information, see Collect network performance metrics Unit: None Reports the number of tracked connections that can be established by the instance before hitting the Connections Tracked allowance of that instance type. This metric is available only on Nitro-based EC2 instances using the Linux driver for Elastic Network Adapter (ENA) starting from version 2.8.1, and on computers using the Windows driver for Elastic Network Adapter (ENA) starting from version 2.6.0. Manually create or edit the CloudWatch agent configuration file 2616 Amazon CloudWatch Metric User Guide Description This metric is collected only if you have listed it in the ethtool subsection of the metrics_c ollected section of the CloudWatch agent configuration file. For more information, see Collect network performance metrics Unit: None Name on Linux servers:ena_srd_mode Name on Windows servers: ena srd mode Describes which ENA Express features are enabled. For more information about ENA Express, see Improve network performance with ENA Express on Linux instances Values are as follows: • 0 = ENA Express off, UDP off • 1 = ENA Express on, UDP off • 2 = ENA Express off, UDP on Note This happens only when ENA Express was originally enabled, and UDP was configure d to use it. The
acw-ug-757
acw-ug.pdf
757
metrics_c ollected section of the CloudWatch agent configuration file. For more information, see Collect network performance metrics Unit: None Name on Linux servers:ena_srd_mode Name on Windows servers: ena srd mode Describes which ENA Express features are enabled. For more information about ENA Express, see Improve network performance with ENA Express on Linux instances Values are as follows: • 0 = ENA Express off, UDP off • 1 = ENA Express on, UDP off • 2 = ENA Express off, UDP on Note This happens only when ENA Express was originally enabled, and UDP was configure d to use it. The prior value is retained for UDP traffic. • 3 = ENA Express on, UDP on Manually create or edit the CloudWatch agent configuration file 2617 Amazon CloudWatch Metric Description User Guide Name on Linux servers:ena_srd_e ligible_tx_pkts The number of network packets sent within a given time period that meet AWS Scalable Reliable Datagram (SRD) requirements for eligibility, as Name on Windows servers: ena srd eligible tx pkts follows: • Both sending and receiving instance types are supported. • Both sending and receiving instances must have ENA Express configured. • The sending and receiving instances must be on the same subnet. • The network path between the instances must not include middleware boxes. ENA Express doesn't currently support middleware boxes. Name on Linux servers:ena_srd_t x_pkts The number of SRD packets transmitted within a given time period. Name on Windows servers: ena srd tx pkts Name on Linux servers:ena_srd_r x_pkts The number of SRD packets received within a given time period. Name on Windows servers: ena srd rx pkts Name on Linux servers:ena_srd_r esource_utilization Name on Windows servers: ena srd resource utilization The percentage of the maximum allowed memory utilization for concurrent SRD connections that the instance has consumed. Manually create or edit the CloudWatch agent configuration file 2618 Amazon CloudWatch Metric Description User Guide Name on Linux servers: linklocal _allowance_exceeded The number of packets dropped because the PPS of the traffic to local proxy services exceeded the Name on Windows servers: Link local packet rate allowance exceeded maximum for the network interface. This impacts traffic to the DNS service, the Instance Metadata Service, and the Amazon Time Sync Service, but does not impact traffic to custom DNS resolvers. This metric is collected only if you have listed it in the ethtool subsection of the metrics_c ollected section of the CloudWatch agent configuration file. For more information, see Collect network performance metrics Unit: None Name on Linux servers: pps_allow ance_exceeded The number of packets queued and/or dropped because the bidirectional PPS exceeded the maximum for the instance. Name on Windows servers: PPS allowance exceeded This metric is collected only if you have listed it in the ethtool subsection of the metrics_c ollected section of the CloudWatch agent configuration file. For more information, see Collect network performance metrics Unit: None Linux setup On Linux servers, the ethtool plugin enables you to import the network performance metrics into CloudWatch. ethtool is a standard Linux utility that can collect statistics about Ethernet devices on Linux servers. The statistics it collects depend on the network device and driver. Examples of these statistics include tx_cnt, rx_bytes, tx_errors, and align_errors. When you use the ethtool plugin Manually create or edit the CloudWatch agent configuration file 2619 Amazon CloudWatch User Guide with the CloudWatch agent, you can also import these statistics into CloudWatch, along with the EC2 network performance metrics listed earlier in this section. Tip To find the statistics available on our operating system and network device, use the ethtool –S command. When the CloudWatch agent imports metrics into CloudWatch, it adds an ethtool_ prefix to the names of all imported metrics. So the standard ethtool statistic rx_bytes is called ethtool_rx_bytes in CloudWatch, and the EC2 network performance metric bw_in_allowance_exceeded is called ethtool_bw_in_allowance_exceeded in CloudWatch. On Linux servers, to import ethtool metrics, add an ethtool section to the metrics_collected section of the CloudWatch agent configuration file. The ethtool section can include the following subsections: • interface_include— Including this section causes the agent to collect metrics from only the interfaces that have names listed in this section. If you omit this section, metrics are collected from all Ethernet interfaces that aren't listed in interface_exclude. The default ethernet interface is eth0. • interface_exclude— If you include this section, list the Ethernet interfaces that you don't want to collect metrics from. The ethtool plugin always ignores loopback interfaces. • metrics_include— This section lists the metrics to import into CloudWatch. It can include both standard statistics collected by ethtool and Amazon EC2 high-resolution network metrics. The following example displays part of the CloudWatch agent configuration file. This configuration collects the standard ethtool metrics rx_packets and tx_packets, and the Amazon EC2 network performance metrics from only the eth1 interface. For more information about
acw-ug-758
acw-ug.pdf
758
that aren't listed in interface_exclude. The default ethernet interface is eth0. • interface_exclude— If you include this section, list the Ethernet interfaces that you don't want to collect metrics from. The ethtool plugin always ignores loopback interfaces. • metrics_include— This section lists the metrics to import into CloudWatch. It can include both standard statistics collected by ethtool and Amazon EC2 high-resolution network metrics. The following example displays part of the CloudWatch agent configuration file. This configuration collects the standard ethtool metrics rx_packets and tx_packets, and the Amazon EC2 network performance metrics from only the eth1 interface. For more information about the CloudWatch agent configuration file, see Manually create or edit the CloudWatch agent configuration file. "metrics": { Manually create or edit the CloudWatch agent configuration file 2620 Amazon CloudWatch User Guide "append_dimensions": { "InstanceId": "${aws:InstanceId}" }, "metrics_collected": { "ethtool": { "interface_include": [ "eth1" ], "metrics_include": [ "bw_in_allowance_exceeded", "bw_out_allowance_exceeded", "conntrack_allowance_exceeded", "linklocal_allowance_exceeded", "pps_allowance_exceeded" ] } } } Windows setup On Windows servers, the network performance metrics are available through Windows Performance Counters, which the CloudWatch agent already collects metrics from. So you do not need a plugin to collect these metrics from Windows servers. The following is a sample configuration file to collect network performance metrics from Windows. For more information about editing the CloudWatch agent configuration file, see Manually create or edit the CloudWatch agent configuration file. { "metrics": { "append_dimensions": { "InstanceId": "${aws:InstanceId}" }, "metrics_collected": { "ENA Packets Shaping": { "measurement": [ "Aggregate inbound BW allowance exceeded", "Aggregate outbound BW allowance exceeded", "Connection tracking allowance exceeded", "Link local packet rate allowance exceeded", "PPS allowance exceeded" ], Manually create or edit the CloudWatch agent configuration file 2621 Amazon CloudWatch User Guide "metrics_collection_interval": 60, "resources": [ "*" ] } } } } Viewing network performance metrics After importing network performance metrics into CloudWatch, you can view these metrics as time series graphs, and create alarms that can watch these metrics and notify you if they breach a threshold that you specify. The following procedure shows how to view ethtool metrics as a time series graph. For more information about setting alarms, see Using Amazon CloudWatch alarms. Because all of these metrics are aggregate counters, you can use CloudWatch metric math functions such as RATE(METRICS()) to calculate the rate for these metrics in graphs or use them to set alarms. For more information about metric math functions, see Using math expressions with CloudWatch metrics. To view network performance metrics in the CloudWatch console 1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 2. In the navigation pane, choose Metrics. 3. Choose the namespace for the metrics collected by the agent. By default, this is CWAgent, but you may have specified a different namespace in the CloudWatch agent configuration file. 4. Choose a metric dimension (for example, Per-Instance Metrics). 5. The All metrics tab displays all metrics for that dimension in the namespace. You can do the following: a. To graph a metric, select the check box next to the metric. To select all metrics, select the check box in the heading row of the table. To sort the table, use the column heading. To filter by resource, choose the resource ID, and then choose Add to search. To filter by metric, choose the metric name, and then choose Add to search. b. c. d. 6. (Optional) To add this graph to a CloudWatch dashboard, choose Actions, and then choose Add to dashboard. Manually create or edit the CloudWatch agent configuration file 2622 Amazon CloudWatch User Guide Collect NVIDIA GPU metrics You can use the CloudWatch agent to collect NVIDIA GPU metrics from Linux servers. To set this up, add a nvidia_gpu section inside the metrics_collected section of the CloudWatch agent configuration file. For more information, see Linux section. Additionally, the instance must have an NVIDIA driver installed. NVIDIA drivers on pre-installed on some Amazon Machine Images (AMIs). Otherwise, you can manually install the driver. For more information, see Install NVIDIA drivers on Linux instances. The following metrics can be collected. All of these metrics are collected with no CloudWatch Unit, but you can specify a unit for each metric by adding a parameter to the CloudWatch agent configuration file. For more information, see Linux section. Metric Metric name in CloudWatc h Description utilizati nvidia_smi_utiliza on_gpu tion_gpu The percentage of time over the past sample period during which one or more kernals on the GPU was running. temperatu nvidia_smi_tempera The core GPU temperature in degrees Celsius. re_gpu ture_gpu power_dra nvidia_smi_power_d w raw The last measured power draw for the entire board, in watts. utilizati nvidia_smi_utiliza on_memory tion_memory The percentage of time over the past sample period during which global (device) memory was being read or written. fan_speed nvidia_smi_fan_spe ed The percentage of maximum fan speed that the device's fan is currently intended to run at. memory_to
acw-ug-759
acw-ug.pdf
759
Metric Metric name in CloudWatc h Description utilizati nvidia_smi_utiliza on_gpu tion_gpu The percentage of time over the past sample period during which one or more kernals on the GPU was running. temperatu nvidia_smi_tempera The core GPU temperature in degrees Celsius. re_gpu ture_gpu power_dra nvidia_smi_power_d w raw The last measured power draw for the entire board, in watts. utilizati nvidia_smi_utiliza on_memory tion_memory The percentage of time over the past sample period during which global (device) memory was being read or written. fan_speed nvidia_smi_fan_spe ed The percentage of maximum fan speed that the device's fan is currently intended to run at. memory_to nvidia_smi_memory_ Reported total memory, in MB. tal total memory_us nvidia_smi_memory_ Memory used, in MB. ed used Manually create or edit the CloudWatch agent configuration file 2623 Amazon CloudWatch Metric Metric name in CloudWatc h Description User Guide memory_fr nvidia_smi_memory_ Memory free, in MB. ee free pcie_link nvidia_smi_pcie_li The current link generation. _gen_curr nk_gen_current ent pcie_link nvidia_smi_pcie_li The current link width. _width_cu nk_width_current rrent encoder_s nvidia_smi_encoder Current number of encoder sessions. tats_sess _stats_session_cou ion_count nt encoder_s nvidia_smi_encoder tats_aver _stats_average_fps The moving average of the encode frames per second. age_fps encoder_s nvidia_smi_encoder tats_aver _stats_average_lat The moving average of the encode latency in microseconds. age_laten ency cy clocks_cu nvidia_smi_clocks_ rrent_gra current_graphics The current frequency of the graphics (shader) clock. phics clocks_cu nvidia_smi_clocks_ rrent_sm current_sm The current frequency of the Streaming Multiproc essor (SM) clock. clocks_cu nvidia_smi_clocks_ The current frequency of the memory clock. rrent_mem current_memory ory Manually create or edit the CloudWatch agent configuration file 2624 Amazon CloudWatch Metric Metric name in CloudWatc h Description User Guide clocks_cu nvidia_smi_clocks_ rrent_vid current_video The current frequency of the video (encoder plus decoder) clocks. eo All of these metrics are collected with the following dimensions: Dimension Description index name arch A unique identifier for the GPU on this server. Represents the NVIDIA Management Library (NVML) index of the device. The type of GPU. For example, NVIDIA Tesla A100 The server architecture. Collect Java Management Extensions (JMX) metrics You can use the CloudWatch agent to collect Java Management Extensions (JMX) metrics from your Java applications. The CloudWatch agent supports collecting these metrics from the following versions: Manually create or edit the CloudWatch agent configuration file 2625 Amazon CloudWatch • JVM 8 and later • Kafka 0.8.2.x and later • Tomcat 9, 10.1, and 11 (beta) Amazon EC2 To enable JMX in your JVM instance User Guide For the CloudWatch agent to be able to collect JMX metrics, your application’s JVM must bind to a port using the com.sun.management.jmxremote.port system property. java -Dcom.sun.management.jmxremote.port=port-number -jar example.jar For more information and other configurations, see the JMX documentation. Amazon EKS To enable JMX on your Java application pods When using the CloudWatch Observability EKS add-on, you can manage how JMX metrics are enabled with annotations. For more information, see Install the CloudWatch agent with the Amazon CloudWatch Observability EKS add-on or the Helm chart. To enable JMX metrics collection from a workload, add the following annotations to the workload manifest file under the PodTemplate section: • instrumentation.opentelemetry.io/inject-java: "true" • One or more of the following: • For JVM metrics: cloudwatch.aws.amazon.com/inject-jmx-jvm: "true" • For Kafka broker metrics: cloudwatch.aws.amazon.com/inject-jmx-kafka: "true" • For Kafka consumer metrics: cloudwatch.aws.amazon.com/inject-jmx-kafka- consumer: "true" • For Kafka producer metrics: cloudwatch.aws.amazon.com/inject-jmx-kafka- producer: "true" • For Tomcat metrics: cloudwatch.aws.amazon.com/inject-jmx-tomcat: "true" Manually create or edit the CloudWatch agent configuration file 2626 Amazon CloudWatch User Guide To start collecting JMX metrics, add a jmx section inside the metrics_collected section of the CloudWatch agent configuration file. The jmx section can contain the following fields. • jvm – Optional. Specifies that you want to retrieve Java Virtual Machine (JVM) metrics from the instance. For more information, see Collect JVM metrics. This section can include the following fields: • measurement – Specifies the array of JVM metrics to be collected. For a list of the possible values to use here, see the Metric column in the table in Collect JVM metrics. Within the entry for each individual metric, you can optionally specify one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit for the metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. • kafka – Optional. Specifies that you want to retrieve Apache Kafka broker metrics from the instance. For more information, see Collect Kafka metrics. This section can include the following fields: • measurement – Specifies the array of Kafka broker metrics to be collected. For a list of the possible values to use here, see the Metric column in the first table in Collect Kafka metrics. Within the entry for each individual metric, you can optionally specify one or both
acw-ug-760
acw-ug.pdf
760
The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. • kafka – Optional. Specifies that you want to retrieve Apache Kafka broker metrics from the instance. For more information, see Collect Kafka metrics. This section can include the following fields: • measurement – Specifies the array of Kafka broker metrics to be collected. For a list of the possible values to use here, see the Metric column in the first table in Collect Kafka metrics. Within the entry for each individual metric, you can optionally specify one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit for the metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. • kafka-consumer – Optional. Specifies that you want to retrieve Apache Kafka consumer metrics from the instance. For more information, see Collect Kafka metrics. This section can include the following fields: • measurement – Specifies the array of Kafka broker metrics to be collected. For a list of the possible values to use here, see the Metric column in the second metrics table in Collect Kafka metrics. Manually create or edit the CloudWatch agent configuration file 2627 Amazon CloudWatch User Guide Within the entry for each individual metric, you can optionally specify one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit for the metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. • kafka-producer – Optional. Specifies that you want to retrieve Apache Kafka producer metrics from the instance. For more information, see Collect Kafka metrics. This section can include the following fields: • measurement – Specifies the array of Kafka broker metrics to be collected. For a list of the possible values to use here, see the Metric column in the third metrics table in Collect Kafka metrics. Within the entry for each individual metric, you can optionally specify one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit for the metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. • tomcat – Optional. Specifies that you want to retrieve Tomcat metrics from the instance. For more information, see Collect Tomcat metrics. This section can include the following fields: • measurement – Specifies the array of Tomcat metrics to be collected. For a list of the possible values to use here, see the Metric column in the table in Collect Tomcat metrics. Within the entry for each individual metric, you can optionally specify one or both of the following: • rename – Specifies a different name for this metric. • unit – Specifies the unit to use for this metric, overriding the default unit for the metric. The unit that you specify must be a valid CloudWatch metric unit, as listed in the Unit description in MetricDatum. The jmx section can also include the optional append_dimensions field: Manually create or edit the CloudWatch agent configuration file 2628 Amazon CloudWatch User Guide • append_dimensions – Optional. Additional dimensions to use for only the process metrics. If you specify this field, it's used in addition to dimensions specified in the append_dimensions field that is used for all types of metrics collected by the agent. The following fields are for Amazon EC2 only. • endpoint – The address for the JMX client to connect to. The format is ip:port. If the endpoint is not the localhost, and password authentication and SSL must be enabled. • metrics_collection_interval – Optional. Specifies how often to collect the processes metrics, overriding the global metrics_collection_interval specified in the agent section of the configuration file. This value is specified in seconds. For example, specifying 10 causes metrics to be collected every 10 seconds, and setting it to 300 specifies metrics to be collected every 5 minutes. If you set this value below 60 seconds, each metric is collected as a high-resolution metric. For more information, see High-resolution metrics. If JMX was enabled with password authentication or SSL for remote access, you can use the following fields. • password_file – Optional. Specifies a Java properties file of keys to passwords. The file must be read-only and restricted to the user running the CloudWatch agent. If password authentication is enabled, this requires the same username and password pair as the entry in
acw-ug-761
acw-ug.pdf
761
every 10 seconds, and setting it to 300 specifies metrics to be collected every 5 minutes. If you set this value below 60 seconds, each metric is collected as a high-resolution metric. For more information, see High-resolution metrics. If JMX was enabled with password authentication or SSL for remote access, you can use the following fields. • password_file – Optional. Specifies a Java properties file of keys to passwords. The file must be read-only and restricted to the user running the CloudWatch agent. If password authentication is enabled, this requires the same username and password pair as the entry in the JMX password file provided in the com.sun.management.jmxremote.password.file property. If SSL is enabled, it requires entries for keystore and truststore and corresponds to the javax.net.ssl.keyStorePassword and javax.net.ssl.trustStorePassword respectively. • username – If password authentication is enabled, specify the username that matches the username in the provided password file. • keystore_path – If SSL is enabled, specify the full path to the Java keystore, which consists of a private key and a certificate to the public key. Corresponds to the javax.net.ssl.keyStore property. • keystore_type – If SSL is enabled, specify the type of keystore being used. Corresponds to the javax.net.ssl.keyStoreType property. Manually create or edit the CloudWatch agent configuration file 2629 Amazon CloudWatch User Guide • truststore_path – If SSL is enabled, specify the full path to the Java truststore, which must contain the remote JMX server's public certificate. Corresponds to the javax.net.ssl.trustStore property. • truststore_type – If SSL is enabled, specify the type of truststore being used. Corresponds to the javax.net.ssl.trustStoreType property. • remote_profile – Optional. Supported JMX remote profiles are TLS in combination with SASL profiles: SASL/PLAIN, SASL/DIGEST-MD5, and SASL/CRAM-MD5. Should be one of:SASL/ PLAIN, SASL/DIGEST-MD5, SASL/CRAM-MD5, TLS SASL/PLAIN, TLS SASL/DIGEST-MD5, or TLS SASL/CRAM-MD5 • realm – Optional. The realm as required by the remote profile SASL/DIGEST-MD5. • registry_ssl_enabled – If RMI registry authentication is enabled. Set to true if the JVM was configured with com.sun.management.jmxremote.registry.ssl=true. • insecure Set to true to opt out of the validation required if the agent is configured for a non- localhost endpoint. The following is an example of the jmx section of the CloudWatch agent configuration file. { "metrics": { "metrics_collected": { "jmx": [ { "endpoint": "remotehost:1314", "jvm": { "measurement": [ "jvm.memory.heap.init", "jvm.memory.nonheap.used" ] }, "kafka": { "measurement": [ "kafka.request.count", { "name": "kafka.message.count", "rename": "KAFKA_MESSAGE_COUNT", "unit": "Count" } ] }, Manually create or edit the CloudWatch agent configuration file 2630 Amazon CloudWatch User Guide "username": "cwagent", "keystore_path": "/path/to/keystore", "keystore_type": "PKCS12", "truststore_path": "/path/to/truststore", "truststore_type": "PKCS12" }, { "endpoint": "localhost:1315", "kafka-producer": { "measurement": [ "kafka.producer.request-rate" ] }, "append_dimensions": { "service.name": "kafka/1" } } ] } } } Collect JVM metrics You can use the CloudWatch agent to collect Java Virtual Machine (JVM) metrics. To set this up, add a jvm section inside the jmxsection of the CloudWatch agent configuration file. The following metrics can be collected. Metric Dimensions Description jvm.class [DEFAULT] es.loaded The total number of loaded classes. Unit: None Meaningfu l statistics: Minimum, Manually create or edit the CloudWatch agent configuration file 2631 Amazon CloudWatch User Guide Metric Dimensions Description jvm.gc.co [DEFAULT], llections name .count jvm.gc.co [DEFAULT], llections name .elapsed Maximum, Average The total number of garbage collections that have occurred. Unit: None Meaningfu l statistics: Minimum, Maximum, Average The approxima te accumulat ed garbage collection elapsed time. Unit: Milliseco nds Meaningfu l statistics: Minimum, Maximum, Average Manually create or edit the CloudWatch agent configuration file 2632 Amazon CloudWatch User Guide Metric Dimensions Description jvm.memor [DEFAULT] y.heap.in it jvm.memor [DEFAULT] y.heap.ma x The initial amount of memory that the JVM requests from the operating system for the heap. Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average The maximum amount of memory that can be used for the heap. Unit: Bytes Meaningfu l statistics: Maximum Manually create or edit the CloudWatch agent configuration file 2633 Amazon CloudWatch User Guide Metric Dimensions Description jvm.memor [DEFAULT] y.heap.us ed jvm.memor [DEFAULT] y.heap.co mmitted The current heap memory usage. Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average The amount of memory that is guaranteed to be available for the heap. Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average Manually create or edit the CloudWatch agent configuration file 2634 Amazon CloudWatch User Guide Metric Dimensions Description jvm.memor [DEFAULT] y.nonheap .init jvm.memor [DEFAULT] y.nonheap .max The initial amount of memory that the JVM requests from the operating system for non-heap purposes. Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average The maximum amount of memory that can be used for non-heap purposes. Unit: Bytes Meaningfu l statistics: Maximum Manually create or edit the CloudWatch agent configuration file 2635 Amazon CloudWatch User Guide Metric Dimensions Description jvm.memor [DEFAULT] y.nonheap .used jvm.memor [DEFAULT] y.nonheap .committe d The current non-heap memory usage. Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average The amount of memory that
acw-ug-762
acw-ug.pdf
762
CloudWatch User Guide Metric Dimensions Description jvm.memor [DEFAULT] y.nonheap .init jvm.memor [DEFAULT] y.nonheap .max The initial amount of memory that the JVM requests from the operating system for non-heap purposes. Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average The maximum amount of memory that can be used for non-heap purposes. Unit: Bytes Meaningfu l statistics: Maximum Manually create or edit the CloudWatch agent configuration file 2635 Amazon CloudWatch User Guide Metric Dimensions Description jvm.memor [DEFAULT] y.nonheap .used jvm.memor [DEFAULT] y.nonheap .committe d The current non-heap memory usage. Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average The amount of memory that is guaranteed to be available for non-heap purposes. Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average Manually create or edit the CloudWatch agent configuration file 2636 Amazon CloudWatch User Guide Metric Dimensions Description jvm.memor [DEFAULT], y.pool.in name it jvm.memor [DEFAULT], y.pool.ma name x The initial amount of memory that the JVM requests from the operating system for the memory pool. Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average The maximum amount of memory that can be used for the memory pool. Unit: Bytes Meaningfu l statistics: Maximum Manually create or edit the CloudWatch agent configuration file 2637 Amazon CloudWatch User Guide Metric Dimensions Description jvm.memor [DEFAULT], y.pool.us name ed jvm.memor [DEFAULT], y.pool.co name mmitted The current memory pool memory usage. Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average The amount of memory that is guarantee d to be available for the memory pool. Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average Manually create or edit the CloudWatch agent configuration file 2638 Amazon CloudWatch User Guide Metric Dimensions Description jvm.threa [DEFAULT] ds.count The current number of threads. Unit: None Meaningfu l statistics: Minimum, Maximum, Average The JVM metrics are collected with the following dimensions: Dimension [DEFAULT] Description On Amazon EC2 by default, the host is also published as a dimension of metrics that are collected by the CloudWatch agent, unless you are using the append_dimensions field in the metrics section. See omit_hostname in the agent section of Manually create or edit the CloudWatch agent configuration file for more information. On Amazon EKS by default, k8s related context is also published as dimension s of metrics (k8s.container.name , k8s.deployment.name , k8s.names pace.name , k8s.node.name , k8s.pod.name , and k8s.repli ). These can be filtered down caset.name using the aggregation_dimensions field. Manually create or edit the CloudWatch agent configuration file 2639 Amazon CloudWatch Dimension name Collect Kafka metrics User Guide Description For jvm.gc.collections value is the garbage collector name. metrics, the For jvm.memory.pool metrics, the value is the memory pool name. You can use the CloudWatch agent to collect Apache Kafka metrics. To set this up, add one or more of the following subsections inside the jmx section of the CloudWatch agent configuration file. • Use a kafka section to collect Kafka broker metrics. • Use a kafka-consumer section to collect Kafka consumer metrics. • Use a kafka-producer section to collect Kafka producer metrics. Kafka broker metrics The following metrics can be collected for Kafka brokers. Metric Dimensions Description kafka.mes [DEFAULT] sage.coun t The number of messages received by the Kafka broker. Unit: None Meaningfu l statistics: Minimum, Maximum, Average Manually create or edit the CloudWatch agent configuration file 2640 Amazon CloudWatch User Guide Metric Dimensions Description kafka.req [DEFAULT], uest.coun type t kafka.req [DEFAULT], uest.fail type ed The number of requests received by the Kafka broker. Unit: None Meaningfu l statistics: Minimum, Maximum, Average The number of requests to the Kafka broker that resulted in a failure. Unit: None Meaningfu l statistics: Minimum, Maximum, Average Manually create or edit the CloudWatch agent configuration file 2641 Amazon CloudWatch User Guide Metric Dimensions Description kafka.req [DEFAULT], uest.time type .total kafka.req [DEFAULT], uest.time type .50p The total time that the Kafka broker has taken to service requests. Unit: Milliseco nds Meaningfu l statistics: Minimum, Maximum, Average The 50th percentile time that the Kafka broker has taken to service requests. Unit: Milliseco nds Meaningfu l statistics: Minimum, Maximum, Average Manually create or edit the CloudWatch agent configuration file 2642 Amazon CloudWatch User Guide Metric Dimensions Description kafka.req [DEFAULT], uest.time type .99p kafka.req [DEFAULT], uest.time type .avg The 99th percentile time that the Kafka broker has taken to service requests. Unit: Milliseco nds Meaningfu l statistics: Minimum, Maximum, Average The average time that the Kafka broker has taken to service requests. Unit: Milliseco nds Meaningfu l statistics: Average Manually create or edit the CloudWatch agent configuration file 2643 Amazon CloudWatch User Guide Metric Dimensions Description kafka.net [DEFAULT], work.io state kafka.pur [DEFAULT], gatory.si type ze The number of bytes received by or sent by the Kafka broker. Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average The number of requests waiting in purgatory. Unit: None Meaningfu l statistics: Minimum, Maximum, Average Manually create or edit the CloudWatch agent configuration file
acw-ug-763
acw-ug.pdf
763
service requests. Unit: Milliseco nds Meaningfu l statistics: Minimum, Maximum, Average The average time that the Kafka broker has taken to service requests. Unit: Milliseco nds Meaningfu l statistics: Average Manually create or edit the CloudWatch agent configuration file 2643 Amazon CloudWatch User Guide Metric Dimensions Description kafka.net [DEFAULT], work.io state kafka.pur [DEFAULT], gatory.si type ze The number of bytes received by or sent by the Kafka broker. Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average The number of requests waiting in purgatory. Unit: None Meaningfu l statistics: Minimum, Maximum, Average Manually create or edit the CloudWatch agent configuration file 2644 Amazon CloudWatch User Guide Metric Dimensions Description kafka.par [DEFAULT] tition.co unt The number of partitions on the Kafka broker. Unit: None Meaningfu l statistics: Minimum, Maximum, Average kafka.par [DEFAULT] tition.of fline The number of partitions that are offline. kafka.par [DEFAULT] tition.un der_repli cated Unit: None Meaningfu l statistics: Minimum, Maximum, Average The number of under- replicated partitions. Unit: None Meaningfu l statistics: Minimum, Maximum, Average Manually create or edit the CloudWatch agent configuration file 2645 Amazon CloudWatch User Guide Metric Dimensions Description kafka.isr [DEFAULT], .operatio operation n.count kafka.max [DEFAULT] .lag The number of in-sync replica shrink and expand operations. Unit: None Meaningfu l statistics: Minimum, Maximum, Average The maximum lag in messages between follower and leader replicas. Unit: None Meaningfu l statistics: Maximum Manually create or edit the CloudWatch agent configuration file 2646 Amazon CloudWatch User Guide Metric Dimensions Description kafka.con [DEFAULT] troller.a ctive.cou nt kafka.lea [DEFAULT] der.elect ion.rate The number of active controllers on the broker. Unit: None Meaningfu l statistics: Minimum, Maximum, Average Leader election rate. If this increases , it indicates broker failures. Unit: None Meaningfu l statistics: Minimum, Maximum, Average Manually create or edit the CloudWatch agent configuration file 2647 Amazon CloudWatch User Guide Metric Dimensions Description kafka.unc [DEFAULT] lean.elec tion.rate kafka.req [DEFAULT] uest.queu e kafka.log [DEFAULT] s.flush.t ime.count Unclean leader election rate. If this increases , it indicates broker failures. Unit: None Meaningfu l statistics: Minimum, Maximum, Average The size of the request queue. Unit: None Meaningfu l statistics: Minimum, Maximum, Average The logs flush count. Unit: Milliseco nds Meaningfu l statistics: Minimum, Maximum, Average Manually create or edit the CloudWatch agent configuration file 2648 Amazon CloudWatch User Guide Metric Dimensions Description kafka.log [DEFAULT] s.flush.t ime.media n kafka.log [DEFAULT] s.flush.t ime.99p The 50th percentile value of the logs flush count. Unit: Milliseco nds Meaningfu l statistics: Minimum, Maximum, Average The 99th percentile value of the logs flush count. Unit: Milliseco nds Meaningfu l statistics: Minimum, Maximum, Average The Kafka broker metrics are collected with the following dimensions: Dimension [DEFAULT] Description On Amazon EC2 by default, the host is also published as a dimension of metrics that are Manually create or edit the CloudWatch agent configuration file 2649 Amazon CloudWatch Dimension type state operation User Guide Description collected by the CloudWatch agent, unless you are using the append_dimensions field in the metrics section. See omit_hostname in the agent section of Manually create or edit the CloudWatch agent configuration file for more information. On Amazon EKS by default, k8s related context is also published as dimension s of metrics (k8s.container.name , k8s.deployment.name , k8s.names pace.name , k8s.node.name , k8s.pod.name , and k8s.repli ). These can be filtered down caset.name using the aggregation_dimensions field. The request type. Possible values are produce, fetch, fetchconsumer , and fetchfollower . The direction of network traffic. Possible values are in and out. The operation type for the in-sync replica. Possible values are shrink and expand. Kafka consumer metrics The following metrics can be collected for Kafka consumers. Metric Dimensions Description kafka.con [DEFAULT], sumer.fet client-id The number of fetch requests ch-rate Manually create or edit the CloudWatch agent configuration file 2650 Amazon CloudWatch User Guide Metric Dimensions Description for all topics per second. Unit: None Meaningfu l statistics: Minimum, Maximum, Average The number of messages that the consumer lags behind the producer. Unit: None Meaningfu l statistics: Minimum, Maximum, Average The average number of bytes consumed for all topics per second. Unit: Bytes Meaningfu l statistics: Average kafka.con [DEFAULT], sumer.rec client-id ords-lag- max kafka.con [DEFAULT], sumer.tot client-id al.bytes- consumed- rate Manually create or edit the CloudWatch agent configuration file 2651 Amazon CloudWatch User Guide Metric Dimensions Description kafka.con [DEFAULT], sumer.tot client-id al.fetch- size-avg The number of bytes fetched per request for all topics. kafka.con [DEFAULT], sumer.tot client-id al.record s-consume d-rate kafka.con [DEFAULT], sumer.byt client-id , es-consum topic ed-rate Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average The average number of records consumed for all topics per second. Unit: None Meaningfu l statistics: Average The average number of bytes consumed per second. Unit: Bytes Meaningfu l statistics: Average Manually create or edit the CloudWatch agent configuration file 2652 Amazon CloudWatch User Guide Metric Dimensions Description kafka.con [DEFAULT], sumer.fet client-id , ch-size-a topic The
acw-ug-764
acw-ug.pdf
764
User Guide Metric Dimensions Description kafka.con [DEFAULT], sumer.tot client-id al.fetch- size-avg The number of bytes fetched per request for all topics. kafka.con [DEFAULT], sumer.tot client-id al.record s-consume d-rate kafka.con [DEFAULT], sumer.byt client-id , es-consum topic ed-rate Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average The average number of records consumed for all topics per second. Unit: None Meaningfu l statistics: Average The average number of bytes consumed per second. Unit: Bytes Meaningfu l statistics: Average Manually create or edit the CloudWatch agent configuration file 2652 Amazon CloudWatch User Guide Metric Dimensions Description kafka.con [DEFAULT], sumer.fet client-id , ch-size-a topic The number of bytes fetched per request. vg kafka.con [DEFAULT], sumer.rec client-id , ords-cons topic umed-rate Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average The average number of records consumed per second. Unit: None Meaningfu l statistics: Average The Kafka consumer metrics are collected with the following dimensions: Dimension [DEFAULT] Description On Amazon EC2 by default, the host is also published as a dimension of metrics that are collected by the CloudWatch agent, unless you are using the append_dimensions field in the metrics section. See omit_hostname in the agent section of Manually create or edit the CloudWatch agent configuration file for more information. Manually create or edit the CloudWatch agent configuration file 2653 Amazon CloudWatch Dimension client-id topic Kafka producer metrics User Guide Description On Amazon EKS by default, k8s related context is also published as dimension s of metrics (k8s.container.name , k8s.deployment.name , k8s.names pace.name , k8s.node.name , k8s.pod.name , and k8s.repli ). These can be filtered down caset.name using the aggregation_dimensions field. The ID of the client. The Kafka topic. The following metrics can be collected for Kafka producers. Metric Dimensions Description kafka.pro [DEFAULT], ducer.io- client-id wait-time -ns-avg The average length of time the I/O thread spent waiting for a socket ready for reads or writes. Unit: None Meaningfu l statistics: Average kafka.pro [DEFAULT], ducer.out client-id The average number of Manually create or edit the CloudWatch agent configuration file 2654 Amazon CloudWatch User Guide Metric Dimensions Description going-byt e-rate kafka.pro [DEFAULT], ducer.req client-id uest-late ncy-avg kafka.pro [DEFAULT], ducer.req client-id uest-rate outgoing bytes sent per second to all servers. Unit: Bytes Meaningfu l statistics: Average The average request latency. Unit: Milliseco nds Meaningfu l statistics: Average The average number of requests sent per second. Unit: None Meaningfu l statistics: Average Manually create or edit the CloudWatch agent configuration file 2655 Amazon CloudWatch User Guide Metric Dimensions Description kafka.pro [DEFAULT], ducer.res client-id ponse-rat e kafka.pro [DEFAULT], ducer.byt client-id , e-rate topic kafka.pro [DEFAULT], ducer.com client-id , pression- topic rate The number of responses received per second. Unit: None Meaningfu l statistics: Minimum, Maximum, Average The average number of bytes sent per second for a topic. Unit: Bytes Meaningfu l statistics: Average The average compression rate of record batches for a topic. Unit: None Meaningfu l statistics: Average Manually create or edit the CloudWatch agent configuration file 2656 Amazon CloudWatch User Guide Metric Dimensions Description kafka.pro [DEFAULT], ducer.rec client-id , ord-error topic -rate kafka.pro [DEFAULT], ducer.rec client-id , ord-retry topic -rate The average per-second number of record sends that resulted in errors for a topic. Unit: None Meaningfu l statistics: Average The average per-second number of retried record sends for a topic. Unit: None Meaningfu l statistics: Average Manually create or edit the CloudWatch agent configuration file 2657 Amazon CloudWatch User Guide Metric Dimensions Description kafka.pro [DEFAULT], ducer.rec client-id , ord-send- topic rate The average number of records sent per second for a topic. Unit: None Meaningfu l statistics: Average Kafka producer metrics are collected with the following dimensions: Dimension [DEFAULT] Description On Amazon EC2 by default, the host is also published as a dimension of metrics that are collected by the CloudWatch agent, unless you are using the append_dimensions field in the metrics section. See omit_hostname in the agent section of Manually create or edit the CloudWatch agent configuration file for more information. On Amazon EKS by default, k8s related context is also published as dimension s of metrics (k8s.container.name , k8s.deployment.name , k8s.names pace.name , k8s.node.name , k8s.pod.name , and k8s.repli ). These can be filtered down caset.name using the aggregation_dimensions field. Manually create or edit the CloudWatch agent configuration file 2658 Amazon CloudWatch Dimension client-id topic Collect Tomcat metrics User Guide Description The ID of the client. The Kafka topic. You can use the CloudWatch agent to collect Apache Tomcat metrics. To set this up, add a tomcat section inside the metrics_collected section of the CloudWatch agent configuration file. The following metrics can be collected. Metric Dimensions Description tomcat.se [DEFAULT] ssions The number of active sessions. tomcat.er [DEFAULT], rors proto_han dler Unit: None Meaningfu l statistics: Minimum, Maximum, Average The number of errors encountered. Unit: None Meaningfu l statistics: Minimum, Maximum, Average Manually create or edit the CloudWatch agent
acw-ug-765
acw-ug.pdf
765
file 2658 Amazon CloudWatch Dimension client-id topic Collect Tomcat metrics User Guide Description The ID of the client. The Kafka topic. You can use the CloudWatch agent to collect Apache Tomcat metrics. To set this up, add a tomcat section inside the metrics_collected section of the CloudWatch agent configuration file. The following metrics can be collected. Metric Dimensions Description tomcat.se [DEFAULT] ssions The number of active sessions. tomcat.er [DEFAULT], rors proto_han dler Unit: None Meaningfu l statistics: Minimum, Maximum, Average The number of errors encountered. Unit: None Meaningfu l statistics: Minimum, Maximum, Average Manually create or edit the CloudWatch agent configuration file 2659 Amazon CloudWatch User Guide Metric Dimensions Description tomcat.pr [DEFAULT], ocessing_ proto_han time dler The total processing time. Unit: Milliseco nds Meaningfu l statistics: Minimum, Maximum, Average tomcat.tr [DEFAULT], affic proto_han dler The number of bytes received and sent. Unit: Bytes Meaningfu l statistics: Minimum, Maximum, Average tomcat.th [DEFAULT], reads proto_han The number of threads. dler Unit: None Meaningfu l statistics: Minimum, Maximum, Average Manually create or edit the CloudWatch agent configuration file 2660 Amazon CloudWatch User Guide Metric Dimensions Description tomcat.ma [DEFAULT], x_time proto_han dler , direction Maximum time to process a request. Unit: Milliseco nds Meaningfu l statistics: Maximum tomcat.re [DEFAULT], quest_cou proto_han The total requests. nt dler Unit: None Meaningfu l statistics: Minimum, Maximum, Average Tomcat metrics are collected with the following dimensions: Dimension [DEFAULT] Description On Amazon EC2 by default, the host is also published as a dimension of metrics that are collected by the CloudWatch agent, unless you are using the append_dimensions field in the metrics section. See omit_hostname in the agent section of Manually create or edit the CloudWatch agent configuration file for more information. Manually create or edit the CloudWatch agent configuration file 2661 Amazon CloudWatch Dimension proto_handler direction User Guide Description On Amazon EKS by default, k8s related context is also published as dimension s of metrics (k8s.container.name , k8s.deployment.name , k8s.names pace.name , k8s.node.name , k8s.pod.name , and k8s.repli ). These can be filtered down caset.name using the aggregation_dimensions field. The proto_handler is an identifier for a connector, which is provided in the <protocol>-<type>-<port> format (for example, http-nio-8080 ). The traffic direction. Possible values are received and sent. Collect metrics and traces with OpenTelemetry You can collect metrics and traces from your applications or services using the CloudWatch agent with the OpenTelemetry Protocol (OTLP), which is a popular open source solution. You can use any OpenTelemetry SDK to send metrics and traces to the CloudWatch agent. For more information about the available OpenTelemetry SDKs, see OpenTelemetry Supported Language APIs & SDKs.. To collect OpenTelemetry metrics and traces, add an otlp section to the CloudWatch agent configuration file. The section has the following fields: • grpc_endpoint – Optional. Specifies the address for the CloudWatch agent to use to listen for OpenTelemetry metrics or traces sent using gRPC Remote Procedure Calls. The format is ip:port. This address must match the address set for the gRPC exporter in the OpenTelemetry SDK. If you omit this field, the default of 127.0.0.1:4317 is used. • http_endpoint – Optional. Specifies the address for the CloudWatch agent to use to listen for OpenTelemetry metrics or traces sent over HTTP. The format is ip:port. This address must Manually create or edit the CloudWatch agent configuration file 2662 Amazon CloudWatch User Guide match the address set for the HTTP exporter in the OpenTelemetry SDK. If you omit this field, the default of 127.0.0.1:4318 is used. • tls – Optional. Specifies that the server should be configured with TLS. • cert_file – Path to the TLS certificate to use for TLS required connections. • key_file – Path to the TLS key to use for TLS required connections. The otlp section can be placed in multiple sections within the CloudWatch agent configuration file depending on how and where you want to send the metrics and traces. Each otlp section requires a unique endpoint. For detailed information about splitting the metrics and traces endpoints, see OTLP Exporter Configuration in the OpenTelemetry SDK documentation. To send metrics to CloudWatch or Amazon Managed Service for Prometheus, add the otlp section under metrics_collected within the metrics section. For more information about sending metrics to different destinations, see Manually create or edit the CloudWatch agent configuration file. The following example shows a configuration that sends metrics to CloudWatch: { "metrics": { "metrics_collected": { "otlp": { "grpc_endpoint": "127.0.0.1:4317", "http_endpoint": "127.0.0.1:4318" } } } } To send metrics to Amazon CloudWatch Logs using the Embedded metric format (EMF), add the otlp section under metrics_collected within the logs section. This sends the EMF logs by default to the /aws/cwagent log group and a generated log stream. The metrics are extracted into the CWAgent namespace by default. The following example shows a configuration that sends metrics as EMF logs
acw-ug-766
acw-ug.pdf
766
different destinations, see Manually create or edit the CloudWatch agent configuration file. The following example shows a configuration that sends metrics to CloudWatch: { "metrics": { "metrics_collected": { "otlp": { "grpc_endpoint": "127.0.0.1:4317", "http_endpoint": "127.0.0.1:4318" } } } } To send metrics to Amazon CloudWatch Logs using the Embedded metric format (EMF), add the otlp section under metrics_collected within the logs section. This sends the EMF logs by default to the /aws/cwagent log group and a generated log stream. The metrics are extracted into the CWAgent namespace by default. The following example shows a configuration that sends metrics as EMF logs to CloudWatch Logs: { "logs": { "metrics_collected": { "otlp": { Manually create or edit the CloudWatch agent configuration file 2663 Amazon CloudWatch User Guide "grpc_endpoint": "127.0.0.1:4317", "http_endpoint": "127.0.0.1:4318" } } } } To send traces to AWS X-Ray, add the otlp section under traces_collected within the traces section. The following example shows a configuration that sends traces to X-Ray: { "traces": { "traces_collected": { "otlp": { "grpc_endpoint": "127.0.0.1:4317", "http_endpoint": "127.0.0.1:4318" } } } } Collect process metrics with the procstat plugin The procstat plugin enables you to collect metrics from individual processes. The plugin is supported on Linux servers and on servers running supported version of Windows Server. This section describes how to configure the CloudWatch agent for procstat and view metrics the CloudWatch agent imports. It also lists the metrics that procstat collects. Note The procstat plugin is not supported for the Fargate launch type in Amazon ECS environments. Topics • Configure the CloudWatch agent for procstat • Metrics collected by procstat Manually create or edit the CloudWatch agent configuration file 2664 Amazon CloudWatch User Guide • Viewing process metrics imported by the CloudWatch agent Configure the CloudWatch agent for procstat To use the procstat plugin, add a procstat section in the metrics_collected section of the CloudWatch agent configuration file. There are three ways to specify the processes to monitor. You can use only one of these methods, but you can use that method to specify one or more processes to monitor. • pid_file: Selects processes by the names of the process identification number (PID) files they create. • exe: Selects the processes that have process names that match the string that you specify, using regular expression matching rules. The match is a "contains" match, meaning that if you specify agent as the term to match, processes with names like cloudwatchagent match the term. For more information, see Syntax. • pattern: Selects processes by the command lines used to start the processes. All processes are selected that have command lines matching the specified string using regular expression matching rules. The entire command line is checked, including parameters and options used with the command. The match is a "contains" match, meaning that if you specify -c as the term to match, processes with parameters like -config match the term. The CloudWatch agent uses only one of these methods, even if you include more than one of the above sections. If you specify more than one section, the CloudWatch agent uses the pid_file section if it is present. If not, it uses the exe section. On Linux servers, the strings that you specify in an exe or pattern section are evaluated as regular expressions. On servers running Windows Server, these strings are evaluated as WMI queries. An example would be pattern: "%apache%". For more information, see LIKE Operator. Whichever method you use, you can include an optional metrics_collection_interval parameter, which specifies how often in seconds to collect those metrics. If you omit this parameter, the default value of 60 seconds is used. In the examples in the following sections, the procstat section is the only section included in the metrics_collected section of the agent configuration file. Actual configuration files can also Manually create or edit the CloudWatch agent configuration file 2665 Amazon CloudWatch User Guide include other sections in metrics_collected. For more information, see Manually create or edit the CloudWatch agent configuration file. Configure with pid_file The following example procstat section monitors the processes that create the PID files example1.pid and example2.pid. Different metrics are collected from each process. Metrics collected from the process that creates example2.pid are collected every 10 seconds, and the metrics collected from the example1.pid process are collected every 60 seconds, the default value. { "metrics": { "metrics_collected": { "procstat": [ { "pid_file": "/var/run/example1.pid", "measurement": [ "cpu_usage", "memory_rss" ] }, { "pid_file": "/var/run/example2.pid", "measurement": [ "read_bytes", "read_count", "write_bytes" ], "metrics_collection_interval": 10 } ] } } } Configuring with exe The following example procstat section monitors all processes with names that match the strings agent or plugin. The same metrics are collected from each process. { Manually create or edit the CloudWatch agent configuration file 2666 Amazon CloudWatch User Guide "metrics": { "metrics_collected": { "procstat": [ { "exe":
acw-ug-767
acw-ug.pdf
767
seconds, and the metrics collected from the example1.pid process are collected every 60 seconds, the default value. { "metrics": { "metrics_collected": { "procstat": [ { "pid_file": "/var/run/example1.pid", "measurement": [ "cpu_usage", "memory_rss" ] }, { "pid_file": "/var/run/example2.pid", "measurement": [ "read_bytes", "read_count", "write_bytes" ], "metrics_collection_interval": 10 } ] } } } Configuring with exe The following example procstat section monitors all processes with names that match the strings agent or plugin. The same metrics are collected from each process. { Manually create or edit the CloudWatch agent configuration file 2666 Amazon CloudWatch User Guide "metrics": { "metrics_collected": { "procstat": [ { "exe": "agent", "measurement": [ "cpu_time", "cpu_time_system", "cpu_time_user" ] }, { "exe": "plugin", "measurement": [ "cpu_time", "cpu_time_system", "cpu_time_user" ] } ] } } } Configuring with pattern The following example procstat section monitors all processes with command lines that match the strings config or -c. The same metrics are collected from each process. { "metrics": { "metrics_collected": { "procstat": [ { "pattern": "config", "measurement": [ "rlimit_memory_data_hard", "rlimit_memory_data_soft", "rlimit_memory_stack_hard", "rlimit_memory_stack_soft" ] }, { Manually create or edit the CloudWatch agent configuration file 2667 Amazon CloudWatch User Guide "pattern": "-c", "measurement": [ "rlimit_memory_data_hard", "rlimit_memory_data_soft", "rlimit_memory_stack_hard", "rlimit_memory_stack_soft" ] } ] } } } Metrics collected by procstat The following table lists the metrics that you can collect with the procstat plugin. The CloudWatch agent adds procstat to the beginning of the following metric names. There is a different syntax depending on whether it was collected from a Linux server or a server running Windows Server. For example, the cpu_time metric appears as procstat_cpu_time when collected from Linux and as procstat cpu_time when collected from Windows Server. Metric name cpu_time Available on Linux cpu_time_guest Linux Description The amount of time that the process uses the CPU. This metric is measured in hundredths of a second. Unit: Count The amount of time that the process is in guest mode. This metric is Manually create or edit the CloudWatch agent configuration file 2668 Amazon CloudWatch User Guide Metric name Available on cpu_time_guest_nice Linux cpu_time_idle Linux Description measured in hundredths of a second. Type: Float Unit: None The amount of time that the process is running in a nice guest. This metric is measured in hundredths of a second. Type: Float Unit: None The amount of time that the process is in idle mode. This metric is measured in hundredths of a second. Type: Float Unit: None Manually create or edit the CloudWatch agent configuration file 2669 Amazon CloudWatch User Guide Metric name Available on cpu_time_iowait Linux cpu_time_irq Linux Description The amount of time that the process is waiting for I/ O operations to complete. This metric is measured in hundredths of a second. Type: Float Unit: None The amount of time that the process is servicing interrupts. This metric is measured in hundredths of a second. Type: Float Unit: None Manually create or edit the CloudWatch agent configuration file 2670 Amazon CloudWatch User Guide Metric name Available on cpu_time_nice Linux cpu_time_soft_irq Linux Description The amount of time that the process is in nice mode. This metric is measured in hundredths of a second. Type: Float Unit: None The amount of time that the process is servicing software interrupts. This metric is measured in hundredths of a second. Type: Float Unit: None Manually create or edit the CloudWatch agent configuration file 2671 Amazon CloudWatch User Guide Metric name Available on cpu_time_steal Linux cpu_time_stolen Linux, Windows Server Description The amount of time spent running in other operating systems when running in a virtualized environment. This metric is measured in hundredths of a second. Type: Float Unit: None The amount of time that the process is in stolen time, which is time spent in other operating systems in a virtualized environment. This metric is measured in hundredths of a second. Type: Float Unit: None Manually create or edit the CloudWatch agent configuration file 2672 Amazon CloudWatch User Guide Metric name Available on cpu_time_system Linux, Windows Server, macOS cpu_time_user Linux, Windows Server, macOS cpu_usage Linux, Windows Server, macOS Description The amount of time that the process is in system mode. This metric is measured in hundredths of a second. Type: Float Unit: Count The amount of time that the process is in user mode. This metric is measured in hundredths of a second. Unit: Count The percentag e of time that the process is active in any capacity. Unit: Percent Manually create or edit the CloudWatch agent configuration file 2673 Amazon CloudWatch Metric name memory_data Available on Linux, macOS memory_locked Linux, macOS memory_rss Linux, Windows Server, macOS memory_stack Linux, macOS User Guide Description The amount of memory that the process uses for data. Unit: Bytes The amount of memory that the process has locked. Unit: Bytes The amount of real memory (resident set) that the process is using. Unit: Bytes The amount
acw-ug-768
acw-ug.pdf
768
user mode. This metric is measured in hundredths of a second. Unit: Count The percentag e of time that the process is active in any capacity. Unit: Percent Manually create or edit the CloudWatch agent configuration file 2673 Amazon CloudWatch Metric name memory_data Available on Linux, macOS memory_locked Linux, macOS memory_rss Linux, Windows Server, macOS memory_stack Linux, macOS User Guide Description The amount of memory that the process uses for data. Unit: Bytes The amount of memory that the process has locked. Unit: Bytes The amount of real memory (resident set) that the process is using. Unit: Bytes The amount of stack memory that the process is using. Unit: Bytes Manually create or edit the CloudWatch agent configuration file 2674 Amazon CloudWatch Metric name memory_swap Available on Linux, macOS memory_vms Linux, Windows Server, macOS num_fds Linux num_threads Linux, Windows, macOS pid Linux, Windows Server, macOS User Guide Description The amount of swap memory that the process is using. Unit: Bytes The amount of virtual memory that the process is using. Unit: Bytes The number of file descripto rs that this process has open. Unit: None The number of threads in this process. Unit: None Process identifier (ID). Unit: None Manually create or edit the CloudWatch agent configuration file 2675 Amazon CloudWatch Metric name pid_count Available on Linux, Windows Server. macOS read_bytes Linux, Windows Server User Guide Description The number of process IDs associate d with the process. On Linux servers and macOS computers the full name of this metric is procstat_ lookup_pi d_count and on Windows Server it is procstat_ lookup pid_count . Unit: None The number of bytes that the process has read from disks. Unit: Bytes Manually create or edit the CloudWatch agent configuration file 2676 Amazon CloudWatch User Guide Metric name Available on write_bytes Linux, Windows Server read_count Linux, Windows Server rlimit_realtime_pr Linux iority_hard rlimit_realtime_pr Linux iority_soft Description The number of bytes that the process has written to disks. Unit: Bytes The number of disk read operation s that the process has executed. Unit: None The hard limit on the real- time priority that can be set for this process. Unit: None The soft limit on the real- time priority that can be set for this process. Unit: None Manually create or edit the CloudWatch agent configuration file 2677 Amazon CloudWatch User Guide Metric name Available on rlimit_signals_pen Linux ding_hard rlimit_signals_pen Linux ding_soft rlimit_nice_priori Linux ty_hard Description The hard limit on maximum number of signals that can be queued by this process. Unit: None The soft limit on maximum number of signals that can be queued by this process. Unit: None The hard limit on the maximum nice priority that can be set by this process. Unit: None Manually create or edit the CloudWatch agent configuration file 2678 Amazon CloudWatch Metric name Available on rlimit_nice_priori Linux ty_soft rlimit_num_fds_hard Linux rlimit_num_fds_soft Linux User Guide Description The soft limit on the maximum nice priority that can be set by this process. Unit: None The hard limit on the maximum number of file descripto rs that this process can have open. Unit: None The soft limit on the maximum number of file descripto rs that this process can have open. Unit: None Manually create or edit the CloudWatch agent configuration file 2679 Amazon CloudWatch User Guide Metric name Available on write_count Linux, Windows Server involuntary_contex Linux t_switches voluntary_context_ Linux switches realtime_priority Linux Description The number of disk write operation s that the process has executed. Unit: None The number of times that the process was involunta rily context-s witched. Unit: None The number of times that the process was context- switched voluntarily. Unit: None The current usage of real-time priority for the process. Unit: None Manually create or edit the CloudWatch agent configuration file 2680 Amazon CloudWatch User Guide Metric name Available on nice_priority Linux signals_pending Linux rlimit_cpu_time_hard Linux rlimit_cpu_time_soft Linux rlimit_file_locks_hard Linux Description The current usage of nice priority for the process. Unit: None The number of signals pending to be handled by the process. Unit: None The hard CPU time resource limit for the process. Unit: None The soft CPU time resource limit for the process. Unit: None The hard file locks resource limit for the process. Unit: None Manually create or edit the CloudWatch agent configuration file 2681 Amazon CloudWatch User Guide Metric name Available on rlimit_file_locks_soft Linux rlimit_memory_data_hard Linux rlimit_memory_data_soft Linux rlimit_memory_lock Linux ed_hard Description The soft file locks resource limit for the process. Unit: None The hard resource limit on the process for memory used for data. Unit: Bytes The soft resource limit on the process for memory used for data. Unit: Bytes The hard resource limit on the process for locked memory. Unit: Bytes Manually create or edit the CloudWatch agent configuration file 2682 Amazon CloudWatch User Guide Metric name Available on rlimit_memory_lock Linux
acw-ug-769
acw-ug.pdf
769
None Manually create or edit the CloudWatch agent configuration file 2681 Amazon CloudWatch User Guide Metric name Available on rlimit_file_locks_soft Linux rlimit_memory_data_hard Linux rlimit_memory_data_soft Linux rlimit_memory_lock Linux ed_hard Description The soft file locks resource limit for the process. Unit: None The hard resource limit on the process for memory used for data. Unit: Bytes The soft resource limit on the process for memory used for data. Unit: Bytes The hard resource limit on the process for locked memory. Unit: Bytes Manually create or edit the CloudWatch agent configuration file 2682 Amazon CloudWatch User Guide Metric name Available on rlimit_memory_lock Linux ed_soft rlimit_memory_rss_hard Linux rlimit_memory_rss_soft Linux rlimit_memory_stac Linux k_hard rlimit_memory_stac Linux k_soft Description The soft resource limit on the process for locked memory. Unit: Bytes The hard resource limit on the process for physical memory. Unit: Bytes The soft resource limit on the process for physical memory. Unit: Bytes The hard resource limit on the process stack. Unit: Bytes The soft resource limit on the process stack. Unit: Bytes Manually create or edit the CloudWatch agent configuration file 2683 Amazon CloudWatch User Guide Metric name Available on rlimit_memory_vms_hard Linux rlimit_memory_vms_soft Linux Description The hard resource limit on the process for virtual memory. Unit: Bytes The soft resource limit on the process for virtual memory. Unit: Bytes Viewing process metrics imported by the CloudWatch agent After importing process metrics into CloudWatch, you can view these metrics as time series graphs, and create alarms that can watch these metrics and notify you if they breach a threshold that you specify. The following procedure shows how to view process metrics as a time series graph. For more information about setting alarms, see Using Amazon CloudWatch alarms. To view process metrics in the CloudWatch console 1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 2. In the navigation pane, choose Metrics. 3. Choose the namespace for the metrics collected by the agent. By default, this is CWAgent, but you may have specified a different namespace in the CloudWatch agent configuration file. 4. Choose a metric dimension (for example, Per-Instance Metrics). 5. The All metrics tab displays all metrics for that dimension in the namespace. You can do the following: a. To graph a metric, select the check box next to the metric. To select all metrics, select the check box in the heading row of the table. Manually create or edit the CloudWatch agent configuration file 2684 Amazon CloudWatch User Guide b. c. d. To sort the table, use the column heading. To filter by resource, choose the resource ID and then choose Add to search. To filter by metric, choose the metric name and then choose Add to search. 6. (Optional) To add this graph to a CloudWatch dashboard, choose Actions, Add to dashboard. Retrieve custom metrics with StatsD You can retrieve additional custom metrics from your applications or services using the CloudWatch agent with the StatsD protocol. StatsD is a popular open-source solution that can gather metrics from a wide variety of applications. StatsD is especially useful for instrumenting your own metrics. For an example of using the CloudWatch agent and StatsD together, see How to better monitor your custom application metrics using Amazon CloudWatch Agent. StatsD is supported on both Linux servers and servers running Windows Server. CloudWatch supports the following StatsD format: MetricName:value|type|@sample_rate|#tag1: value,tag1... • MetricName – A string with no colons, bars, # characters, or @ characters. • value – This can be either integer or float. • type – Specify c for counter, g for gauge, ms for timer, h for histogram, or s for set. • sample_rate – (Optional) A float between 0 and 1, inclusive. Use only for counter, histogram, and timer metrics. The default value is 1 (sampling 100% of the time). • tags – (Optional) A comma-separated list of tags. StatsD tags are similar to dimensions in CloudWatch. Use colons for key/value tags, such as env:prod. You can use any StatsD client that follows this format to send the metrics to the CloudWatch agent. For more information about some of the available StatsD clients, see the StatsD client page on GitHub. To collect these custom metrics, add a "statsd": {} line to the metrics_collected section of the agent configuration file. You can add this line manually. If you use the wizard to create the configuration file, it's done for you. For more information, see Create the CloudWatch agent configuration file. Manually create or edit the CloudWatch agent configuration file 2685 Amazon CloudWatch User Guide The StatsD default configuration works for most users. There are optional fields that you can add to the statsd section of the agent configuration file as needed: • service_address – The service address to which the CloudWatch agent should listen. The format is ip:port. If you omit the IP address, the agent listens
acw-ug-770
acw-ug.pdf
770
agent configuration file. You can add this line manually. If you use the wizard to create the configuration file, it's done for you. For more information, see Create the CloudWatch agent configuration file. Manually create or edit the CloudWatch agent configuration file 2685 Amazon CloudWatch User Guide The StatsD default configuration works for most users. There are optional fields that you can add to the statsd section of the agent configuration file as needed: • service_address – The service address to which the CloudWatch agent should listen. The format is ip:port. If you omit the IP address, the agent listens on all available interfaces. Only the UDP format is supported, so you don't need to specify a UDP prefix. The default value is :8125. • metrics_collection_interval – How often in seconds that the StatsD plugin runs and collects metrics. The default value is 10 seconds. The range is 1–172,000. • metrics_aggregation_interval – How often in seconds CloudWatch aggregates metrics into single data points. The default value is 60 seconds. For example, if metrics_collection_interval is 10 and metrics_aggregation_interval is 60, CloudWatch collects data every 10 seconds. After each minute, the six data readings from that minute are aggregated into a single data point, which is sent to CloudWatch. The range is 0–172,000. Setting metrics_aggregation_interval to 0 disables the aggregation of StatsD metrics. • allowed_pending_messages – The number of UDP messages that are allowed to queue up. When the queue is full, the StatsD server starts dropping packets. The default value is 10000. • drop_original_metrics – Optional. If you are using the aggregation_dimensions field in the metrics section to roll up metrics into aggregated results, then by default the agent sends both the aggregated metrics and the original metrics that are separated for each value of the dimension. If you don't want the original metrics to be sent to CloudWatch, you can specify this parameter with a list of metrics. The metrics specified along with this parameter don't have their metrics by dimension reported to CloudWatch. Instead, only the aggregated metrics are reported. This reduces the number of metrics that the agent collects, reducing your costs. The following is an example of the statsd section of the agent configuration file, using the default port and custom collection and aggregation intervals. { "metrics":{ "metrics_collected":{ "statsd":{ Manually create or edit the CloudWatch agent configuration file 2686 Amazon CloudWatch User Guide "service_address":":8125", "metrics_collection_interval":60, "metrics_aggregation_interval":300 } } } } Viewing StatsD metrics imported by the CloudWatch agent After importing StatsD metrics into CloudWatch, you can view these metrics as time series graphs, and create alarms that can watch these metrics and notify you if they breach a threshold that you specify. The following procedure shows how to view StatsD metrics as a time series graph. For more information about setting alarms, see Using Amazon CloudWatch alarms. To view StatsD metrics in the CloudWatch console 1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/. 2. In the navigation pane, choose Metrics. 3. Choose the namespace for the metrics collected by the agent. By default, this is CWAgent, but you may have specified a different namespace in the CloudWatch agent configuration file. 4. Choose a metric dimension (for example, Per-Instance Metrics). 5. The All metrics tab displays all metrics for that dimension in the namespace. You can do the following: a. To graph a metric, select the check box next to the metric. To select all metrics, select the check box in the heading row of the table. To sort the table, use the column heading. To filter by resource, choose the resource ID and then choose Add to search. To filter by metric, choose the metric name and then choose Add to search. b. c. d. 6. (Optional) To add this graph to a CloudWatch dashboard, choose Actions, Add to dashboard. Retrieve custom metrics with collectd You can retrieve additional metrics from your applications or services using the CloudWatch agent with the collectd protocol, which is supported only on Linux servers. collectd is a popular open- source solution with plugins that can gather system statistics for a wide variety of applications. By Manually create or edit the CloudWatch agent configuration file 2687 Amazon CloudWatch User Guide combining the system metrics that the CloudWatch agent can already collect with the additional metrics from collectd, you can better monitor, analyze, and troubleshoot your systems and applications. For more information about collectd, see collectd - The system statistics collection daemon. You use the collectd software to send the metrics to the CloudWatch agent. For the collectd metrics, the CloudWatch agent acts as the server while the collectd plugin acts as the client. The collectd software is not installed automatically on every server. On a server running Amazon Linux 2, follow these steps to install collectd sudo amazon-linux-extras install collectd For information about