Skip to content

Commit ac810ab

Browse files
authored
Add support for configuring EFA receiver on EC2 via JSON (#2093)
1 parent 82cf464 commit ac810ab

21 files changed

Lines changed: 474 additions & 4 deletions

translator/config/schema.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@
132132
"diskio": {
133133
"$ref": "#/definitions/metricsDefinition/definitions/diskioDefinitions"
134134
},
135+
"efa": {
136+
"$ref": "#/definitions/metricsDefinition/definitions/efaDefinitions"
137+
},
135138
"statsd": {
136139
"$ref": "#/definitions/metricsDefinition/definitions/statsdDefinitions"
137140
},
@@ -358,6 +361,28 @@
358361
}
359362
]
360363
},
364+
"efaDefinitions": {
365+
"type": "object",
366+
"properties": {
367+
"metrics_collection_interval": {
368+
"$ref": "#/definitions/timeIntervalDefinition"
369+
},
370+
"measurement": {
371+
"$ref": "#/definitions/metricsDefinition/definitions/metricsMeasurementDefinition"
372+
},
373+
"drop_original_metrics": {
374+
"type": "array",
375+
"items": {
376+
"type": "string"
377+
},
378+
"minItems": 1,
379+
"uniqueItems": true
380+
}
381+
},
382+
"required": [
383+
"measurement"
384+
]
385+
},
361386
"jmxDefinitions": {
362387
"oneOf": [
363388
{

translator/translate/otel/common/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const (
7070
Console = "console"
7171
DiskKey = "disk"
7272
DiskIOKey = "diskio"
73+
EfaKey = "efa"
7374
NetKey = "net"
7475
Emf = "emf"
7576
StructuredLog = "structuredlog"

translator/translate/otel/common/metrics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const (
1818
)
1919

2020
// Map to support dropping metrics without measurement.
21-
var toDropMap = collections.NewSet("collectd", "statsd", "ethtool")
21+
var toDropMap = collections.NewSet("collectd", "statsd", "ethtool", "efa")
2222

2323
func GetRollupDimensions(conf *confmap.Conf) [][]string {
2424
key := ConfigKey(MetricsKey, AggregationDimensionsKey)

translator/translate/otel/pipeline/host/translators.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/aws/amazon-cloudwatch-agent/receiver/adapter"
1414
"github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/common"
1515
adaptertranslator "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/receiver/adapter"
16+
"github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/receiver/awsefa"
1617
"github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/receiver/awsnvme"
1718
"github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/receiver/otlp"
1819
)
@@ -50,6 +51,10 @@ func NewTranslators(conf *confmap.Conf, configSection, os string) (common.Transl
5051
deltaReceivers.Set(awsnvme.NewTranslator())
5152
}
5253

54+
if shouldAddEfaReceiver(conf, configSection) {
55+
deltaReceivers.Set(awsefa.NewTranslator())
56+
}
57+
5358
otlpReceivers.Merge(otlp.NewTranslators(conf, common.PipelineNameHostOtlpMetrics, common.ConfigKey(configSection, common.OtlpKey)))
5459

5560
hasHostPipeline := hostReceivers.Len() != 0
@@ -112,6 +117,10 @@ func NewTranslators(conf *confmap.Conf, configSection, os string) (common.Transl
112117
return translators, nil
113118
}
114119

120+
func shouldAddEfaReceiver(conf *confmap.Conf, configSection string) bool {
121+
return conf.IsSet(common.ConfigKey(configSection, common.EfaKey))
122+
}
123+
115124
func shouldAddNvmeReceiver(conf *confmap.Conf, configSection string) bool {
116125
diskioMap := conf.Get(common.ConfigKey(configSection, common.DiskIOKey))
117126
if diskioMap == nil {

translator/translate/otel/processor/cumulativetodeltaprocessor/translator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const (
2626
var (
2727
netKey = common.ConfigKey(common.MetricsKey, common.MetricsCollectedKey, common.NetKey)
2828
diskioKey = common.ConfigKey(common.MetricsKey, common.MetricsCollectedKey, common.DiskIOKey)
29+
efaKey = common.ConfigKey(common.MetricsKey, common.MetricsCollectedKey, common.EfaKey)
2930
otlpKey = common.ConfigKey(common.MetricsKey, common.MetricsCollectedKey, common.OtlpKey)
3031
otlpEmfKey = common.ConfigKey(common.LogsKey, common.MetricsCollectedKey, common.OtlpKey)
3132

@@ -39,7 +40,7 @@ var (
3940
)
4041

4142
func WithDefaultKeys() common.TranslatorOption {
42-
return WithConfigKeys(diskioKey, netKey, otlpKey, otlpEmfKey)
43+
return WithConfigKeys(diskioKey, netKey, efaKey, otlpKey, otlpEmfKey)
4344
}
4445

4546
func WithConfigKeys(keys ...string) common.TranslatorOption {

translator/translate/otel/processor/cumulativetodeltaprocessor/translator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func TestTranslator(t *testing.T) {
3131
},
3232
},
3333
},
34-
wantErr: &common.MissingKeyError{ID: cdpTranslator.ID(), JsonKey: fmt.Sprint(diskioKey, " or ", netKey, " or ", otlpKey, " or ", otlpEmfKey)},
34+
wantErr: &common.MissingKeyError{ID: cdpTranslator.ID(), JsonKey: fmt.Sprint(diskioKey, " or ", netKey, " or ", efaKey, " or ", otlpKey, " or ", otlpEmfKey)},
3535
},
3636
"GenerateDeltaProcessorConfigWithNet": {
3737
input: map[string]any{

translator/translate/otel/receiver/adapter/translators.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ var (
6868

6969
// otelReceivers is used for receivers that need to be in the same pipeline that
7070
// exports to Cloudwatch while not having to follow the adapter rules
71-
otelReceivers = collections.NewSet[string](common.OtlpKey, common.JmxKey, common.PrometheusKey)
71+
otelReceivers = collections.NewSet[string](common.OtlpKey, common.JmxKey, common.PrometheusKey, common.EfaKey)
7272
)
7373

7474
// FindReceiversInConfig looks in the metrics and logs sections to determine which
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"agent": {
3+
"metrics_collection_interval": 120
4+
},
5+
"metrics": {
6+
"metrics_collected": {
7+
"efa": {}
8+
}
9+
}
10+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
collection_interval: 120s
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"metrics": {
3+
"metrics_collected": {
4+
"efa": {
5+
"measurement": [
6+
"efa_tx_bytes",
7+
"efa_rx_bytes"
8+
],
9+
"metrics_collection_interval": 30
10+
}
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)