Skip to content

Commit

Permalink
Add a note for read me (#3167)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnWu20 authored Apr 21, 2021
1 parent e663b59 commit be47f6f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion exporter/awsemfexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
7 changes: 4 additions & 3 deletions exporter/awsemfexporter/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
23 changes: 17 additions & 6 deletions exporter/awsemfexporter/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
},
Expand All @@ -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",
},
},
},
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit be47f6f

Please sign in to comment.