diff --git a/exporter/awsemfexporter/README.md b/exporter/awsemfexporter/README.md index 51529ce25407..29c38747e788 100644 --- a/exporter/awsemfexporter/README.md +++ b/exporter/awsemfexporter/README.md @@ -15,7 +15,7 @@ The following exporter configuration parameters are supported. | Name | Description | Default | | :---------------- | :--------------------------------------------------------------------- | ------- | | `log_group_name` | Customized log group name which supports `{ClusterName}` and `{TaskId}` placeholders. One valid example is `/aws/metrics/{ClusterName}`. It will search for `ClusterName` (or `aws.ecs.cluster.name`) resource attribute in the metrics data and replace with the actual cluster name. If none of them are found in the resource attribute map, `{ClusterName}` will be replaced by `undefined`. Similar way, for the `{TaskId}`, it searches for `TaskId` (or `aws.ecs.task.id`) key in the resource attribute map. For `{NodeName}`, it searches for `NodeName` (or `k8s.node.name`) |"/metrics/default"| -| `log_stream_name` | Customized log stream name which supports `{TaskId}`, `{ClusterName}` and `{NodeName}` placeholders. One valid example is `{TaskId}`. It will search for `TaskId` (or `aws.ecs.task.id`) resource attribute in the metrics data and replace with the actual task id. If none of them are found in the resource attribute map, `{TaskId}` will be replaced by `undefined`. Similar way,, for the `{ClusterName}`, it searches for `ClusterName` (or `aws.ecs.cluster.name`). For `{NodeName}`, it searches for `NodeName` (or `k8s.node.name`). |"otel-stream"| +| `log_stream_name` | Customized log stream name which supports `{TaskId}`, `{ClusterName}`, `{NodeName}` and '{ContainerInstanceId}' placeholders. One valid example is `{TaskId}`. It will search for `TaskId` (or `aws.ecs.task.id`) resource attribute in the metrics data and replace with the actual task id. If none of them are found in the resource attribute map, `{TaskId}` will be replaced by `undefined`. Similar way,, for the `{ClusterName}`, it searches for `ClusterName` (or `aws.ecs.cluster.name`). For `{NodeName}`, it searches for `NodeName` (or `k8s.node.name`). For `{ContainerInstanceId}`, it searches for `ContainerInstanceId` (or `aws.ecs.container.instance.id`). (Note: ContainerInstanceId (or `aws.ecs.container.instance.id`) only works for AWS ECS EC2 launch type.) |"otel-stream"| | `namespace` | Customized CloudWatch metrics namespace | "default" | | `endpoint` | Optionally override the default CloudWatch service endpoint. | | | `no_verify_ssl` | Enable or disable TLS certificate verification. | false | diff --git a/exporter/awsemfexporter/util.go b/exporter/awsemfexporter/util.go index 7f947c3bc2b9..ce0f2aafcb96 100644 --- a/exporter/awsemfexporter/util.go +++ b/exporter/awsemfexporter/util.go @@ -26,9 +26,10 @@ import ( ) var patternKeyToAttributeMap = map[string]string{ - "ClusterName": "aws.ecs.cluster.name", - "TaskId": "aws.ecs.task.id", - "NodeName": "k8s.node.name", + "ClusterName": "aws.ecs.cluster.name", + "TaskId": "aws.ecs.task.id", + "NodeName": "k8s.node.name", + "ContainerInstanceId": "aws.ecs.container.instance.id", } func replacePatterns(s string, attrMap pdata.AttributeMap, logger *zap.Logger) string { diff --git a/exporter/awsemfexporter/util_test.go b/exporter/awsemfexporter/util_test.go index 4888142a2f07..50e5ec5af3b0 100644 --- a/exporter/awsemfexporter/util_test.go +++ b/exporter/awsemfexporter/util_test.go @@ -171,9 +171,10 @@ func TestGetLogInfo(t *testing.T) { }, Resource: &resourcepb.Resource{ Labels: map[string]string{ - "aws.ecs.cluster.name": "test-cluster-name", - "aws.ecs.task.id": "test-task-id", - "k8s.node.name": "ip-192-168-58-245.ec2.internal", + "aws.ecs.cluster.name": "test-cluster-name", + "aws.ecs.task.id": "test-task-id", + "k8s.node.name": "ip-192-168-58-245.ec2.internal", + "aws.ecs.container.instance.id": "203e0410260d466bab7873bb4f317b4e", }, }, }, @@ -184,9 +185,10 @@ func TestGetLogInfo(t *testing.T) { }, Resource: &resourcepb.Resource{ Labels: map[string]string{ - "ClusterName": "test-cluster-name", - "TaskId": "test-task-id", - "NodeName": "ip-192-168-58-245.ec2.internal", + "ClusterName": "test-cluster-name", + "TaskId": "test-task-id", + "NodeName": "ip-192-168-58-245.ec2.internal", + "ContainerInstanceId": "203e0410260d466bab7873bb4f317b4e", }, }, }, @@ -262,6 +264,15 @@ func TestGetLogInfo(t *testing.T) { "/aws/containerinsights/test-cluster-name/performance", "ip-192-168-58-245.ec2.internal", }, + // test case for AWS ECS EC2 container insights usage + { + "empty namespace, config w/ pattern", + "", + "/aws/containerinsights/{ClusterName}/performance", + "instanceTelemetry/{ContainerInstanceId}", + "/aws/containerinsights/test-cluster-name/performance", + "instanceTelemetry/203e0410260d466bab7873bb4f317b4e", + }, } for i := range rms {