diff --git a/.drone/drone.yml b/.drone/drone.yml index dfb9ecaba441..c8fa382d8ddf 100644 --- a/.drone/drone.yml +++ b/.drone/drone.yml @@ -18,7 +18,7 @@ steps: - name: lint image: golangci/golangci-lint:v1.44 commands: - - apt-get update -y && apt-get install -y libsystemd-dev libbpfcc-dev + - apt-get update -y && apt-get install -y libsystemd-dev - make DOCKER_OPTS="" lint --- @@ -45,7 +45,7 @@ steps: - name: docker path: /var/run/docker.sock commands: - - apt-get update && apt-get install -y rubygems rpm nsis apt-transport-https ca-certificates curl gnupg lsb-release libbpfcc-dev + - apt-get update && apt-get install -y rubygems rpm nsis apt-transport-https ca-certificates curl gnupg lsb-release - gem install --no-document fpm - rm -r /usr/local/go - mkdir -p /usr/local/go/bin @@ -246,6 +246,6 @@ get: name: pat --- kind: signature -hmac: fecfa28d1eb83659605f42dc3f1c62ac4666a6600a993a8347eb69822375481c +hmac: b14773ba7e50432dfe90920d442a850f85aed74f1419dd78502b1e76d91cde46 ... diff --git a/CHANGELOG.md b/CHANGELOG.md index dbffd11d57e6..1227ec717afc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,8 +34,6 @@ Main (unreleased) - Introduce SNMP exporter integration. (@v-zhuravlev) -- Introduce ebpf exporter v2 integration. (@tpaschalis) - ### Enhancements - integrations-next: Integrations using autoscrape will now autoscrape metrics diff --git a/cmd/agent/Dockerfile b/cmd/agent/Dockerfile index 565a3e20ab59..cbffe0098b56 100644 --- a/cmd/agent/Dockerfile +++ b/cmd/agent/Dockerfile @@ -8,18 +8,14 @@ ARG IMAGE_TAG RUN echo "deb http://deb.debian.org/debian bullseye-backports main" >> /etc/apt/sources.list RUN apt-get update && apt-get install -t bullseye-backports -qy libsystemd-dev -# Add support for bcc bindings required to compile the eBPF integration -RUN apt-get update && apt-get install -qy libbpfcc-dev - RUN make clean && make IMAGE_TAG=${IMAGE_TAG} RELEASE_BUILD=${RELEASE_BUILD} BUILD_IN_CONTAINER=false agent FROM debian:bullseye-slim # Backports repo required to get a libsystemd version 246 or newer which is required to handle journal +ZSTD compression -# plus the libbpfcc library for running the eBPF integration. RUN echo "deb http://deb.debian.org/debian bullseye-backports main" >> /etc/apt/sources.list RUN apt-get update && apt-get install -t bullseye-backports -qy libsystemd-dev && \ - apt-get install -qy tzdata ca-certificates libbpfcc && \ + apt-get install -qy tzdata ca-certificates && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* COPY --from=build /src/agent/cmd/agent/agent /bin/agent diff --git a/cmd/agent/Dockerfile.buildx b/cmd/agent/Dockerfile.buildx index 90d5afa45add..d6b3fcaf816b 100644 --- a/cmd/agent/Dockerfile.buildx +++ b/cmd/agent/Dockerfile.buildx @@ -12,9 +12,6 @@ RUN rm -rf /usr/local/go \ && tar -C /usr/local -xzf golang.tar.gz \ && rm golang.tar.gz -# Add support for bcc bindings required to compile the eBPF integration -RUN apt-get update && apt-get install -qy libbpfcc-dev - COPY . /src/agent WORKDIR /src/agent ARG RELEASE_BUILD=true @@ -25,10 +22,9 @@ RUN make clean && IMAGE_TAG=${IMAGE_TAG} RELEASE_BUILD=${RELEASE_BUILD} BUILD_IN FROM debian:bullseye-slim # Backports repo required to get a libsystemd version 246 or newer which is required to handle journal +ZSTD compression -# plus the libbpfcc library for running the eBPF integration. RUN echo "deb http://deb.debian.org/debian bullseye-backports main" >> /etc/apt/sources.list RUN apt-get update && apt-get install -t bullseye-backports -qy libsystemd-dev && \ - apt-get install -qy tzdata ca-certificates libsystemd-dev libbpfcc && \ + apt-get install -qy tzdata ca-certificates libsystemd-dev && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* COPY --from=build /src/agent/cmd/agent/agent /bin/agent diff --git a/cmd/agentctl/Dockerfile b/cmd/agentctl/Dockerfile index c2eeb7a4ced2..bce90ca092df 100644 --- a/cmd/agentctl/Dockerfile +++ b/cmd/agentctl/Dockerfile @@ -8,18 +8,14 @@ ARG IMAGE_TAG RUN echo "deb http://deb.debian.org/debian bullseye-backports main" >> /etc/apt/sources.list RUN apt-get update && apt-get install -t bullseye-backports -qy libsystemd-dev -# Add support for bcc bindings required to compile the eBPF integration -RUN apt-get update && apt-get install -qy libbpfcc-dev - RUN make clean && make IMAGE_TAG=${IMAGE_TAG} RELEASE_BUILD=${RELEASE_BUILD} BUILD_IN_CONTAINER=false agentctl FROM debian:bullseye-slim # Backports repo required to get a libsystemd version 246 or newer which is required to handle journal +ZSTD compression -# plus the libbpfcc library for running the eBPF integration. RUN echo "deb http://deb.debian.org/debian bullseye-backports main" >> /etc/apt/sources.list RUN apt-get update && apt-get install -t bullseye-backports -qy libsystemd-dev && \ - apt-get install -qy tzdata ca-certificates libbpfcc && \ + apt-get install -qy tzdata ca-certificates && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* COPY --from=build /src/agent/cmd/agentctl/agentctl /bin/agentctl diff --git a/cmd/agentctl/Dockerfile.buildx b/cmd/agentctl/Dockerfile.buildx index 3df5bc3dea21..64b664683d2b 100644 --- a/cmd/agentctl/Dockerfile.buildx +++ b/cmd/agentctl/Dockerfile.buildx @@ -12,9 +12,6 @@ RUN rm -rf /usr/local/go \ && tar -C /usr/local -xzf golang.tar.gz \ && rm golang.tar.gz -# Add support for bcc bindings required to compile the eBPF integration -RUN apt-get update && apt-get install -qy libbpfcc-dev - COPY . /src/agent WORKDIR /src/agent ARG RELEASE_BUILD=true @@ -26,10 +23,9 @@ RUN make clean && IMAGE_TAG=${IMAGE_TAG} RELEASE_BUILD=${RELEASE_BUILD} BUILD_IN FROM debian:bullseye-slim # Backports repo required to get a libsystemd version 246 or newer which is required to handle journal +ZSTD compression -# plus the libbpfcc library for running the eBPF integration. RUN echo "deb http://deb.debian.org/debian bullseye-backports main" >> /etc/apt/sources.list RUN apt-get update && apt-get install -t bullseye-backports -qy libsystemd-dev && \ - apt-get install -qy tzdata ca-certificates libsystemd-dev libbpfcc && \ + apt-get install -qy tzdata ca-certificates libsystemd-dev && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* COPY --from=build /src/agent/cmd/agentctl/agentctl /bin/agentctl diff --git a/docs/developer/contributing.md b/docs/developer/contributing.md index 6e286b891be1..29384906d13a 100644 --- a/docs/developer/contributing.md +++ b/docs/developer/contributing.md @@ -82,14 +82,6 @@ The Makefile provides several targets: * `test`: run the tests * `lint`: run linting checks -### Compiling on Linux -Compiling the Agent on Linux requires a couple of extra dependencies. -These are -* [systemd headers](https://github.com/grafana/agent/blob/main/cmd/agent/Dockerfile#L8-L9) for Promtail -* [bcc tools](https://github.com/grafana/agent/blob/main/cmd/agent/Dockerfile#L12-L13) for the eBPF integration on AMD64 systems - -If you have issues installing the bcc tooling, you can use `-tags=noebpf` to compile the Agent without the eBPF integration. - ## Pull Request Checklist Changes should be branched off of the `main` branch. It's recommended to rebase diff --git a/docs/user/configuration/integrations/integrations-next/_index.md b/docs/user/configuration/integrations/integrations-next/_index.md index 55559a5b73e7..a2dea51fe534 100644 --- a/docs/user/configuration/integrations/integrations-next/_index.md +++ b/docs/user/configuration/integrations/integrations-next/_index.md @@ -73,7 +73,6 @@ integrations: # Configs for integrations which do not support multiple instances. [agent: ] [cadvisor: ] - [ebpf: ] [node_exporter: ] [process: ] [statsd: ] diff --git a/docs/user/configuration/integrations/integrations-next/ebpf-config.md b/docs/user/configuration/integrations/integrations-next/ebpf-config.md deleted file mode 100644 index b6aa43708358..000000000000 --- a/docs/user/configuration/integrations/integrations-next/ebpf-config.md +++ /dev/null @@ -1,59 +0,0 @@ -+++ -title = "ebpf_config" -+++ - -# ebpf_config - -The `ebpf_config` block configures the Agent's eBPF integration. -It is an embedded version of -[`ebpf_exporter`](https://github.com/cloudflare/ebpf_exporter) -that allows the Agent to attach eBPF programs to the host kernel -and export defined metrics in a Prometheus-compatible format. - -As such, this integration is only supported on Linux/AMD64, and -it comes with the relevant caveats of running eBPF programs -on your host, like being on a kernel version >4.1, specific -kernel flags being enabled, plus having superuser access. - -Currently, the exporter only supports `kprobes`, that is -kernel-space probes. - -Configuration reference: - -```yaml - ## ebpf runs the provided 'programs' on the host's kernel - ## and reports back on the metrics attached to them. - programs: - [- ... ] -``` - -Each provided [``](https://pkg.go.dev/github.com/cloudflare/ebpf_exporter@v1.2.5/config#Program) block defines a single eBPF program that the integration should run, along with what metrics should be attached to it. - -Here's an [example](https://github.com/cloudflare/ebpf_exporter/blob/master/examples/cachestat.yaml) of a valid configuration that includes a program to measure hits and misses to the file system page cache. - -```yaml -programs: -- name: cachestat - metrics: - counters: - - name: page_cache_ops_total - help: Page cache operation counters by type - table: counts - labels: - - name: op - size: 8 - decoders: - - name: ksym - kprobes: - add_to_page_cache_lru: do_count - mark_page_accessed: do_count - account_page_dirtied: do_count - mark_buffer_dirty: do_count - code: | - #include - BPF_HASH(counts, u64); - int do_count(struct pt_regs *ctx) { - counts.increment(PT_REGS_IP(ctx) - 1); - return 0; - } -``` diff --git a/go.mod b/go.mod index b8cd8455cdcb..406974777626 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.18 require ( contrib.go.opencensus.io/exporter/prometheus v0.4.0 github.com/Shopify/sarama v1.32.0 - github.com/cloudflare/ebpf_exporter v1.2.5 github.com/cortexproject/cortex v1.11.0 github.com/davidmparrott/kafka_exporter/v2 v2.0.1 github.com/docker/docker v20.10.14+incompatible @@ -289,7 +288,6 @@ require ( github.com/infinityworks/go-common v0.0.0-20170820165359-7f20a140fd37 // indirect github.com/influxdata/go-syslog/v3 v3.0.1-0.20201128200927-a1889d947b48 // indirect github.com/influxdata/telegraf v1.16.3 // indirect - github.com/iovisor/gobpf v0.2.0 // indirect github.com/jaegertracing/jaeger v1.31.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jcmturner/aescts/v2 v2.0.0 // indirect diff --git a/go.sum b/go.sum index b46ef09b3ec0..cd940dd888db 100644 --- a/go.sum +++ b/go.sum @@ -273,7 +273,6 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= -github.com/alecthomas/units v0.0.0-20210912230133-d1bdfacee922/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc= github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= @@ -480,8 +479,6 @@ github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004 h1:lkAMpLVBDaj17e85keuznYcH5rqI438v41pKcBl4ZxQ= github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004/go.mod h1:yMWuSON2oQp+43nFtAV/uvKQIFpSPerB57DCt9t8sSA= -github.com/cloudflare/ebpf_exporter v1.2.5 h1:YJhA0xPx4ubRaSqkoLF7S5m9FAWDEkWO9LP1n/vBnaw= -github.com/cloudflare/ebpf_exporter v1.2.5/go.mod h1:fBXebODa2nqqCaYS6/HZJtqH8xTKbE5nK91mlMCdvlY= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= @@ -1509,8 +1506,6 @@ github.com/influxdata/telegraf v1.16.3/go.mod h1:fX/6k7qpIqzVPWyeIamb0wN5hbwc0AN github.com/influxdata/toml v0.0.0-20190415235208-270119a8ce65/go.mod h1:zApaNFpP/bTpQItGZNNUMISDMDAnTXu9UqJ4yT3ocz8= github.com/influxdata/wlog v0.0.0-20160411224016-7c63b0a71ef8/go.mod h1:/2NMgWB1DHM1ti/gqhOlg+LJeBVk6FqR5aVGYY0hlwI= github.com/intel/goresctrl v0.2.0/go.mod h1:+CZdzouYFn5EsxgqAQTEzMfwKwuc0fVdMrT9FCCAVRQ= -github.com/iovisor/gobpf v0.2.0 h1:34xkQxft+35GagXBk3n23eqhm0v7q0ejeVirb8sqEOQ= -github.com/iovisor/gobpf v0.2.0/go.mod h1:WSY9Jj5RhdgC3ci1QaacvbFdQ8cbrEjrpiZbLHLt2s4= github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA= github.com/j-keck/arping v1.0.2/go.mod h1:aJbELhR92bSk7tp79AWM/ftfc90EfEi2bQJrbBFOsPw= github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ= @@ -2999,7 +2994,6 @@ golang.org/x/sys v0.0.0-20210903071746-97244b99971b/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/pkg/integrations/install/install.go b/pkg/integrations/install/install.go index 9d613937ce1c..d320ddf1dc40 100644 --- a/pkg/integrations/install/install.go +++ b/pkg/integrations/install/install.go @@ -30,7 +30,6 @@ import ( _ "github.com/grafana/agent/pkg/integrations/v2/agent" // register agent _ "github.com/grafana/agent/pkg/integrations/v2/app_agent_receiver" // register app_agent_receiver - _ "github.com/grafana/agent/pkg/integrations/v2/ebpf" // register ebpf integration _ "github.com/grafana/agent/pkg/integrations/v2/eventhandler" _ "github.com/grafana/agent/pkg/integrations/v2/snmp_exporter" ) diff --git a/pkg/integrations/v2/ebpf/integration.go b/pkg/integrations/v2/ebpf/integration.go deleted file mode 100644 index 5a4c2b45db0e..000000000000 --- a/pkg/integrations/v2/ebpf/integration.go +++ /dev/null @@ -1,86 +0,0 @@ -//go:build linux && amd64 && !noebpf -// +build linux,amd64,!noebpf - -package ebpf - -import ( - "fmt" - "net/http" - - ebpf_config "github.com/cloudflare/ebpf_exporter/config" - "github.com/cloudflare/ebpf_exporter/exporter" - "github.com/go-kit/log" - "github.com/grafana/agent/pkg/integrations/v2" - "github.com/grafana/agent/pkg/integrations/v2/common" - "github.com/grafana/agent/pkg/integrations/v2/metricsutils" - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/client_golang/prometheus/promhttp" -) - -// Config controls the eBPF integration. -type Config struct { - Programs []ebpf_config.Program `yaml:"programs,omitempty"` -} - -type ebpfHandler struct { - cfg *Config -} - -func init() { - integrations.Register(&Config{}, integrations.TypeSingleton) -} - -var defaultConfig = Config{ - Programs: []ebpf_config.Program{}, -} - -// UnmarshalYAML implements yaml.Unmarshaler for Config. -func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { - *c = defaultConfig - type plain Config - - return unmarshal((*plain)(c)) -} - -// ApplyDefaults applies globals to the configuration object. -func (c *Config) ApplyDefaults(globals integrations.Globals) error { return nil } - -// Identifier returns a string identifying the current integration. -func (c *Config) Identifier(globals integrations.Globals) (string, error) { return c.Name(), nil } - -// Name returns the integration's name. -func (c *Config) Name() string { return "ebpf" } - -// NewIntegration instantiates a new integrations.MetricsIntegration -// which will handle requests to the eBPF exporter. -func (c *Config) NewIntegration(l log.Logger, globals integrations.Globals) (integrations.Integration, error) { - var metricsCfg common.MetricsConfig - metricsCfg.ApplyDefaults(globals.SubsystemOpts.Metrics.Autoscrape) - - ebpf := &ebpfHandler{cfg: c} - h, err := ebpf.createHandler() - if err != nil { - return nil, err - } - - return metricsutils.NewMetricsHandlerIntegration(l, c, metricsCfg, globals, h) -} - -func (e *ebpfHandler) createHandler() (http.HandlerFunc, error) { - exp, err := exporter.New(ebpf_config.Config{Programs: e.cfg.Programs}) - if err != nil { - return nil, fmt.Errorf("failed to create ebpf exporter with input config: %s", err) - } - - err = exp.Attach() - if err != nil { - return nil, fmt.Errorf("failed to attach ebpf exporter: %s", err) - } - - return func(w http.ResponseWriter, r *http.Request) { - registry := prometheus.NewRegistry() - registry.MustRegister(exp) - h := promhttp.HandlerFor(registry, promhttp.HandlerOpts{}) - h.ServeHTTP(w, r) - }, nil -} diff --git a/pkg/integrations/v2/ebpf/integration_stub.go b/pkg/integrations/v2/ebpf/integration_stub.go deleted file mode 100644 index ec826e0e25dc..000000000000 --- a/pkg/integrations/v2/ebpf/integration_stub.go +++ /dev/null @@ -1,27 +0,0 @@ -//go:build !linux || !amd64 || noebpf -// +build !linux !amd64 noebpf - -package ebpf - -import ( - ebpf_config "github.com/cloudflare/ebpf_exporter/config" - "github.com/go-kit/log" - "github.com/go-kit/log/level" - "github.com/grafana/agent/pkg/integrations/v2" -) - -func init() { - integrations.Register(&Config{}, integrations.TypeSingleton) -} - -type Config struct { - Programs []ebpf_config.Program `yaml:"programs,omitempty"` -} - -func (c *Config) ApplyDefaults(globals integrations.Globals) error { return nil } -func (c *Config) Identifier(globals integrations.Globals) (string, error) { return c.Name(), nil } -func (c *Config) Name() string { return "ebpf" } -func (c *Config) NewIntegration(l log.Logger, globals integrations.Globals) (integrations.Integration, error) { - level.Warn(l).Log("msg", "the ebpf integration only works on linux; enabling it on other platforms will do nothing") - return integrations.NoOpIntegration, nil -} diff --git a/tools/seego/Dockerfile b/tools/seego/Dockerfile index 0f18eaf90317..45f3e51fddae 100644 --- a/tools/seego/Dockerfile +++ b/tools/seego/Dockerfile @@ -11,5 +11,3 @@ RUN rm -rf /usr/local/go \ && rm golang.tar.gz RUN apt-get update RUN apt-get install -y nsis -RUN apt-get install -y libbpfcc-dev -