Skip to main content
Version: 1.11.0

Linux eBPF 安装

概述

ebpf-agent 是一个通过 ebpf 内核技术采集系统、应用的 metrics、traces、logs 的采集服务,并将其采集到的数据发送到 light-agent 。

前置条件

前置条件
  1. Lighthouse 平台版本最低为 1.8.0
  2. Linux 内核版本最低为 4.16(查看内核版本 uname -rcat /proc/version
  3. 禁用 SELinux:sudo setenforce 0
  4. 需要在同一台机器上安装好 light-agent

    登录 Lighthouse 平台, 进入「数据采集」模块,获取 light-agent 安装指令和安装步骤

注意事项
  1. 如果采集的服务部署在 Kubernetes 集群中,需要安装 kube-state-metrics

Systemd 服务安装方式

环境变量说明

环境变量默认值描述
COLLECTOR_ENDPOINThttp://0.0.0.0:4318指标、trace、日志的基本端点URL
METRICS_ENDPOINThttp://0.0.0.0:4318/v1/metrics发送指标的端点URL
LOGS_ENDPOINThttp://0.0.0.0:4318/v1/logs发送日志的端点URL
PROFILES_ENDPOINT-profiling 上报地址
SCRAPE_INTERVAL"15s"从代理收集指标的频率
DISABLE_LOG_PARSING"false"是否禁用容器日志解析
WAL_DIR"/tmp/ebpf-agent"代理存储数据的路径(例如:指标 Write-Ahead Log)

安装

安装的参数说明:

  • LOGS_ENDPOINT: http://127.0.0.1:54318/v1/logs127.0.0.1 是 light-agent,ip 默认是 127.0.0.1,端口号默认是 54318
  • PROFILES_ENDPOINT: http://{IP}:8085/profiling/v1/ebpfinput{IP} 需要改为 Lighthouse 平台所在机器的 ip,端口号默认是 8085
注意

ebpf agent 数据导出仅支持 http 的 otel 协议

cd /usr/local/light-agent/ebpf-agent
export LOGS_ENDPOINT=http://127.0.0.1:54318/v1/logs
export PROFILES_ENDPOINT=http://{IP}:8085/profiling/v1/ebpfinput
export WAL_DIR=/tmp/ebpf-agent
export SCRAPE_INTERVAL=15s
./ebpf-agent-install.sh

状态查看

sudo systemctl status ebpf-agent
[root@VM-Template ebpf-agent]# systemctl status ebpf-agent
● ebpf-agent.service - ebpf node agent
Loaded: loaded (/etc/systemd/system/ebpf-agent.service; enabled; preset: disabled)
Active: active (running) since Thu 2024-11-14 03:18:55 EST; 27s ago
Main PID: 69546 (ebpf-agent)
Tasks: 31
Memory: 401.7M
CPU: 6.747s
CGroup: /system.slice/ebpf-agent.service
└─69546 /usr/bin/ebpf-agent

Nov 14 03:19:03 VM-Template ebpf-agent[69546]: I1114 03:19:03.784509 69546 container.go:504] got IPs [127.0.0.1 172.17.0.2] for NS(4:4026533115)
Nov 14 03:19:03 VM-Template ebpf-agent[69546]: I1114 03:19:03.784552 69546 container.go:476] TCP listen open pid=4086643 id=/system.slice/docker.service addr=0.0.0.0:6379
Nov 14 03:19:03 VM-Template ebpf-agent[69546]: I1114 03:19:03.861143 69546 container.go:476] TCP listen open pid=4155032 id=/docker/file-server addr=0.0.0.0:80
Nov 14 03:19:04 VM-Template ebpf-agent[69546]: I1114 03:19:04.174883 69546 tls.go:251] pid=4158433 golang_app=/root/light-alert golang_version=v1.22.5: crypto/tls uprobes attached
Nov 14 03:19:04 VM-Template ebpf-agent[69546]: I1114 03:19:04.176134 69546 container.go:476] TCP listen open pid=4158433 id=/docker/light-alert addr=[::]:8088
Nov 14 03:19:04 VM-Template ebpf-agent[69546]: I1114 03:19:04.177607 69546 container.go:504] got IPs [127.0.0.1 192.168.208.9] for NS(4:4026532746)
Nov 14 03:19:04 VM-Template ebpf-agent[69546]: I1114 03:19:04.260487 69546 container.go:504] got IPs [127.0.0.1 192.168.208.13] for NS(4:4026533053)
Nov 14 03:19:05 VM-Template ebpf-agent[69546]: I1114 03:19:05.473448 69546 wrappers.go:218] level info remote_name 58595a url http://127.0.0.1:54318/v1/metrics msg Replaying WAL queue 58595a
Nov 14 03:19:11 VM-Template ebpf-agent[69546]: I1114 03:19:11.626330 69546 wrappers.go:218] level info remote_name 58595a url http://127.0.0.1:54318/v1/metrics msg Done replaying WAL duration 6.153091048s
Nov 14 03:19:15 VM-Template ebpf-agent[69546]: [258B blob data]

日志查看

使用 journalctl 命令读取代理日志:

# 全部日志
sudo journalctl -u ebpf-agent
# 流式日志输出
sudo journalctl -u ebpf-agent -f

卸载

要卸载,请运行以下命令:

/usr/local/light-agent/ebpf-agent/ebpf-agent-uninstall.sh

常用的服务操作命令

# 查看服务状态
systemctl status ebpf-agent
# 启动服务
systemctl start ebpf-agent
# 停止服务
systemctl stop ebpf-agent
# 重启服务
systemctl restart ebpf-agent

常见问题

Q:环境变量配置错误如何修改?

A:

  1. 先查看
cat /etc/systemd/system/ebpf-agent.service.env
  1. 再使用以下命令修改环境值,修改完成后重启服务 。
vi /etc/systemd/system/ebpf-agent.service.env 

# 重启服务
systemctl restart ebpf-agent

img