From 80d49208f971dbb871602224d324950d4c316bd7 Mon Sep 17 00:00:00 2001 From: Roopesh Saravanan Date: Sun, 7 Apr 2024 17:08:14 +0530 Subject: [PATCH 1/8] Added support for OTEL Collector Signed-off-by: Roopesh Saravanan --- .gitignore | 2 ++ dev_environment/Vagrantfile | 6 ++++ dev_environment/cfg/otel-collector-config.yml | 30 +++++++++++++++++++ dev_environment/provision.sh | 6 ++++ 4 files changed, 44 insertions(+) create mode 100644 .gitignore create mode 100644 dev_environment/cfg/otel-collector-config.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..174e953 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/dev_environment/.vagrant +/dev_environment/*.log \ No newline at end of file diff --git a/dev_environment/Vagrantfile b/dev_environment/Vagrantfile index e2753e2..d96275c 100644 --- a/dev_environment/Vagrantfile +++ b/dev_environment/Vagrantfile @@ -91,6 +91,12 @@ Vagrant.configure("2") do |config| rsync SHELL + # Install Opentelemetry collector deb package + l3af.vm.provision "shell", inline: <<-SHELL + curl --proto '=https' --tlsv1.2 -fOL https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.97.0/otelcol_0.97.0_linux_amd64.tar.gz + tar -xvf otelcol_0.97.0_linux_amd64.tar.gz + SHELL + # # Install latest golang version l3af.vm.provision "shell", inline: <<-SHELL # Get cpu architecture, arm or amd diff --git a/dev_environment/cfg/otel-collector-config.yml b/dev_environment/cfg/otel-collector-config.yml new file mode 100644 index 0000000..6ed53f4 --- /dev/null +++ b/dev_environment/cfg/otel-collector-config.yml @@ -0,0 +1,30 @@ +receivers: + prometheus: + config: + scrape_configs: + - job_name: 'otelcol' + scrape_interval: 5s + static_configs: + - targets: ['0.0.0.0:8888'] + - job_name: 'node' + scrape_interval: 5s + static_configs: + - targets: ['localhost:9100'] + - job_name: 'l3af' + scrape_interval: 5s + static_configs: + - targets: ['localhost:8898'] + +processors: + batch: + +exporters: + prometheusremotewrite: + endpoint: + +service: + pipelines: + metrics: + receivers: [prometheus] + processors: [batch] + exporters: [prometheusremotewrite] \ No newline at end of file diff --git a/dev_environment/provision.sh b/dev_environment/provision.sh index 580d03b..ff6de2b 100755 --- a/dev_environment/provision.sh +++ b/dev_environment/provision.sh @@ -22,6 +22,12 @@ systemctl daemon-reload systemctl start grafana-server systemctl enable grafana-server.service +# Copy opentelemetry collector config and restart opentelemetry collector +mkdir -p "/etc/otelcol/" +cp /vagrant/cfg/otel-collector-config.yml /etc/otelcol/config.yml +systemctl daemon-reload +./otelcol --config=/etc/otelcol/config.yml & + # Get Linux source code to build our eBPF programs against # TODO: Support building against the Linux source from the distro's source # package. From a4a76883b8c0d610b348c336fae52baa362f43f0 Mon Sep 17 00:00:00 2001 From: Roopesh Saravanan Date: Wed, 17 Apr 2024 18:26:40 +0530 Subject: [PATCH 2/8] Added support for OTEL collector in setup_linux_dev_env.sh Signed-off-by: Roopesh Saravanan --- dev_environment/Vagrantfile | 2 +- dev_environment/provision.sh | 2 +- dev_environment/setup_linux_dev_env.sh | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dev_environment/Vagrantfile b/dev_environment/Vagrantfile index d96275c..f7dc668 100644 --- a/dev_environment/Vagrantfile +++ b/dev_environment/Vagrantfile @@ -91,7 +91,7 @@ Vagrant.configure("2") do |config| rsync SHELL - # Install Opentelemetry collector deb package + # Install Opentelemetry collector l3af.vm.provision "shell", inline: <<-SHELL curl --proto '=https' --tlsv1.2 -fOL https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.97.0/otelcol_0.97.0_linux_amd64.tar.gz tar -xvf otelcol_0.97.0_linux_amd64.tar.gz diff --git a/dev_environment/provision.sh b/dev_environment/provision.sh index ff6de2b..22cb002 100755 --- a/dev_environment/provision.sh +++ b/dev_environment/provision.sh @@ -22,7 +22,7 @@ systemctl daemon-reload systemctl start grafana-server systemctl enable grafana-server.service -# Copy opentelemetry collector config and restart opentelemetry collector +# Copy opentelemetry collector config and start opentelemetry collector mkdir -p "/etc/otelcol/" cp /vagrant/cfg/otel-collector-config.yml /etc/otelcol/config.yml systemctl daemon-reload diff --git a/dev_environment/setup_linux_dev_env.sh b/dev_environment/setup_linux_dev_env.sh index d9483cb..47ecafe 100755 --- a/dev_environment/setup_linux_dev_env.sh +++ b/dev_environment/setup_linux_dev_env.sh @@ -108,6 +108,10 @@ apt-get install -y bc \ prometheus \ rsync +# Install OTEL collector +curl --proto '=https' --tlsv1.2 -fOL https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.97.0/otelcol_0.97.0_linux_amd64.tar.gz +tar -xvf otelcol_0.97.0_linux_amd64.tar.gz + # Install the latest go lang version os=`uname|tr '[:upper:]' '[:lower:]'` go_filename=`curl -s https://go.dev/dl/?mode=json|jq '.[0].files[].filename'|grep $os|grep $arch|egrep -v "ppc"|tr -d '"'` @@ -149,6 +153,11 @@ chown root:grafana /etc/grafana/provisioning/datasources/*.yaml # Copy prometheus config and restart prometheus cp /root/l3af-arch/dev_environment/cfg/prometheus.yml /etc/prometheus/prometheus.yml + +# Copy OTEL collector config and start OTEL collector +mkdir -p "/etc/otelcol/" +cp /root/l3af-arch/dev_environment/cfg/otel-collector-config.yml /etc/otelcol/config.yml + if uname -a | grep -q 'WSL'; then echo "WSL DETECTED" @@ -160,6 +169,9 @@ then sleep 1 /etc/init.d/grafana-server stop || true /etc/init.d/grafana-server start || true + + # Start OTEL collector + ./root/otelcol --config=/etc/otelcol/config.yml & else # The configuration got copied, restart the prometheus service systemctl daemon-reload @@ -170,6 +182,9 @@ else # Start and enable Grafana systemctl restart grafana-server systemctl enable grafana-server.service + + # Start OTEL collector + ./root/otelcol --config=/etc/otelcol/config.yml & fi # Get Linux source code to build our eBPF programs against From 6b3620763a997d70b9a6cda5b079f892d181b3a0 Mon Sep 17 00:00:00 2001 From: Roopesh Saravanan Date: Tue, 23 Apr 2024 22:31:13 +0530 Subject: [PATCH 3/8] fix: new line Signed-off-by: Roopesh Saravanan --- .gitignore | 2 +- dev_environment/cfg/otel-collector-config.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 174e953..4d2da66 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ /dev_environment/.vagrant -/dev_environment/*.log \ No newline at end of file +/dev_environment/*.log diff --git a/dev_environment/cfg/otel-collector-config.yml b/dev_environment/cfg/otel-collector-config.yml index 6ed53f4..3e70e73 100644 --- a/dev_environment/cfg/otel-collector-config.yml +++ b/dev_environment/cfg/otel-collector-config.yml @@ -27,4 +27,4 @@ service: metrics: receivers: [prometheus] processors: [batch] - exporters: [prometheusremotewrite] \ No newline at end of file + exporters: [prometheusremotewrite] From cc3d75084bf1c91323aa883b25a6b3b2ad24047c Mon Sep 17 00:00:00 2001 From: Roopesh Saravanan Date: Wed, 22 May 2024 19:39:41 +0530 Subject: [PATCH 4/8] fix: absolute path Signed-off-by: Roopesh Saravanan --- dev_environment/cfg/otel-collector-config.yml | 4 ++-- dev_environment/setup_linux_dev_env.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dev_environment/cfg/otel-collector-config.yml b/dev_environment/cfg/otel-collector-config.yml index 3e70e73..f4a7f37 100644 --- a/dev_environment/cfg/otel-collector-config.yml +++ b/dev_environment/cfg/otel-collector-config.yml @@ -14,12 +14,12 @@ receivers: scrape_interval: 5s static_configs: - targets: ['localhost:8898'] - + processors: batch: exporters: - prometheusremotewrite: + prometheusremotewrite: endpoint: service: diff --git a/dev_environment/setup_linux_dev_env.sh b/dev_environment/setup_linux_dev_env.sh index 47ecafe..281113f 100755 --- a/dev_environment/setup_linux_dev_env.sh +++ b/dev_environment/setup_linux_dev_env.sh @@ -171,7 +171,7 @@ then /etc/init.d/grafana-server start || true # Start OTEL collector - ./root/otelcol --config=/etc/otelcol/config.yml & + /usr/local/bin/otelcol --config=/etc/otelcol/config.yml & else # The configuration got copied, restart the prometheus service systemctl daemon-reload @@ -184,7 +184,7 @@ else systemctl enable grafana-server.service # Start OTEL collector - ./root/otelcol --config=/etc/otelcol/config.yml & + /usr/local/bin/otelcol --config=/etc/otelcol/config.yml & fi # Get Linux source code to build our eBPF programs against From 6c4f2df97b18a7908ed4a0976167d37f76b9253b Mon Sep 17 00:00:00 2001 From: Roopesh Saravanan Date: Mon, 10 Jun 2024 21:48:08 +0530 Subject: [PATCH 5/8] Added condition to install OTELC binary Signed-off-by: Roopesh Saravanan --- dev_environment/cfg/otel-collector-config.yml | 2 +- dev_environment/setup_linux_dev_env.sh | 45 ++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/dev_environment/cfg/otel-collector-config.yml b/dev_environment/cfg/otel-collector-config.yml index f4a7f37..1c970d8 100644 --- a/dev_environment/cfg/otel-collector-config.yml +++ b/dev_environment/cfg/otel-collector-config.yml @@ -20,7 +20,7 @@ processors: exporters: prometheusremotewrite: - endpoint: + endpoint: # Update the endpoint field with your desired remote backend service: pipelines: diff --git a/dev_environment/setup_linux_dev_env.sh b/dev_environment/setup_linux_dev_env.sh index 281113f..cd10c2f 100755 --- a/dev_environment/setup_linux_dev_env.sh +++ b/dev_environment/setup_linux_dev_env.sh @@ -109,8 +109,49 @@ apt-get install -y bc \ rsync # Install OTEL collector -curl --proto '=https' --tlsv1.2 -fOL https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.97.0/otelcol_0.97.0_linux_amd64.tar.gz -tar -xvf otelcol_0.97.0_linux_amd64.tar.gz +OTEL_VERSION="0.97.0" +case $ARCH in + arm) + echo "Installing OTELC for arm" + OTEL_ARCH="arm" + ;; + + aarch64) + echo "Installing OTELC for arm" + OTEL_ARCH="arm64" + ;; + + x86_64) + echo "Installing OTELC for amd64" + OTEL_ARCH="amd64" + ;; + i386) + KERNEL=$(uname -m) + if [ "$KERNEL" = "x86_64" ]; + then + echo "Installing OTELC for amd64" + OTEL_ARCH="amd64" + elif [ "$KERNEL" = "i386" ]; + then + echo "Installing OTELC for i386" + OTEL_ARCH="386" + else + echo "The CPU kernel $KERNEL is not supported by the script" + exit 1 + fi + ;; + + *) + echo "The CPU architecture $ARCH is not supported by the script" + exit 1 + ;; +esac +OTEL_BINARY="otelcol_${OTEL_VERSION}_linux_${OTEL_ARCH}.tar.gz" +OTEL_DIR="otelcol_${OTEL_VERSION}_linux_${OTEL_ARCH}" +curl --proto '=https' --tlsv1.2 -fOL "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${OTEL_VERSION}/${OTEL_BINARY}" +tar -xvf ${OTEL_BINARY} +sudo mv ${OTEL_DIR}/otelcol /usr/local/bin/otelcol +sudo chmod +x /usr/local/bin/otelcol # Install the latest go lang version os=`uname|tr '[:upper:]' '[:lower:]'` From 428ed7dc0f4769fec2c29daaae7b03b5365fad76 Mon Sep 17 00:00:00 2001 From: Roopesh Saravanan Date: Wed, 12 Jun 2024 21:18:01 +0530 Subject: [PATCH 6/8] Added condition to install OTELC binary in Vagrantfile Signed-off-by: Roopesh Saravanan --- dev_environment/Vagrantfile | 41 +++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/dev_environment/Vagrantfile b/dev_environment/Vagrantfile index f7dc668..3712fcd 100644 --- a/dev_environment/Vagrantfile +++ b/dev_environment/Vagrantfile @@ -93,8 +93,45 @@ Vagrant.configure("2") do |config| # Install Opentelemetry collector l3af.vm.provision "shell", inline: <<-SHELL - curl --proto '=https' --tlsv1.2 -fOL https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.97.0/otelcol_0.97.0_linux_amd64.tar.gz - tar -xvf otelcol_0.97.0_linux_amd64.tar.gz + OTEL_VERSION="0.97.0" + ARCH=$(uname -p) + case $ARCH in + arm) + echo "Installing OTELC for arm" + OTEL_ARCH=arm64 + ;; + aarch64) + echo "Installing OTELC for arm" + OTEL_ARCH=arm64 + ;; + x86_64) + echo "Installing OTELC for amd64" + OTEL_ARCH=amd64 + ;; + i386) + KERNEL=$(uname -m) + if [ "$KERNEL" = "x86_64" ]; + then + echo "Installing OTELC for amd64" + OTEL_ARCH=amd64 + elif [ "$KERNEL" = "i386" ]; + then + echo "Installing OTELC for i386" + OTEL_ARCH=386 + else + echo "The CPU kernel $KERNEL is not supported by the script" + exit 1 + fi + ;; + *) + echo "The CPU architecture $ARCH is not supported by the script" + exit 1 + ;; + esac + OTEL_BINARY="otelcol_${OTEL_VERSION}_linux_${OTEL_ARCH}.tar.gz" + OTEL_DIR="otelcol_${OTEL_VERSION}_linux_${OTEL_ARCH}" + curl --proto '=https' --tlsv1.2 -fOL "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${OTEL_VERSION}/${OTEL_BINARY}" + tar -xvf ${OTEL_BINARY} SHELL # # Install latest golang version From e2e893ae3f3a0bd5f91f65b32fa2769d1148e63b Mon Sep 17 00:00:00 2001 From: Roopesh Saravanan Date: Fri, 28 Jun 2024 23:12:41 +0530 Subject: [PATCH 7/8] Added conditional installation of opentelemetry collector Signed-off-by: Roopesh Saravanan --- dev_environment/README.md | 4 + dev_environment/Vagrantfile | 88 +++++++++++--------- dev_environment/config.yaml | 3 +- dev_environment/provision.sh | 6 -- dev_environment/setup_linux_dev_env.sh | 106 +++++++++++++++---------- 5 files changed, 119 insertions(+), 88 deletions(-) diff --git a/dev_environment/README.md b/dev_environment/README.md index 0377a1a..92cf5c1 100644 --- a/dev_environment/README.md +++ b/dev_environment/README.md @@ -75,3 +75,7 @@ Here is a visual overview: 3. Start traffic mirrroing via `curl -X POST http://localhost:37080/l3af/configs/v1/add -d "@cfg/traffic_mirroring_payload.json"` from the host 4. Delete the default route by executing this command (`sudo ip r del 192.168.10.50 via 192.168.10.1 dev enp0s8`) on l3af-VM as it is not required in the current vagrant environment 5. SSH into Collector VM via `vagrant ssh collector` command and execute `sudo tcpdump -i enp0s8` to see the mirrored-GUE packets and `sudo tcpdump -i gue1` to see the mirrored-original packets when we send traffic to the l3af VM web server (`hey -n 200 -c 20 http://localhost:18080`) from the host +* Additional steps if you would like to use a custom backend instead of Prometheus for observability through Opentelemetry Collector: + 1. Set `otel_collector: 'true'` in [config.yaml](config.yaml) + 2. Set `endpoint` field in [otel-collector-config.yaml](../dev_environment/cfg/otel-collector-config.yml) under `exporters` > `prometheusremotewrite`. Refer [Opentelemetry Exporters](https://opentelemetry.io/docs/collector/configuration/#exporters) documentation to know more. + 3. Redeploy the Vagrant script (`vagrant reload --provision`) to install the Opentelemetry Collector binary. \ No newline at end of file diff --git a/dev_environment/Vagrantfile b/dev_environment/Vagrantfile index 3712fcd..b548f09 100644 --- a/dev_environment/Vagrantfile +++ b/dev_environment/Vagrantfile @@ -92,47 +92,49 @@ Vagrant.configure("2") do |config| SHELL # Install Opentelemetry collector - l3af.vm.provision "shell", inline: <<-SHELL - OTEL_VERSION="0.97.0" - ARCH=$(uname -p) - case $ARCH in - arm) - echo "Installing OTELC for arm" - OTEL_ARCH=arm64 - ;; - aarch64) - echo "Installing OTELC for arm" - OTEL_ARCH=arm64 - ;; - x86_64) - echo "Installing OTELC for amd64" - OTEL_ARCH=amd64 - ;; - i386) - KERNEL=$(uname -m) - if [ "$KERNEL" = "x86_64" ]; - then + if cfg['otel_collector'] == "true" + l3af.vm.provision "shell", inline: <<-SHELL + OTEL_VERSION="0.97.0" + ARCH=$(uname -p) + case $ARCH in + arm) + echo "Installing OTELC for arm" + OTEL_ARCH=arm64 + ;; + aarch64) + echo "Installing OTELC for arm" + OTEL_ARCH=arm64 + ;; + x86_64) echo "Installing OTELC for amd64" OTEL_ARCH=amd64 - elif [ "$KERNEL" = "i386" ]; - then - echo "Installing OTELC for i386" - OTEL_ARCH=386 - else - echo "The CPU kernel $KERNEL is not supported by the script" + ;; + i386) + KERNEL=$(uname -m) + if [ "$KERNEL" = "x86_64" ]; + then + echo "Installing OTELC for amd64" + OTEL_ARCH=amd64 + elif [ "$KERNEL" = "i386" ]; + then + echo "Installing OTELC for i386" + OTEL_ARCH=386 + else + echo "The CPU kernel $KERNEL is not supported by the script" + exit 1 + fi + ;; + *) + echo "The CPU architecture $ARCH is not supported by the script" exit 1 - fi - ;; - *) - echo "The CPU architecture $ARCH is not supported by the script" - exit 1 - ;; - esac - OTEL_BINARY="otelcol_${OTEL_VERSION}_linux_${OTEL_ARCH}.tar.gz" - OTEL_DIR="otelcol_${OTEL_VERSION}_linux_${OTEL_ARCH}" - curl --proto '=https' --tlsv1.2 -fOL "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${OTEL_VERSION}/${OTEL_BINARY}" - tar -xvf ${OTEL_BINARY} - SHELL + ;; + esac + OTEL_BINARY="otelcol_${OTEL_VERSION}_linux_${OTEL_ARCH}.tar.gz" + OTEL_DIR="otelcol_${OTEL_VERSION}_linux_${OTEL_ARCH}" + curl --proto '=https' --tlsv1.2 -fOL "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${OTEL_VERSION}/${OTEL_BINARY}" + tar -xvf ${OTEL_BINARY} + SHELL + end # # Install latest golang version l3af.vm.provision "shell", inline: <<-SHELL @@ -183,6 +185,16 @@ Vagrant.configure("2") do |config| # Reboot for updated kernel to load l3af.vm.provision :reload + + # Copy opentelemetry collector config and start opentelemetry collector + if cfg['otel_collector'] == "true" + l3af.vm.provision "shell", inline: <<-SHELL + mkdir -p "/etc/otelcol/" + cp /vagrant/cfg/otel-collector-config.yml /etc/otelcol/config.yml + ./otelcol --config=/etc/otelcol/config.yml & + SHELL + end + l3af.vm.provision :shell, path: "provision.sh" # Always start test servers because they aren't managed services diff --git a/dev_environment/config.yaml b/dev_environment/config.yaml index ed4904b..e06adcc 100644 --- a/dev_environment/config.yaml +++ b/dev_environment/config.yaml @@ -7,4 +7,5 @@ configs: host_l3af_debug_port: '38899' host_l3afd_code_dir: '/code/l3afd' traffic_mirroring: 'false' - host_distro_codename: 'jammy' + otel_collector: 'false' + host_distro_codename: 'jammy' \ No newline at end of file diff --git a/dev_environment/provision.sh b/dev_environment/provision.sh index 22cb002..580d03b 100755 --- a/dev_environment/provision.sh +++ b/dev_environment/provision.sh @@ -22,12 +22,6 @@ systemctl daemon-reload systemctl start grafana-server systemctl enable grafana-server.service -# Copy opentelemetry collector config and start opentelemetry collector -mkdir -p "/etc/otelcol/" -cp /vagrant/cfg/otel-collector-config.yml /etc/otelcol/config.yml -systemctl daemon-reload -./otelcol --config=/etc/otelcol/config.yml & - # Get Linux source code to build our eBPF programs against # TODO: Support building against the Linux source from the distro's source # package. diff --git a/dev_environment/setup_linux_dev_env.sh b/dev_environment/setup_linux_dev_env.sh index cd10c2f..69c8aa8 100755 --- a/dev_environment/setup_linux_dev_env.sh +++ b/dev_environment/setup_linux_dev_env.sh @@ -109,49 +109,55 @@ apt-get install -y bc \ rsync # Install OTEL collector -OTEL_VERSION="0.97.0" -case $ARCH in - arm) - echo "Installing OTELC for arm" - OTEL_ARCH="arm" - ;; - - aarch64) - echo "Installing OTELC for arm" - OTEL_ARCH="arm64" - ;; - - x86_64) - echo "Installing OTELC for amd64" - OTEL_ARCH="amd64" - ;; - i386) - KERNEL=$(uname -m) - if [ "$KERNEL" = "x86_64" ]; - then +if [ $# -ge 1 ] && [ "$1" == "--otel-collector" ]; then + OTEL_VERSION="0.97.0" + case $ARCH in + arm) + echo "Installing OTELC for arm" + OTEL_ARCH="arm" + ;; + + aarch64) + echo "Installing OTELC for arm" + OTEL_ARCH="arm64" + ;; + + x86_64) echo "Installing OTELC for amd64" OTEL_ARCH="amd64" - elif [ "$KERNEL" = "i386" ]; - then - echo "Installing OTELC for i386" - OTEL_ARCH="386" - else - echo "The CPU kernel $KERNEL is not supported by the script" + ;; + i386) + KERNEL=$(uname -m) + if [ "$KERNEL" = "x86_64" ]; + then + echo "Installing OTELC for amd64" + OTEL_ARCH="amd64" + elif [ "$KERNEL" = "i386" ]; + then + echo "Installing OTELC for i386" + OTEL_ARCH="386" + else + echo "The CPU kernel $KERNEL is not supported by the script" + exit 1 + fi + ;; + + *) + echo "The CPU architecture $ARCH is not supported by the script" exit 1 - fi - ;; + ;; + esac + OTEL_BINARY="otelcol_${OTEL_VERSION}_linux_${OTEL_ARCH}.tar.gz" + OTEL_DIR="otelcol_${OTEL_VERSION}_linux_${OTEL_ARCH}" + curl --proto '=https' --tlsv1.2 -fOL "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${OTEL_VERSION}/${OTEL_BINARY}" + tar -xvf ${OTEL_BINARY} + sudo mv ${OTEL_DIR}/otelcol /usr/local/bin/otelcol + sudo chmod +x /usr/local/bin/otelcol + echo "OTEL Collector version ${OTEL_VERSION} installed successfully." +else + echo "Skipping OTEL Collector installation." +fi - *) - echo "The CPU architecture $ARCH is not supported by the script" - exit 1 - ;; -esac -OTEL_BINARY="otelcol_${OTEL_VERSION}_linux_${OTEL_ARCH}.tar.gz" -OTEL_DIR="otelcol_${OTEL_VERSION}_linux_${OTEL_ARCH}" -curl --proto '=https' --tlsv1.2 -fOL "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${OTEL_VERSION}/${OTEL_BINARY}" -tar -xvf ${OTEL_BINARY} -sudo mv ${OTEL_DIR}/otelcol /usr/local/bin/otelcol -sudo chmod +x /usr/local/bin/otelcol # Install the latest go lang version os=`uname|tr '[:upper:]' '[:lower:]'` @@ -196,8 +202,14 @@ chown root:grafana /etc/grafana/provisioning/datasources/*.yaml cp /root/l3af-arch/dev_environment/cfg/prometheus.yml /etc/prometheus/prometheus.yml # Copy OTEL collector config and start OTEL collector -mkdir -p "/etc/otelcol/" -cp /root/l3af-arch/dev_environment/cfg/otel-collector-config.yml /etc/otelcol/config.yml +if [ $# -ge 1 ] && [ "$1" == "--otel-collector" ]; then + echo "Copying OTEL Collector config." + mkdir -p "/etc/otelcol/" + cp /root/l3af-arch/dev_environment/cfg/otel-collector-config.yml /etc/otelcol/config.yml +else + echo "Skipping copying of OTEL Collector config." +fi + if uname -a | grep -q 'WSL'; then @@ -212,7 +224,11 @@ then /etc/init.d/grafana-server start || true # Start OTEL collector - /usr/local/bin/otelcol --config=/etc/otelcol/config.yml & + if [ $# -ge 1 ] && [ "$1" == "--otel-collector" ]; then + /usr/local/bin/otelcol --config=/etc/otelcol/config.yml & + else + echo "Skipping OTEL collector binary startup." + fi else # The configuration got copied, restart the prometheus service systemctl daemon-reload @@ -225,7 +241,11 @@ else systemctl enable grafana-server.service # Start OTEL collector - /usr/local/bin/otelcol --config=/etc/otelcol/config.yml & + if [ $# -ge 1 ] && [ "$1" == "--otel-collector" ]; then + /usr/local/bin/otelcol --config=/etc/otelcol/config.yml & + else + echo "Skipping OTEL collector binary startup." + fi fi # Get Linux source code to build our eBPF programs against From 9a522e82fc675a43a3a5b6b071d1e70879d25d84 Mon Sep 17 00:00:00 2001 From: Roopesh Saravanan Date: Wed, 3 Jul 2024 21:16:40 +0530 Subject: [PATCH 8/8] Added changes based on review comments Signed-off-by: Roopesh Saravanan --- dev_environment/config.yaml | 2 +- dev_environment/setup_linux_dev_env.sh | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/dev_environment/config.yaml b/dev_environment/config.yaml index e06adcc..3f36d3f 100644 --- a/dev_environment/config.yaml +++ b/dev_environment/config.yaml @@ -8,4 +8,4 @@ configs: host_l3afd_code_dir: '/code/l3afd' traffic_mirroring: 'false' otel_collector: 'false' - host_distro_codename: 'jammy' \ No newline at end of file + host_distro_codename: 'jammy' diff --git a/dev_environment/setup_linux_dev_env.sh b/dev_environment/setup_linux_dev_env.sh index 69c8aa8..786aca0 100755 --- a/dev_environment/setup_linux_dev_env.sh +++ b/dev_environment/setup_linux_dev_env.sh @@ -154,8 +154,6 @@ if [ $# -ge 1 ] && [ "$1" == "--otel-collector" ]; then sudo mv ${OTEL_DIR}/otelcol /usr/local/bin/otelcol sudo chmod +x /usr/local/bin/otelcol echo "OTEL Collector version ${OTEL_VERSION} installed successfully." -else - echo "Skipping OTEL Collector installation." fi @@ -206,8 +204,6 @@ if [ $# -ge 1 ] && [ "$1" == "--otel-collector" ]; then echo "Copying OTEL Collector config." mkdir -p "/etc/otelcol/" cp /root/l3af-arch/dev_environment/cfg/otel-collector-config.yml /etc/otelcol/config.yml -else - echo "Skipping copying of OTEL Collector config." fi