Skip to content

Commit 70eaf4f

Browse files
authored
Set monitorAllServices to true and conditionally update to false if AppSignals is disabled (#240)
1 parent 41300cb commit 70eaf4f

21 files changed

Lines changed: 591 additions & 37 deletions

File tree

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

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,43 @@ jobs:
3232
- name: Build
3333
run: make all
3434

35+
Minikube-IntegrationTests:
36+
name: Minikube
37+
needs: [ Build ]
38+
runs-on: ubuntu-latest
39+
timeout-minutes: 30
40+
strategy:
41+
matrix:
42+
scenario: [default, appsignals-disabled, appsignals-disabled-multi-agents, appsignals-enabled-multi-agents]
43+
steps:
44+
- uses: actions/checkout@v3
45+
46+
- name: Start minikube
47+
uses: medyagh/setup-minikube@master
48+
with:
49+
driver: docker
50+
51+
- name: Install Terraform
52+
uses: hashicorp/setup-terraform@v3
53+
with:
54+
terraform_version: "1.1.7"
55+
56+
- name: Run scenario test
57+
run: |
58+
cd integration-tests/amazon-cloudwatch-observability/terraform/minikube/scenarios/${{ matrix.scenario }}
59+
terraform init
60+
terraform apply -auto-approve
61+
terraform destroy -auto-approve
62+
63+
- name: Cleanup on failure
64+
if: ${{ cancelled() || failure() }}
65+
run: |
66+
cd integration-tests/amazon-cloudwatch-observability/terraform/minikube/scenarios/${{ matrix.scenario }}
67+
terraform destroy -auto-approve || true
68+
3569
EKS-IntegrationTest:
3670
name: EKS-IntegrationTest
37-
needs: [ Build ]
71+
needs: [ Minikube-IntegrationTests ]
3872
runs-on: ubuntu-latest
3973
timeout-minutes: 60
4074
steps:
@@ -95,7 +129,7 @@ jobs:
95129
96130
EKS-IntegrationTest-Win2022:
97131
name: EKS-IntegrationTest-Win2022
98-
needs: [ Build ]
132+
needs: [ Minikube-IntegrationTests ]
99133
runs-on: ubuntu-latest
100134
timeout-minutes: 60
101135
steps:
@@ -156,7 +190,7 @@ jobs:
156190
157191
EKS-IntegrationTest-Win2019:
158192
name: EKS-IntegrationTest-Win2019
159-
needs: [ Build ]
193+
needs: [ Minikube-IntegrationTests ]
160194
runs-on: ubuntu-latest
161195
timeout-minutes: 60
162196
steps:

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

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

22+
{{/*
23+
Helper function to modify auto-monitor config based on agent configurations
24+
*/}}
25+
{{- define "manager.modify-auto-monitor-config" -}}
26+
{{- $autoMonitorConfig := deepCopy .Values.manager.applicationSignals.autoMonitor -}}
27+
{{- $hasAppSignals := false -}}
28+
{{- range .Values.agents -}}
29+
{{- $agent := merge . (deepCopy $.Values.agent) -}}
30+
{{- $agentConfig := $agent.config | default $agent.defaultConfig -}}
31+
{{- if and (hasKey $agentConfig "logs") (hasKey $agentConfig.logs "metrics_collected") (hasKey $agentConfig.logs.metrics_collected "application_signals") -}}
32+
{{- $hasAppSignals = true -}}
33+
{{- end -}}
34+
{{- if and (hasKey $agentConfig "traces") (hasKey $agentConfig.traces "traces_collected") (hasKey $agentConfig.traces.traces_collected "application_signals") -}}
35+
{{- $hasAppSignals = true -}}
36+
{{- end -}}
37+
{{- end -}}
38+
{{- if not $hasAppSignals -}}
39+
{{- $_ := set $autoMonitorConfig "monitorAllServices" false -}}
40+
{{- end -}}
41+
{{- $autoMonitorConfig | toJson -}}
42+
{{- end -}}
43+
2244
{{/*
2345
Helper function to modify cloudwatch-agent config
2446
*/}}

charts/amazon-cloudwatch-observability/templates/operator-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ spec:
2828
args:
2929
- {{ printf "--auto-instrumentation-config=%s" (dict "java" (merge .Values.manager.autoInstrumentationResources.java .Values.manager.autoInstrumentationConfiguration.java) "python" (merge .Values.manager.autoInstrumentationResources.python .Values.manager.autoInstrumentationConfiguration.python) "dotnet" (merge .Values.manager.autoInstrumentationResources.dotnet .Values.manager.autoInstrumentationConfiguration.dotnet) "nodejs" (.Values.manager.autoInstrumentationResources.nodejs) | toJson) | quote }}
3030
- {{ printf "--auto-annotation-config=%s" (.Values.manager.autoAnnotateAutoInstrumentation | toJson) | quote }}
31-
- {{ printf "--auto-monitor-config=%s" (.Values.manager.applicationSignals.autoMonitor | toJson) | quote }}
31+
- {{ printf "--auto-monitor-config=%s" (include "manager.modify-auto-monitor-config" .) | quote }}
3232
- "--auto-instrumentation-java-image={{ template "auto-instrumentation-java.image" . }}"
3333
- "--auto-instrumentation-python-image={{ template "auto-instrumentation-python.image" . }}"
3434
- "--auto-instrumentation-dotnet-image={{ template "auto-instrumentation-dotnet.image" . }}"

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: false
1066+
monitorAllServices: true
10671067
languages:
10681068
- java
10691069
- python
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
terraform {
5+
required_providers {
6+
helm = {
7+
source = "hashicorp/helm"
8+
version = "~> 2.0"
9+
}
10+
kubernetes = {
11+
source = "hashicorp/kubernetes"
12+
version = "~> 2.0"
13+
}
14+
}
15+
}
16+
17+
provider "kubernetes" {
18+
config_path = "~/.kube/config"
19+
}
20+
21+
provider "helm" {
22+
kubernetes {
23+
config_path = "~/.kube/config"
24+
}
25+
}
26+
27+
resource "null_resource" "minikube_start" {
28+
provisioner "local-exec" {
29+
command = <<-EOT
30+
minikube start --driver=docker --kubernetes-version=${var.k8s_version}
31+
minikube status
32+
EOT
33+
}
34+
35+
provisioner "local-exec" {
36+
when = destroy
37+
command = "minikube delete"
38+
}
39+
}
40+
41+
resource "helm_release" "cloudwatch_observability" {
42+
depends_on = [null_resource.minikube_start]
43+
44+
name = "amazon-cloudwatch-observability"
45+
namespace = "amazon-cloudwatch"
46+
create_namespace = true
47+
chart = var.helm_dir
48+
49+
values = [file(var.helm_values_file)]
50+
}
51+
52+
output "helm_release" {
53+
value = helm_release.cloudwatch_observability
54+
}
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+
variable "helm_dir" {
11+
type = string
12+
default = "../../../../../../charts/amazon-cloudwatch-observability"
13+
}
14+
15+
resource "null_resource" "validator" {
16+
depends_on = [module.base.helm_release]
17+
18+
provisioner "local-exec" {
19+
command = "go test ${var.test_dir} -v -run=TestAppSignalsDisabledMultiAgents"
20+
}
21+
}
22+
23+
variable "test_dir" {
24+
type = string
25+
default = "../../../../validations/minikube/scenarios"
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
region: us-west-2
2+
clusterName: minikube
3+
4+
agents:
5+
- name: cloudwatch-agent
6+
config:
7+
{
8+
"logs": {
9+
"metrics_collected": {
10+
"kubernetes": {
11+
"enhanced_container_insights": true
12+
}
13+
}
14+
}
15+
}
16+
- name: cloudwatch-agent-prom
17+
mode: deployment
18+
config:
19+
{
20+
"metrics": {
21+
"metrics_collected": {
22+
"prometheus": {
23+
"prometheus_config_path": "/test/path"
24+
}
25+
}
26+
}
27+
}
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+
variable "helm_dir" {
11+
type = string
12+
default = "../../../../../../charts/amazon-cloudwatch-observability"
13+
}
14+
15+
resource "null_resource" "validator" {
16+
depends_on = [module.base.helm_release]
17+
18+
provisioner "local-exec" {
19+
command = "go test ${var.test_dir} -v -run=TestAppSignalsDisabled"
20+
}
21+
}
22+
23+
variable "test_dir" {
24+
type = string
25+
default = "../../../../validations/minikube/scenarios"
26+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
region: us-west-2
2+
clusterName: minikube
3+
4+
agents:
5+
- name: cloudwatch-agent
6+
config:
7+
{
8+
"logs": {
9+
"metrics_collected": {
10+
"kubernetes": {
11+
"enhanced_container_insights": true
12+
}
13+
}
14+
}
15+
}
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_dir = var.helm_dir
7+
helm_values_file = "${path.module}/values.yaml"
8+
}
9+
10+
variable "helm_dir" {
11+
type = string
12+
default = "../../../../../../charts/amazon-cloudwatch-observability"
13+
}
14+
15+
resource "null_resource" "validator" {
16+
depends_on = [module.base.helm_release]
17+
18+
provisioner "local-exec" {
19+
command = "go test ${var.test_dir} -v -run=TestAppSignalsEnabledMultiAgents"
20+
}
21+
}
22+
23+
variable "test_dir" {
24+
type = string
25+
default = "../../../../validations/minikube/scenarios"
26+
}

0 commit comments

Comments
 (0)