Compiling the Splunk OpenTelemetry Collector
This article provides a guide on how to compile the Splunk OpenTelemetry Collector, allowing you to integrate custom components and tailor the collector to specific operational requirements.
Why compile the Splunk OpenTelemetry Collector?
Compiling your own Splunk OpenTelemetry Collector offers several advantages, especially when the standard distribution doesn't meet all your needs:
- Add custom components: You can include components that are not part of the official Splunk distribution. This is often a better approach than solely relying on the OpenTelemetry Contrib, as it allows you to maintain all the benefits of the Splunk distribution.
- Retain Splunk distribution features: By compiling, you keep all the extra benefits of the Splunk distribution, such as out-of-the-box content, correlation capabilities, easy installation, and Splunk Helm Chart compatibility.
When you can engage with Splunk Support for general issues on OpenTelemetry Contrib components or custom compilations, support for is typically on a "best effort" basis. We recommend only opening P3 or P4 tickets for these issues.
How to compile the Splunk OpenTelemetry Collector
This section provides step-by-step instructions for compiling the Splunk OpenTelemetry Collector.
The compilation environment used for the examples in this article was:
- Hypervisor: UTM Hypervisor on Apple OS X
- Operating system:
debian-12-arm64-utm
image - RAM: 6000 MB (Note that segfaults were observed at the default 4GB)
1. Modify source code to include custom components
To add new components, you need to modify two key files within the splunk-otel-collector
directory: ./go.mod
which manages the module dependencies, and ./internal/components/components.go
which OpenTelemetry refers to when loading modules.
-
./go.mod
:- Add the new components along with their version numbers.
- Ensure the version numbers match the version of the collector you are compiling to avoid a cascade of broken dependencies.
-
./internal/components/components.go
:- Include the new components in the
import {}
block. - Instantiate the components using
newFactory()
.
- Include the new components in the
The blue arrow in the screenshot below shows the addition of the Azure Blob exporter to ./go.mod
.
The blue arrows in the two screenshots below show the addition of the Azure Blob exporter to ./internal/components/components.go
.
2. Compile the Collector
This step uses a Makefile to complete the remaining actions. A Makefile is a script used by the make
command to automate repetitive tasks such as compiling code, running tests, and managing dependencies. It's useful because it automates build steps, saves time, reduces human error, and ensures consistent project workflows.
In the terminal, use the Makefile below:
# Clone Splunk OpenTelemetry Collector sudo apt update sudo apt install -y git git clone https://github.com/signalfx/splunk-otel-collector # Find the version of Go to compile with cd splunk-otel-collector/ grep '^go' go.mod # Install Go sudo rm -rf /usr/local/go cd /tmp wget https://go.dev/dl/go1.23.8.linux-arm64.tar.gz sudo tar -C /usr/local -xzf go1.23.8.linux-arm64.tar.gz echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile source ~/.profile # Verify Go go version #Modify source code to include components cd ~/splunk-otel-collector vi go.mod vi internal/components/components.go go mod tidy #Compile binary sudo apt install -y make make binaries-linux_arm64 #Install and configure Docker in preparation of packaging deb sudo apt update sudo apt install -y ca-certificates curl gnupg lsb-release sudo mkdir -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg echo \ "deb [arch=$(dpkg --print-architecture) \ signed-by=/etc/apt/keyrings/docker.gpg] \ https://download.docker.com/linux/debian \ $(lsb_release -cs) stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt update sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin sudo usermod -aG docker $USER newgrp docker echo { \"dns\":[\"8.8.8.8\", \"8.8.4.4\"] } | sudo tee /etc/docker/daemon.json sudo systemctl restart docker #Deb Package make ARCH=arm64 deb-package ls dist/ #Install deb pacakge sudo dpkg -i dist/splunk-otel-collector_0.126.0-64-g95a48d6f_arm64.deb #Configure OTEL sudo mv /etc/otel/collector/splunk-otel-collector.conf.example /etc/otel/collector/splunk-otel-collector.conf sudo vi /etc/otel/collector/splunk-otel-collector.conf sudo vi /etc/otel/collector/agent_config.yaml
Next steps
While custom compilation can serve as a short-term fix for specific needs, you can help implement longer-term strategies:
- Open a Splunk idea: If you find a component or feature missing that you believe would benefit many users, consider submitting an idea to Splunk.
- Ask your Splunk representative to advocate for you: Speak to your Splunk representative and ask them to advocate within Splunk for the inclusion of the missing component in future official distributions.