chore: AWS Integration: include CWAgent metrics namespace for ec2 (#7165)

* chore: include CWAgent namespace for ec2 metrics

* chore: update aws integration service metrics connection status queried labels

* chore: fix breaking test
This commit is contained in:
Raj Kamal Singh 2025-02-21 10:45:56 +05:30 committed by GitHub
parent b6858fbfd9
commit bc907b9e61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 12 deletions

View File

@ -497,6 +497,9 @@
"cloudwatch_metric_stream_filters": [
{
"Namespace": "AWS/EC2"
},
{
"Namespace": "CWAgent"
}
]
}

View File

@ -4242,19 +4242,21 @@ func (aH *APIHandler) calculateAWSIntegrationSvcMetricsConnectionStatus(
return nil, nil
}
metricsNamespace := strategy.CloudwatchMetricsStreamFilters[0].Namespace
metricsNamespaceParts := strings.Split(metricsNamespace, "/")
if len(metricsNamespaceParts) < 2 {
return nil, model.InternalError(fmt.Errorf(
"unexpected metric namespace: %s", metricsNamespace,
))
}
expectedLabelValues := map[string]string{
"cloud_provider": "aws",
"cloud_account_id": cloudAccountId,
"service_namespace": metricsNamespaceParts[0],
"service_name": metricsNamespaceParts[1],
}
metricsNamespace := strategy.CloudwatchMetricsStreamFilters[0].Namespace
metricsNamespaceParts := strings.Split(metricsNamespace, "/")
if len(metricsNamespaceParts) >= 2 {
expectedLabelValues["service_namespace"] = metricsNamespaceParts[0]
expectedLabelValues["service_name"] = metricsNamespaceParts[1]
} else {
// metrics for single word namespaces like "CWAgent" do not
// have the service_namespace label populated
expectedLabelValues["service_name"] = metricsNamespaceParts[0]
}
metricNamesCollectedBySvc := []string{}

View File

@ -281,7 +281,7 @@ func TestConfigReturnedWhenAgentChecksIn(t *testing.T) {
for _, f := range telemetryCollectionStrategy.AWSMetrics.CloudwatchMetricsStreamFilters {
metricStreamNamespaces = append(metricStreamNamespaces, f.Namespace)
}
require.Equal([]string{"AWS/EC2", "AWS/RDS"}, metricStreamNamespaces)
require.Equal([]string{"AWS/EC2", "CWAgent", "AWS/RDS"}, metricStreamNamespaces)
require.NotNil(telemetryCollectionStrategy.AWSLogs)
logGroupPrefixes := []string{}