|
1 | 1 | # logger-ebpf |
2 | | -Easily log **encrypted** API requests and responses to your own <a href="https://resurface.io">security data lake</a>. |
| 2 | +Easily log **encrypted** API calls to your own <a href="https://graylog.org/products/api-security/">security data lake</a>. |
| 3 | + |
| 4 | +This open-source [eBPF](https://ebpf.io/) agent logs API requests and responses to [Graylog API Security](https://graylog.org/products/api-security/) |
| 5 | +for analysis and storage. This agent logs encrypted API calls without configuring any encryption keys or making any changes to client or server applications. |
3 | 6 |
|
4 | 7 | [](https://www.codefactor.io/repository/github/resurfaceio/logger-ebpf) |
5 | | -[](https://github.com/resurfaceio/logger-ebpf/blob/master/LICENSE) |
6 | 8 | [](https://github.com/resurfaceio/logger-ebpf/blob/master/CONTRIBUTING.md) |
| 9 | +[](https://github.com/resurfaceio/logger-ebpf/blob/master/LICENSE) |
7 | 10 |
|
| 11 | +⚠️ [Graylog API Security](https://graylog.org/products/api-security/) is licensed and installed separately, and runs as a remote service (on Kubernetes) that receives data from this eBPF agent. |
8 | 12 |
|
9 | 13 | ## Contents |
10 | 14 |
|
11 | 15 | <ul> |
12 | | -<li><a href="#dependencies">Dependencies</a></li> |
13 | | -<li><a href="#usage">Usage</a></li> |
14 | | -<li><a href="#logging-from-container">Capturing traffic from a containerized application</a></li> |
15 | | -<li><a href="#build-from-source">Building from source</a></li> |
| 16 | +<li><a href="#system-requirements">System Requirements</a></li> |
| 17 | +<li><a href="#current-limitations">Current Limitations</a></li> |
| 18 | +<li><a href="#environment-variables">Environment Variables</a></li> |
| 19 | +<li><a href="#logging-from-linux-vm-or-physical-machine">Logging from Linux VM or Physical Machine</a></li> |
| 20 | +<li><a href="#logging-from-docker-container">Logging from Docker Container</a></li> |
| 21 | +<li><a href="#logging-from-kubernetes">Logging from Kubernetes</a></li> |
16 | 22 | <li><a href="#privacy">Protecting User Privacy</a></li> |
17 | 23 | </ul> |
18 | 24 |
|
| 25 | +<a name="system-requirements"></a> |
19 | 26 |
|
20 | | -<a name="dependencies"></a> |
21 | | - |
22 | | -## Dependencies |
23 | | - |
24 | | -Requires Linux kernel v5.8+ and OpenSSL v1.0+ |
25 | | - |
26 | | -<a name="usage"></a> |
| 27 | +## System Requirements |
27 | 28 |
|
28 | | -## Usage |
29 | | - |
30 | | -- Get the apropriate binary for your CPU arch from our [releases](https://github.com/resurfaceio/logger-ebpf/releases). |
31 | | - |
32 | | -- Set the [variables](#environment-variables) used by the logger, according to your use case. |
33 | | - |
34 | | -- Run binary as a privileged user |
35 | | - |
36 | | -```sh |
37 | | -sudo ./ebpf-logger |
38 | | -``` |
| 29 | +* 64-bit Intel or AMD CPU |
| 30 | +* Linux kernel v5.8 or higher |
| 31 | +* OpenSSL v1.0 or higher |
| 32 | +* Root privileges to run the eBPF agent binary |
| 33 | +* Network access to the Kubernetes cluster where [Graylog API Security](https://graylog.org/products/api-security/) is running |
39 | 34 |
|
40 | | -## Environment variables |
| 35 | +<a name="current-limitations"></a> |
41 | 36 |
|
42 | | -This plugin has access to five environment variables, but only two of them are required for the logger to work properly. |
| 37 | +## Current Limitations |
43 | 38 |
|
44 | | -#### ✔ All API calls are sent to the database running inside the `resurface` container |
45 | | -The environment variable `USAGE_LOGGERS_URL` stores this address, which by default should be the string `"http://localhost:7701/message"` |
46 | | -#### ✔ TLS traffic is captured directly from OpenSSL |
47 | | -Encrypted traffic is captured by adding uprobes to symbols found in the OpenSSL shared library. The environment variable `USAGE_LOGGERS_EBPF_EXPATH` specifies the path to this file. This can be found by running the following command: |
| 39 | +* ARM64 chipsets are not yet supported |
| 40 | +* API calls made via HTTP are not logged yet (only HTTPS) |
| 41 | +* Only applications using OpenSSL are supported (additional encryption libraries coming soon) |
| 42 | +* HTTP v3, UDP, and streaming protocols are not supported |
48 | 43 |
|
49 | | -```sh |
50 | | -ldconfig -p | grep ssl |
51 | | -``` |
52 | | -#### ✔ All API calls are filtered using a set of rules (Optional) |
53 | | -The environment variable `USAGE_LOGGERS_RULES` stores these [logging rules](#protecting-user-privacy) as a string. Even though this variable is optional, it is recommended to set it to `"include debug"` or `"allow_http_url"` when trying the plugin for the first time. |
54 | | -#### ✔ The Logger can capture calls in client mode (Optional) |
55 | | -You can set the environment variable `USAGE_LOGGERS_EBPF_ROLE` to `"client"` for the logger to capture API calls made from a client application (e.g. cURL). |
56 | | -#### ✔ The Logger can be disabled at any time (Optional) |
57 | | -By setting the environment variable `USAGE_LOGGERS_DISABLE` to `true` the logger will be disabled and no API calls will be logged. |
| 44 | +<a name="environment-variables"></a> |
58 | 45 |
|
| 46 | +## Environment Variables |
59 | 47 |
|
60 | | -<a name="logging-from-container"></a> |
| 48 | +These environment variables are used to configure this eBPF agent and to control what information is logged. |
61 | 49 |
|
62 | | -## Capturing traffic from a containerized application |
| 50 | +| Variable Name | Default | Description | |
| 51 | +|---------------------------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 52 | +| USAGE_LOGGERS_DISABLE | false | When `true`, the eBPF agent is loaded but no calls are logged | |
| 53 | +| USAGE_LOGGERS_EBPF_EXPATH | (none) | Path to OpenSSL shared library<br>Use `ldconfig -p \| grep ssl` to find | |
| 54 | +| USAGE_LOGGERS_EBPF_ROLE | (none) | Use `server` for inbound calls, `client` for outbound calls | |
| 55 | +| USAGE_LOGGERS_RULES | (none) | [Logging rules](https://go2docs.graylog.org/apisecurity-current/logging_rules/logging_rules.htm) used to mask or remove specific details<br>Use `import debug` to log entire request and response | |
| 56 | +| USAGE_LOGGERS_URL | (none) | [Capture URL](https://go2docs.graylog.org/apisecurity-current/capture_api_calls/capture_api_calls.htm) for Graylog API Security instance<br>Looks like `https://GL_APISECURITY_HOST/fluke/message` | |
63 | 57 |
|
64 | | -### Logging from a running container |
| 58 | +<a name="logging-from-linux-vm-or-physical-machine"></a> |
65 | 59 |
|
66 | | -- Copy the binary to the container |
67 | | -```sh |
68 | | -docker cp ebpf-logger mycontainer:/ |
69 | | -``` |
| 60 | +## Logging from Linux VM or Physical Machine |
70 | 61 |
|
71 | | -- Exec into the container |
72 | | -```sh |
73 | | -docker exec -it -u root mycontainer sh |
| 62 | +Download agent binary: |
| 63 | +```bash |
| 64 | +wget https://github.com/resurfaceio/logger-ebpf/releases/download/v1.1.0/ebpf-logger-amd64 && chmod +x ebpf-logger-amd64 |
74 | 65 | ``` |
75 | 66 |
|
76 | | -- Run the application |
77 | | -```sh |
78 | | -./ebpf-logger |
| 67 | +Run agent binary, with your value for `GL_APISECURITY_HOST`: |
| 68 | +```bash |
| 69 | +sudo USAGE_LOGGERS_EBPF_EXPATH="/lib/x86_64-linux-gnu/libssl.so.3" USAGE_LOGGERS_EBPF_ROLE="server" USAGE_LOGGERS_RULES="include debug" USAGE_LOGGERS_URL="https://GL_APISECURITY_HOST/fluke/message" ./ebpf-logger-amd64 |
79 | 70 | ``` |
80 | 71 |
|
| 72 | +⚠️ Use `CRTL-C` to stop the agent. |
81 | 73 |
|
82 | | -### Building a new image |
83 | | - |
84 | | -You can use your existing container images to build a new one that contains our binary: |
| 74 | +<a name="logging-from-docker-container"></a> |
85 | 75 |
|
86 | | -```dockerfile |
87 | | -FROM yourapp:itstag |
| 76 | +## Logging from Docker Container |
88 | 77 |
|
89 | | -ENV USAGE_LOGGERS_URL="http://172.17.0.1:7701/message" |
90 | | -ENV USAGE_LOGGERS_RULES="include debug" |
91 | | -ENV USAGE_LOGGERS_EBPF_ROLE="server" |
92 | | -# choose according to your CPU arch |
93 | | -ENV USAGE_LOGGERS_EBPF_EXPATH="/lib/x86_64-linux-gnu/libssl.so.3" |
94 | | -#ENV USAGE_LOGGERS_EBPF_EXPATH="/lib/aarch64-linux-gnu/libssl.so.3" |
| 78 | +coming soon! |
95 | 79 |
|
96 | | -COPY --chmod=755 ./ebpf-logger /usr/sbin/ebpf-logger |
97 | | -RUN mkdir /var/log/graylog_ebpf_logger && touch /var/log/graylog_ebpf_logger/out.log /var/log/graylog_ebpf_logger/err.log |
98 | | -ENTRYPOINT [ "/new-entrypoint.sh" ] |
99 | | -``` |
| 80 | +<a name="logging-from-kubernetes"></a> |
100 | 81 |
|
101 | | -With `new-entrypoint.sh` following this pattern: |
| 82 | +## Logging from Kubernetes |
102 | 83 |
|
103 | | -``` |
104 | | -#!/bin/sh |
105 | | -
|
106 | | -ebpf-logger >> /var/log/graylog_ebpf_logger/out.log 2>> /var/log/graylog_ebpf_logger/err.log & |
107 | | -# call your usual entrypoint.sh from here |
108 | | -``` |
109 | | - |
110 | | -<a name="build-from-source"></a> |
111 | | - |
112 | | -## Building from source |
113 | | - |
114 | | -Please, see our [CONTRIBUTING.md](https://github.com/resurfaceio/logger-ebpf/blob/master/CONTRIBUTING.md) guide. |
| 84 | +coming soon! |
115 | 85 |
|
116 | 86 | <a name="privacy"></a> |
117 | 87 |
|
118 | 88 | ## Protecting User Privacy |
119 | 89 |
|
120 | | -Loggers always have an active set of <a href="https://resurface.io/rules.html">rules</a> that control what data is logged |
121 | | -and how sensitive data is masked. All of the examples above apply a predefined set of rules, `include_debug`, |
122 | | -but logging rules are easily customized to meet the needs of any application. |
123 | | - |
124 | | -<a href="https://go2docs.graylog.org/apisecurity-current/logging_rules/logging_rules.htm">Logging rules documentation</a> |
| 90 | +Loggers always have an active set of [logging rules](https://go2docs.graylog.org/apisecurity-current/logging_rules/logging_rules.htm) |
| 91 | +that control what data is logged and how sensitive data is masked. All of the examples above apply a predefined set of rules (`include_debug`), |
| 92 | +but logging rules are easily customized to meet your privacy requirements. |
125 | 93 |
|
126 | 94 | --- |
127 | | -<small>© 2025 <a href="https://resurface.io">Graylog, Inc.</a></small> |
| 95 | +<small>© 2025 <a href="https://graylog.org/products/api-security/">Graylog, Inc.</a></small> |
0 commit comments