Skip to content

Commit 566a75b

Browse files
authored
Enable AutoMonitor only in AppSignals supported regions (#246)
1 parent 402c44b commit 566a75b

File tree

7 files changed

+84
-3
lines changed

7 files changed

+84
-3
lines changed

.github/workflows/amazon-cloudwatch-observability-integration-test.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ jobs:
4040
strategy:
4141
matrix:
4242
# TODO: add webhooks-disabled
43-
scenario: [default, appsignals-disabled, appsignals-disabled-multi-agents, appsignals-enabled-multi-agents, webhooks-partially-enabled, webhooks-configured]
43+
scenario:
44+
- default
45+
- appsignals-disabled
46+
- appsignals-disabled-multi-agents
47+
- appsignals-enabled-multi-agents
48+
- appsignals-unsupported
49+
- webhooks-partially-enabled
50+
- webhooks-configured
4451
steps:
4552
- uses: actions/checkout@v3
4653

charts/amazon-cloudwatch-observability/templates/_helpers.tpl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ tolerations:
1919
{{- end }}
2020
{{- end }}
2121

22+
{{/*
23+
Helper function to determine monitorAllServices based on region
24+
*/}}
25+
{{- define "manager.monitorAllServices" -}}
26+
{{- $region := .Values.region | required ".Values.region is required." -}}
27+
{{- if regexMatch "ap-east-2|ap-southeast-6|cn-.*|.*-iso[a-z]*-.*" $region -}}
28+
false
29+
{{- else -}}
30+
true
31+
{{- end -}}
32+
{{- end -}}
33+
2234
{{/*
2335
Helper function to modify auto-monitor config based on agent configurations
2436
*/}}
@@ -37,6 +49,8 @@ Helper function to modify auto-monitor config based on agent configurations
3749
{{- end -}}
3850
{{- if not $hasAppSignals -}}
3951
{{- $_ := set $autoMonitorConfig "monitorAllServices" false -}}
52+
{{- else if not (hasKey $autoMonitorConfig "monitorAllServices") -}}
53+
{{- $_ := set $autoMonitorConfig "monitorAllServices" (include "manager.monitorAllServices" . | trim | eq "true") -}}
4054
{{- end -}}
4155
{{- $autoMonitorConfig | toJson -}}
4256
{{- end -}}

charts/amazon-cloudwatch-observability/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ manager:
10631063
tag: v0.7.0
10641064
applicationSignals:
10651065
autoMonitor:
1066-
monitorAllServices: true
1066+
# monitorAllServices: true; Defaults to true for regions where AppSignals is supported, false otherwise
10671067
languages:
10681068
- java
10691069
- python
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
module "base" {
5+
source = "../.."
6+
helm_values_file = "${path.module}/values.yaml"
7+
helm_dir = var.helm_dir
8+
}
9+
10+
resource "null_resource" "validator" {
11+
depends_on = [module.base.helm_release]
12+
13+
provisioner "local-exec" {
14+
command = "go test ${var.test_dir} -v -run=TestAppSignalsUnsupported"
15+
}
16+
}
17+
18+
variable "test_dir" {
19+
type = string
20+
default = "../../../../validations/minikube/scenarios"
21+
}
22+
23+
variable "helm_dir" {
24+
type = string
25+
default = "../../../../../../charts/amazon-cloudwatch-observability"
26+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
region: ap-east-2
2+
clusterName: minikube
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package scenarios
5+
6+
import (
7+
"testing"
8+
9+
"github.com/aws-observability/helm-charts/integration-tests/amazon-cloudwatch-observability/util"
10+
"github.com/aws-observability/helm-charts/integration-tests/amazon-cloudwatch-observability/validations/minikube"
11+
"github.com/stretchr/testify/assert"
12+
)
13+
14+
func TestAppSignalsUnsupported(t *testing.T) {
15+
k8sClient, err := util.NewK8sClient()
16+
assert.NoError(t, err)
17+
18+
// Validate operator deployment exists
19+
exists, err := k8sClient.ValidateDeploymentExists(minikube.Namespace, "amazon-cloudwatch-observability-controller-manager")
20+
assert.NoError(t, err)
21+
assert.True(t, exists)
22+
23+
// Validate auto-monitor-config has monitorAllServices: false
24+
// for ap-east-2 (unsupported region) even with AppSignals enabled
25+
expectedConfig := map[string]interface{}{
26+
"monitorAllServices": false,
27+
"languages": []interface{}{"java", "python", "dotnet", "nodejs"},
28+
}
29+
minikube.ValidateOperatorAutoMonitorConfig(t, expectedConfig)
30+
31+
t.Log("AppSignals unsupported region validation passed")
32+
}

integration-tests/amazon-cloudwatch-observability/validations/minikube/scenarios/default_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestDefault(t *testing.T) {
2626
assert.True(t, exists)
2727

2828
// Validate auto-monitor-config uses default values
29-
// Default config has AppSignals enabled, so monitorAllServices should be true
29+
// Default config has AppSignals enabled and us-west-2 is a supported region, so monitorAllServices should be true
3030
expectedConfig := map[string]interface{}{
3131
"monitorAllServices": true,
3232
"languages": []interface{}{"java", "python", "dotnet", "nodejs"},

0 commit comments

Comments
 (0)