-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add mem e2e test, clean up integ test workflow/docs * fix placeholder runner, add mem test to benchmark suite * implement mem fetcher, code cleanup * implement mem fetcher, code cleanup * remove bad metric dimension * fix measured metrics * fix fetcher names * update README, formatting * add license header
- Loading branch information
1 parent
94c654d
commit 49314b8
Showing
14 changed files
with
224 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
//go:build linux && integration | ||
// +build linux,integration | ||
|
||
package metric | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" | ||
"log" | ||
) | ||
|
||
var memSupportedMetricValues = map[string]struct{}{ | ||
"mem_active": {}, | ||
"mem_available": {}, | ||
"mem_available_percent": {}, | ||
"mem_buffered": {}, | ||
"mem_cached": {}, | ||
"mem_free": {}, | ||
"mem_inactive": {}, | ||
"mem_total": {}, | ||
"mem_used": {}, | ||
"mem_used_percent": {}, | ||
} | ||
|
||
type MemMetricValueFetcher struct { | ||
baseMetricValueFetcher | ||
} | ||
|
||
var _ MetricValueFetcher = (*MemMetricValueFetcher)(nil) | ||
|
||
func (f *MemMetricValueFetcher) Fetch(namespace, metricName string, stat Statistics) ([]float64, error) { | ||
dims := f.getMetricSpecificDimensions() | ||
values, err := f.fetch(namespace, metricName, dims, stat) | ||
if err != nil { | ||
log.Printf("Error while fetching metric value for %s: %v", metricName, err) | ||
} | ||
return values, err | ||
} | ||
|
||
func (f *MemMetricValueFetcher) isApplicable(metricName string) bool { | ||
_, exists := memSupportedMetricValues[metricName] | ||
return exists | ||
} | ||
|
||
func (f *MemMetricValueFetcher) getMetricSpecificDimensions() []types.Dimension { | ||
return []types.Dimension{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
integration/test/metric_value_benchmark/agent_configs/base_linux_config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"agent": { | ||
"metrics_collection_interval": 60, | ||
"run_as_user": "root", | ||
"debug": true, | ||
"logfile": "" | ||
}, | ||
"metrics": { | ||
"metrics_collected": { | ||
"mem": { | ||
"measurement": [ | ||
"mem_used_percent" | ||
] | ||
}, | ||
"disk": { | ||
"measurement": [ | ||
"used_percent" | ||
], | ||
"resources": [ | ||
"*" | ||
] | ||
} | ||
}, | ||
"append_dimensions": { | ||
"ImageId": "${aws:ImageId}", | ||
"InstanceId": "${aws:InstanceId}", | ||
"InstanceType": "${aws:InstanceType}", | ||
"AutoScalingGroupName": "${aws:AutoScalingGroupName}" | ||
} | ||
} | ||
} |
File renamed without changes.
22 changes: 22 additions & 0 deletions
22
integration/test/metric_value_benchmark/agent_configs/mem_config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"agent": { | ||
"metrics_collection_interval": 60, | ||
"run_as_user": "root", | ||
"debug": true, | ||
"logfile": "" | ||
}, | ||
"metrics": { | ||
"namespace": "MetricValueBenchmarkTest", | ||
"append_dimensions": { | ||
"InstanceId": "${aws:InstanceId}" | ||
}, | ||
"metrics_collected": { | ||
"mem": { | ||
"measurement": [ | ||
"active", "available", "available_percent", "buffered", "cached", "free", "inactive", "total", | ||
"used", "used_percent" | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
//go:build linux && integration | ||
// +build linux,integration | ||
|
||
package metric_value_benchmark | ||
|
||
import ( | ||
"github.com/aws/amazon-cloudwatch-agent/integration/test/metric" | ||
"github.com/aws/amazon-cloudwatch-agent/integration/test/status" | ||
"time" | ||
) | ||
|
||
type MemTestRunner struct { | ||
} | ||
|
||
var _ ITestRunner = (*MemTestRunner)(nil) | ||
|
||
func (m *MemTestRunner) validate() status.TestGroupResult { | ||
metricsToFetch := m.getMeasuredMetrics() | ||
testResults := make([]status.TestResult, len(metricsToFetch)) | ||
for i, name := range metricsToFetch { | ||
testResults[i] = m.validateMemMetric(name) | ||
} | ||
|
||
return status.TestGroupResult{ | ||
Name: m.getTestName(), | ||
TestResults: testResults, | ||
} | ||
} | ||
|
||
func (m *MemTestRunner) getTestName() string { | ||
return "Mem" | ||
} | ||
|
||
func (m *MemTestRunner) getAgentConfigFileName() string { | ||
return "mem_config.json" | ||
} | ||
|
||
func (m *MemTestRunner) getAgentRunDuration() time.Duration { | ||
return minimumAgentRuntime | ||
} | ||
|
||
func (m *MemTestRunner) getMeasuredMetrics() []string { | ||
return []string{ | ||
"mem_active", "mem_available", "mem_available_percent", "mem_buffered", "mem_cached", | ||
"mem_free", "mem_inactive", "mem_total", "mem_used", "mem_used_percent"} | ||
} | ||
|
||
func (m *MemTestRunner) validateMemMetric(metricName string) status.TestResult { | ||
testResult := status.TestResult{ | ||
Name: metricName, | ||
Status: status.FAILED, | ||
} | ||
|
||
fetcher, err := metric.GetMetricFetcher(metricName) | ||
if err != nil { | ||
return testResult | ||
} | ||
|
||
values, err := fetcher.Fetch(namespace, metricName, metric.AVERAGE) | ||
if err != nil { | ||
return testResult | ||
} | ||
|
||
if !isAllValuesGreaterThanOrEqualToZero(metricName, values) { | ||
return testResult | ||
} | ||
|
||
testResult.Status = status.SUCCESSFUL | ||
return testResult | ||
} |
Oops, something went wrong.