Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for OTEL Collector #106

Merged
merged 8 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/dev_environment/.vagrant
/dev_environment/*.log
4 changes: 4 additions & 0 deletions dev_environment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
55 changes: 55 additions & 0 deletions dev_environment/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,51 @@ Vagrant.configure("2") do |config|
rsync
SHELL

# Install Opentelemetry collector
roopeshsn marked this conversation as resolved.
Show resolved Hide resolved
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
;;
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
end

# # Install latest golang version
l3af.vm.provision "shell", inline: <<-SHELL
# Get cpu architecture, arm or amd
Expand Down Expand Up @@ -140,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
Expand Down
30 changes: 30 additions & 0 deletions dev_environment/cfg/otel-collector-config.yml
Original file line number Diff line number Diff line change
@@ -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: # Update the endpoint field with your desired remote backend

service:
pipelines:
metrics:
receivers: [prometheus]
processors: [batch]
exporters: [prometheusremotewrite]
1 change: 1 addition & 0 deletions dev_environment/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ configs:
host_l3af_debug_port: '38899'
host_l3afd_code_dir: '/code/l3afd'
traffic_mirroring: 'false'
otel_collector: 'false'
host_distro_codename: 'jammy'
72 changes: 72 additions & 0 deletions dev_environment/setup_linux_dev_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,55 @@ apt-get install -y bc \
prometheus \
rsync

# Install OTEL collector
roopeshsn marked this conversation as resolved.
Show resolved Hide resolved
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"
;;
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
echo "OTEL Collector version ${OTEL_VERSION} installed successfully."
fi


roopeshsn marked this conversation as resolved.
Show resolved Hide resolved
# 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 '"'`
Expand Down Expand Up @@ -149,6 +198,15 @@ 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
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
fi


if uname -a | grep -q 'WSL';
then
echo "WSL DETECTED"
Expand All @@ -160,6 +218,13 @@ then
sleep 1
/etc/init.d/grafana-server stop || true
/etc/init.d/grafana-server start || true

# Start OTEL collector
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
Expand All @@ -170,6 +235,13 @@ else
# Start and enable Grafana
systemctl restart grafana-server
systemctl enable grafana-server.service

# Start OTEL collector
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
Expand Down