Skip to content

Commit f435e91

Browse files
committed
adding otel_demo capabilities
1 parent 45475cb commit f435e91

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

workshop/aws/ec2/main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ locals {
183183
realm = var.splunk_realm
184184
presetup = var.splunk_presetup
185185
jdk = var.splunk_jdk
186+
otel_demo = var.otel_demo
186187
instance_password = random_string.password.result
187188
}
188189
}
@@ -219,5 +220,10 @@ resource "aws_instance" "observability-instance" {
219220
condition = var.splunk_presetup ? try(var.splunk_access_token, "") != "" && try(var.splunk_realm, "") != "" && try(var.splunk_rum_token, "") != "" : true
220221
error_message = "When requesting a pre-setup instance, splunk_realm, splunk_access_token and splunk_rum_token are required and cannot be null/empty"
221222
}
223+
precondition {
224+
# if otel_demo=true, tokens and realm cannot be empty. also presetup cannot also be true.
225+
condition = var.otel_demo ? try(var.splunk_access_token, "") != "" && try(var.splunk_realm, "") != "" && try(var.splunk_rum_token, "") != "" && try(var.splunk_presetup, "") == false : true
226+
error_message = "When requesting an otel_demo, splunk_realm, splunk_access_token and splunk_rum_token are required and cannot be null/empty. splunk_presetup variable must also be set to false. "
227+
}
222228
}
223229
}

workshop/aws/ec2/templates/userdata.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ write_files:
8585
fi
8686
%{ endif ~}
8787

88+
%{ if otel_demo == true ~}
89+
export RUM_TOKEN=${rum_token}
90+
mkdir otel-demo && cd otel-demo
91+
curl -o otel-demo-collector.yaml https://raw.githubusercontent.com/splunk/observability-workshop/main/oteldemo/otel-demo-collector.yaml
92+
curl -o otel-demo.yaml https://raw.githubusercontent.com/splunk/observability-workshop/main/oteldemo/otel-demo.yaml
93+
if [ ! -f ~/.helmok ]; then
94+
helm repo add splunk-otel-collector-chart https://signalfx.github.io/splunk-otel-collector-chart
95+
helm repo update
96+
helm install splunk-otel-collector --set="splunkObservability.realm=$REALM" --set="splunkObservability.accessToken=$ACCESS_TOKEN" --set="clusterName=$(hostname)-k3s-cluster" --set="splunkObservability.logsEnabled=true" --set="logsEngine=otel" --set="splunkObservability.profilingEnabled=true" --set="splunkObservability.infrastructureMonitoringEventsEnabled=true" --set="networkExplorer.enabled=true" --set="networkExplorer.podSecurityPolicy.enabled=false" --set="agent.enabled=true" --set="gateway.replicaCount=1" --set="gateway.resources.limits.cpu=500m" --set="gateway.resources.limits.memory=1Gi" --set="clusterReceiver.enabled=true" --set="environment=$(hostname)-apm-env" splunk-otel-collector-chart/splunk-otel-collector -f otel-demo-collector.yaml
97+
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
98+
helm install my-otel-demo open-telemetry/opentelemetry-demo --values otel-demo.yaml
99+
cd /home/ubuntu
100+
fi
101+
%{ endif ~}
102+
103+
88104
export KUBECONFIG=/home/ubuntu/.kube/config
89105
alias kc='kubectl'
90106
alias dc='docker-compose'

workshop/aws/ec2/terraform.tfvars.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ splunk_realm = ""
1111
# optional
1212
splunk_presetup = false
1313
splunk_jdk = false
14+
otel_demo = false

workshop/aws/ec2/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ variable "splunk_jdk" {
1616
default = false
1717
}
1818

19+
variable "otel_demo" {
20+
description = "Spin up the OpenTelemetry Telescope shop demo? (true/false)"
21+
type = bool
22+
default = false
23+
}
24+
1925
variable "aws_instance_count" {
2026
description = "Instance Count (Usually 1)"
2127
nullable = false

0 commit comments

Comments
 (0)