Skip to content

Commit

Permalink
Merge branch 'main' into resubscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
lisguo authored Jul 24, 2024
2 parents c20af64 + b63ec24 commit f855b77
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 2 deletions.
18 changes: 18 additions & 0 deletions translator/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@
},
"metrics_aggregation_interval": {
"$ref": "#/definitions/timeIntervalWithZeroDefinition"
},
"drop_original_metrics": {
"type": "array",
"items": { "type": "string" },
"minItems": 1,
"uniqueItems": true
}
},
"additionalProperties": false
Expand Down Expand Up @@ -337,6 +343,12 @@
"type": "string",
"minLength": 1,
"maxLength": 255
},
"drop_original_metrics": {
"type": "array",
"items": { "type": "string" },
"minItems": 1,
"uniqueItems": true
}
},
"additionalProperties": false
Expand Down Expand Up @@ -471,6 +483,12 @@
},
"append_dimensions": {
"$ref": "#/definitions/generalAppendDimensionsDefinition"
},
"drop_original_metrics": {
"type": "array",
"items": { "type": "string" },
"minItems": 1,
"uniqueItems": true
}
},
"additionalProperties": false
Expand Down
10 changes: 8 additions & 2 deletions translator/tocwconfig/sampleConfig/complete_linux_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@
"collectd_typesdb": [
"/usr/share/collectd/types.db"
],
"metrics_aggregation_interval": 60
"metrics_aggregation_interval": 60,
"drop_original_metrics": [
"collectd_drop"
]
},
"cpu": {
"resources": [
Expand Down Expand Up @@ -155,7 +158,10 @@
"service_address": ":8125",
"metrics_collection_interval": 10,
"metrics_aggregation_interval": 60,
"metric_separator": "_"
"metric_separator": "_",
"drop_original_metrics": [
"statsd_drop"
]
},
"swap": {
"measurement": [
Expand Down
2 changes: 2 additions & 0 deletions translator/tocwconfig/sampleConfig/complete_linux_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ exporters:
awscloudwatch:
drop_original_metrics:
CPU_USAGE_IDLE: true
collectd_drop: true
cpu_time_active: true
statsd_drop: true
endpoint_override: https://monitoring-fips.us-west-2.amazonaws.com
force_flush_interval: 1m0s
max_datums_per_call: 1000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"metrics": {
"metrics_collected": {
"collectd": {
"drop_original_metrics": ["collectd_drop"]
},
"cpu": {
"drop_original_metrics": ["cpu_usage_idle", "time_active"],
"measurement": [
Expand All @@ -19,8 +22,18 @@
]
},
"disk": {},
"ethtool": {
"metrics_include": [
"rx_packets",
"tx_packets"
],
"drop_original_metrics": ["tx_packets"]
},
"nvidia_gpu": {
"drop_original_metrics": ["utilization_gpu", "temperature_gpu"]
},
"statsd": {
"drop_original_metrics": ["statsd_drop"]
}
},
"aggregation_dimensions" : [["ImageId"], ["InstanceId", "InstanceType"], ["d1"], []],
Expand Down
15 changes: 15 additions & 0 deletions translator/translate/otel/exporter/awscloudwatch/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ type translator struct {

var _ common.Translator[component.Config] = (*translator)(nil)

// Map to support dropping metrics without measurement.
var toDropMap = map[string]struct{}{
"collectd": {},
"statsd": {},
"ethtool": {},
}

func NewTranslator() common.Translator[component.Config] {
return NewTranslatorWithName("")
}
Expand Down Expand Up @@ -164,6 +171,14 @@ func getDropOriginalMetrics(conf *confmap.Conf) map[string]bool {
*/
if dropMetrics := common.GetArray[any](conf, dropOriginalCfgKey); dropMetrics != nil {
for _, dropMetric := range dropMetrics {
if _, in := toDropMap[category]; in {
dropMetric, ok := dropMetric.(string)
if ok {
dropOriginalMetrics[dropMetric] = true
}
continue
}

measurements := common.GetArray[any](conf, measurementCfgKey)
if measurements == nil {
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ func TestTranslator(t *testing.T) {
RollupDimensions: [][]string{{"ImageId"}, {"InstanceId", "InstanceType"}, {"d1"}, {}},
DropOriginalConfigs: map[string]bool{
"CPU_USAGE_IDLE": true,
"collectd_drop": true,
"cpu_time_active": true,
"statsd_drop": true,
"tx_packets": true,
},
},
wantWindows: &cloudwatch.Config{
Expand All @@ -131,7 +134,10 @@ func TestTranslator(t *testing.T) {
RollupDimensions: [][]string{{"ImageId"}, {"InstanceId", "InstanceType"}, {"d1"}, {}},
DropOriginalConfigs: map[string]bool{
"CPU_USAGE_IDLE": true,
"collectd_drop": true,
"cpu time_active": true,
"statsd_drop": true,
"tx_packets": true,
},
},
},
Expand Down

0 comments on commit f855b77

Please sign in to comment.