eBPF
eBPF (extended Berkeley Packet Filter) is a powerful feature in the Linux kernel that allows for the safe execution of user-defined programs within the kernel space. This technology enables functionalities like packet filtering, tracing, and performance analysis without modifying kernel source code or loading custom kernel modules.
In Linux systems, the operating environment is divided into two primary spaces: kernel space and user space. Kernel space is where the operating system's core operates with full access to hardware resources like memory, CPU, and storage. Conversely, user space is where application software runs with restricted hardware access, relying on the kernel to perform low-level operations. eBPF bridges these two spaces by allowing custom code to execute safely within the kernel, providing high-performance data processing capabilities.
Traceable's eBPF Solution
Traceable utilizes eBPF to enhance its monitoring and analysis capabilities. By attaching probes to essential kernel functions involved in network socket transactions—such as open, connect, read, write, and close—Traceable can collect valuable data with minimal overhead. These probes operate based on specific parameters, enabling Traceable to decide dynamically whether to collect data, thus optimizing performance and resource usage.
The following diagram shows a high-level flow of how the Traceable's eBPF collection-based solution works:

Before you begin
Ensure that the following prerequisites are met to install an eBPF-based Traceable agent.
Linux kernel – The following kernel versions are supported with BTF (BTP Type Format) enabled:
RHEL 7 and CentOS 7- The underlying Linux kernel should be 3.10.0-1160.76 or later.
Ubuntu, Debian, and RHEL8 – The underlying Linux kernel should be 4.18 or later.
Kernel build – Linux kernel built with
CONFIG_DEBUG_INFO_BTF=yoption. To check whether Kernel is built withCONFIG_DEBUG_INFO_BTF=yoption, enter the following command and look forCONFIG_DEBUG_INFO_BTF=yoption:Capabilities –
SYS_PTRACEandSYS_ADMINcapabilities in Kubernetes. You can check this in Traceable's helm template. A snippet is shown below:Traceable agent – Traceable agent 1.19.2 or later.
Traceable access token – In the Traceable platform (UI), navigate to Settings () → Access Token and click Generate Agent Token. Copy the token.
Privileged user – The deployment requires privileged user access. Check step 2 of the Installation section for
ebpfRunAsPrivileged:true.eBPF solution works at the kernel level interception of traffic; therefore, no specific ports need to be opened to install Traceable's agent.
Installation
You have two options for installing the Traceable agent for eBPF. You can either use Helm Chart or Terraform for the installation.
Option 1 - Installation using Helm
Complete the following steps to install the Traceable agent for eBPF using Helm:
Create namespace - Enter the following command to create a separate namespace for Traceable:
Define values.yaml - Define a sample
values.yamlfile to install the agent. For example:(optional) Configure tolerations - You can configure tolerations for eBPF pods by providing the variable
ebpfTolerationsinvalues.yamlfile above. For more information, see Taints and Tolerations.Run the following command to install the Traceable agent in daemonset mode:
Verify that Traceable agent pods are created. Enter the following command:
for example, the output should be similar to:
Option 2 - Installation using Terraform
Complete the following steps to install the Traceable agent for eBPF using Terraform:
Download - Enter the following command to download the Traceable Platform agent Terraform tarball:
Untar and change directory - Enter the following command to untar the tarball and change the directory:
Create namespace - Enter the following command to create a separate namespace for Traceable:
tfvars file - Create a
terraform.tfvarsfile. A sample file is shown below.(optional) Configure tolerations - You can configure tolerations for eBPF pods by providing the variable
ebpf_tolerationsinterraform.tfvarsfile above. For more information, see Taints and Tolerations.Explanation:
ebpf_tolerations: This is a list containing the tolerations for eBPF pods.
key: The key represents the taint on the node that the toleration is targeting.
operator: The operator specifies how the toleration should be evaluated. In this example, “Exists” means that as long as the taint key exists on the node, the toleration will be valid.
value: The value is associated with the taint key, but in this case, it is set to null. This means that any value associated with the taint key is accepted.
effect: The effect determines which type of taint effect the toleration matches. In this case, the effect is “NoSchedule,” which means that the toleration allows the pod to be scheduled on nodes with the specified taint key.
toleration_seconds: This field is also set to null. It is used to specify a time duration for which the toleration is valid. In this case, since it's null, there is no specific time limit defined for the toleration.
To summarize, the given code creates an eBPF toleration that allows pods to be scheduled on nodes with the taint key “your-app” and the taint effect “NoSchedule.” The toleration is valid as long as the taint key exists on the node, regardless of the associated value.
Apply - Enter the following command to apply Terraform:
Verification- Enter the following command to verify a successful installation.
Following is an example output of a successful installation:
You can also verify a successful installation by navigating to API Catalog → Services and check for ebpf in the traceable.module.name field as shown in the screenshot below.

