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 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 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.
-
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.
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.
Note
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 |
---|---|---|---|
|
Defines the hosted-in platform. |
AWS::EKS, AWS::ECS, AWS::EC2, AWS::Lambda, K8s, Generic |
|
|
Name of the Amazon EKS cluster. |
Alphanumeric string with basic delimiters. |
|
|
Name of the self-hosted Kubernetes cluster. |
Alphanumeric string with basic delimiters. |
|
|
Name of Kubernetes namespace in Amazon EKS or K8s clusters. |
Alphanumeric string with basic delimiters. |
|
|
Name of Kubernetes workload in Amazon EKS and K8s clusters. |
Alphanumeric string with basic delimiters. |
|
|
Identity of Kubernetes node in Amazon EKS and K8s clusters. |
K8s node name (for example, Amazon EC2 instance DNS name). |
|
|
Identity of Kubernetes pod in Amazon EKS and K8s clusters. |
K8s pod identifier. |
|
|
Name of the Amazon EC2 AutoScaling Group. |
Alphanumeric string with basic delimiters. |
|
|
Identity of the Amazon EC2 instance. |
Amazon EC2 instance identifier. |
|
|
Identity of the Amazon ECS cluster. |
Amazon ECS cluster name. |
|
|
Identity of the Amazon ECS service. |
Amazon ECS service name. |
|
|
Identity of the Amazon ECS task. |
Amazon ECS task ID. |
|
|
Identity of the Lambda function. |
Lambda function name. |
|
|
Name of the host for all platform types. |
Sub-domain format. |
|
Resource details
Keyword | Usage | Domain of Values | Examples |
---|---|---|---|
|
ARN for the AWS resource. |
Alphanumeric string with basic delimiters. |
|
Application details
Keyword | Usage | Domain of Values | Examples |
---|---|---|---|
|
Name of the application in AppRegistry. |
Alphanumeric string with basic delimiters. |
|
|
ARN of the application in AppRegistry. |
Alphanumeric string with basic delimiters. |
|
Telemetry provider details
Keyword | Usage | Domain of Values | Examples |
---|---|---|---|
|
The fingerprint of OTEL SDK version for instrumented services. |
Alphanumeric string with basic delimiters. |
|
|
The fingerprint of the Agent used to collect and send telemetry data. |
Alphanumeric string with basic delimiters. |
|
|
Specifies the point of application where the telemetry was collected or what was used for the source of telemetry data. |
ServerSpan, ClientSpan, ProducerSpan, ConsumerSpan, LocalRoot Span, JMX, OS. |
|