Independent eBPF Helm deployment
The eBPF tracer can be deployed independently using Helm, separate from the TPA Helm release. This is achieved with the existing traceable-agent Helm charts by setting a key configuration value: ebpfOnly. Following are the Helm configuration values for this deployment:
ebpfOnly— Controls whether only eBPF resources are deployed (truefor standalone eBPF).ebpfReportingEndpoint— Endpoint for reporting eBPF data.ebpfRemoteEndpoint— Remote endpoint for eBPF communication.ebpfToTpaTlsEnabled— Enables TLS between eBPF and TPA.tpaCaBundle— Base64-encoded CA cert for standalone TPA client deployments.tpaCaCertSecret— Secret containing the TPA CA cert, used in the same namespace as the eBPF DaemonSet.tpaCaCertFile— Absolute file path for the CA cert injected into the eBPF tracer container.
Example configuration
This configuration allows the independent deployment of eBPF while integrating with the Traceable platform, ensuring flexibility and security. For deployments using TLS, ensure to provide the root_ca cert, either as a base64 bundle or as a secret. Once configured, you can deploy the eBPF tracer using:
This command creates an independent Helm release for the eBPF tracer.
Enable or disable mirroring
To configure mirroring, go through the following points:
Enable mirroring for all namespaces
Mirroring is disabled by default. To enable mirroring for all namespaces, use the following configuration:
If you are using Helm, then in
values.yaml, set -daemonSetMirrorAllNamespaces: trueIf you are using Terraform, then in
main.tf, set -daemon_set_mirror_all_namespaces=true
Enable mirroring for a namespace
To enable mirroring for a namespace, set the namespace label traceableai-mirror to enabled or enter the following command:
Disable mirroring for a namespace
To disable mirroring for a namespace, set the namespace label traceableai-mirror to disabled or enter the following command:
Disable mirroring for a pod
To disable mirroring for a pod, set the pod annotation mirror.traceable.ai/enabled to false.
Set the mirroring mode
By default, only ingress traffic is captured. However, by configuring correct annotations, you can capture only egress traffic or both ingress and egress traffic.
Capture egress traffic
Set the following annotations to capture the egress traffic for a deployment or namespace.
Deployment
To capture the egress traffic, set the deployment annotation mirror.traceable.ai/mode to egress. Enter the following command:
Namespace
To capture egress traffic at the namespace level, set the annotation mirror.traceable.ai/defaultMode to egress. Enter the following:
Capture ingress and egress traffic
Set the following annotations to capture both ingress and egress traffic for a deployment or namespace.
Deployment
To capture ingress and egress traffic for a deployment, set the deployment annotation mirror.traceable.ai/mode toingress_and_egress. Enter the following command:
Namespace
To capture the ingress and egress traffic at a namespace level, set the annotation mirror.traceable.ai/defaultMode to ingress_and_egress. Enter the following command:
Capture pod label
You can capture specific pod labels in your traces, providing deeper insights into your Kubernetes deployments.
To utilize this, you need to configure the Helm value ebpfPodLabels, where you can specify the pod label keys that should be captured as span attributes. For instance, if your pods have labels like name: foobar and version: 1.19.0, and you want to capture the name label, you would configure it as follows:
After generating some traffic, the captured label will appear on the Platform as k8s.pod.label.name. If your pod label includes a more complex key structure, such as app.kubernetes.io/name, it will be displayed as k8s.pod.label.app.kubernetes.io/name.
Logs
eBPF package allows you to customize various configurations for eBPF logs. These configurations are part of ebpf-tracer-config.yaml file. Following is a snippet of the logging configurations:
The following table explains the configurations:
level
Defines the log's logging level. The values can be trace, debug, info, warn, or error. The default value is info.
encoding
Encoding sets the logger's encoding. Valid values are json or console.
output_paths
The path to which output is sent. The default value is stdout.
error_output_paths
The stream to which error logs are printed. The default value is stderr.
Log rotation
The following table explains explicitly the configurations for log rotation from the above snippet:
enabled
Defines whether you wish to enable or disable log rotation. The default value is false.
filename
The name of the file to print the logs. The default value is tracer.log.
filepath
The path to save the log file.
max_size
The file size in megabytes, after which the log file is rotated.
max_backups
The number of previous backups that are retained.
Upgrade
You can upgrade the Traceable agent in Kubernetes using the following Helm commands:
Update helm charts by entering the following command:
ActionScript
ActionScript
Enter the following command to upgrade the Traceable agent to the latest version:
ActionScript
ActionScript
Uninstall
Enter the following command to uninstall the Platform agent using Helm:
ActionScript
Troubleshooting
Troubleshooting for eBPF starts with collecting container logs. Enter the following command to collect the logs:
Following are a few of the steps that you can take to troubleshoot eBPF issues:
Verify correct configuration
The current configuration is part of the logs. As soon the configuration is parsed, it is available in the logs. A sample log entry of configuration is shown below:
Error related to BTF (BPF Type Format) not found
You are not likely to encounter this error in the latest Linux kernels, as most of them have vmlinux file in the /boot directory. The /boot directory contains the debug information that is required to run the eBPF program. The other Linux kernels which do not have vmlinux file, Traceable ships BTF files in the eBPF container. These BTF files are available on the Traceable's download site.
The ebpf-tracer first checks for vmlinux file. It then checks for BTF file locally based on the OS information. If the ebpf-tracer does not find the file, it then downloads it from the download site. If all these steps fail, reach out to Traceable support with the OS details from the log files. The OS information is available in the logs when vmlinux is not found.
Check if pods are being tracked
For each pod, the logs contain the following information:
Name : name of pod
Namespace
Service: service to which it belongs
Enabled:
trueifebpf-traceris tracking this podMode: 0 for ingress and 1 for egress
Check Statistics
You can check statistics if the requests are being parsed or requests are getting drooped.
ControlEventReceived: kprobe received from kernel for accept, connect and close calls. KProbes is a debugging mechanism for the Linux kernel which can also be used for monitoring events inside a production system. You can use it to find out performance bottlenecks, log specific events, tracing problems, and so on.
DataEventReceived: [k/u]probe (kprobes and uprobes) received from kernel with data (HTTP).
TotalRequestsParsed: Total requests parsed successfully.
ReqParsingErrors: Errors occurred during parsing of requests.
ResParsingErrors: Errors occurred during parsing of responses.
EventLost: Events lost during read from perf buffers. This happens when event consumption is slower than the event produced in the kernel.
TotalRequestsSent: Total Spans queued for sending to the Traceable Platform Agent.
TotalEventsDroppedAtEventQueueLimit:
ebpf-tracermaintains a queue of events for parsing, if this count is increasing means thatebpf-tracerneeds more CPUs.TotalEventsDroppedAtParsing: Number of events dropped during parsing of data. This can occur due to out of order events.
Check Probe Statistics
The above shown statistics list the entry and exit probe executed for a function. In some environments, you may see that Linux sometimes chooses not to execute the return probe. A possible reason could be a configuration on Linux to execute a number of parallel return probes. These parallel numbers of return probes is equal to the number of default CPUs. This is sometimes not sufficient and causes drops in return probes. If you see a large difference between the two counts of each call, then set the max_active_ret_probe in config to a higher value (10 times the number of CPUs). This setting is also available in the helm charts and terraform deployment of Traceable's Platform Agent.
Last updated
Was this helpful?