Skip to content

Commit fec9180

Browse files
Beyla 2.2 (#3610)
* move trace_printer to its right section * add fields in ebpf section * Bump Beyla to 2.2.3 * fix beyla tag * Fix linter * Fix linter * Update docs/sources/reference/components/beyla/beyla.ebpf.md Co-authored-by: Clayton Cornell <[email protected]> * Fix linter --------- Co-authored-by: Clayton Cornell <[email protected]>
1 parent 075cd0c commit fec9180

File tree

5 files changed

+58
-25
lines changed

5 files changed

+58
-25
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ Main (unreleased)
8484
- [0.26.0] Add option to honor original labels from event tags over labels specified in mapping configuration.
8585
- [0.27.1] Support dogstatsd extended aggregation
8686
- [0.27.2] Fix panic on certain invalid lines
87+
88+
- Upgrade `beyla.ebpf` to v2.2.3. The full list of changes can be found in the [Beyla release notes](https://github.com/grafana/beyla/releases/tag/v2.2.3). (@marctc)
8789

8890
### Bugfixes
8991

docs/sources/reference/components/beyla/beyla.ebpf.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,22 @@ You can use the following arguments with `beyla.ebpf`:
4444
| ----------------- | -------- | ----------------------------------------------------------------------------------- | ------- | -------- |
4545
| `debug` | `bool` | Enable debug mode for Beyla. | `false` | no |
4646
| `enforce_sys_caps`| `bool` | Enforce system capabilities required for eBPF instrumentation. | `false` | no |
47+
| `trace_printer` | `string` | Format for printing trace information. | `"disabled"` | no |
48+
4749

4850
`debug` enables debug mode for Beyla. This mode logs BPF logs, network logs, trace representation logs, and other debug information.
4951

5052
When `enforce_sys_caps` is set to true and the required system capabilities aren't present, Beyla aborts its startup and logs a list of the missing capabilities.
5153

54+
`trace_printer` is used to print the trace information in a specific format.
55+
The following formats are supported:
56+
57+
* `disabled`: Disables trace printing.
58+
* `counter`: Prints the trace information in a counter format.
59+
* `text`: Prints the trace information in a text format.
60+
* `json`: Prints the trace information in a JSON format.
61+
* `json_indent`: Prints the trace information in a JSON format with indentation.
62+
5263
## Blocks
5364

5465
You can use the following blocks with `beyla.ebpf`:
@@ -236,6 +247,7 @@ The `exclude_services` block configures the services to exclude for the componen
236247
| `namespace` | `string` | The namespace of the service to match. | `""` | no |
237248
| `open_ports` | `string` | The port of the running service for Beyla automatically instrumented with eBPF. | `""` | no |
238249
| `exe_path` | `string` | The path of the running service for Beyla automatically instrumented with eBPF. | `""` | no |
250+
| `containers_only` | `bool` |Restrict the discovery to processes which are running inside a container. | `false` | no |
239251

240252
`exe_path` accepts a regular expression to be matched against the full executable command line, including the directory where the executable resides on the file system.
241253

@@ -262,6 +274,7 @@ the instrumented processes need to match all the selector properties.
262274
| `namespace` | `string` | Regular expression of Kubernetes Namespaces to match. | `""` | no |
263275
| `owner_name` | `string` | Regular expression of Kubernetes owners of running Pods to match. | `""` | no |
264276
| `pod_labels` | `map(string)` | Key-value pairs of labels with keys matching Kubernetes Pods with the provided value as regular expression. | `{}` | no |
277+
| `pod_annotations` | `map(string)` | Key-value pairs of labels with keys matching Kubernetes annotations with the provided value as regular expression. | `{}` | no |
265278
| `pod_name` | `string` | Regular expression of Kubernetes Pods to match. | `""` | no |
266279
| `replicaset_name` | `string` | Regular expression of Kubernetes ReplicaSets to match. | `""` | no |
267280
| `statefulset_name` | `string` | Regular expression of Kubernetes StatefulSets to match. | `""` | no |
@@ -303,18 +316,7 @@ The `ebpf` block configures eBPF-specific settings.
303316
| `context_propagation` | `string` | Enables injecting of the Traceparent header value for outgoing HTTP requests. | `"disabled"` | no |
304317
| `high_request_volume` | `bool` | Optimize for immediate request information when response is seen. | `false` | no |
305318
| `heuristic_sql_detect` | `bool` | Enable heuristic-based detection of SQL requests. | `false` | no |
306-
| `trace_printer` | `string` | Format for printing trace information. | `"disabled"` | no |
307-
308-
`enable_context_propagation` enables context propagation using Linux Traffic Control probes.
309-
For more information about this topic, refer to [Distributed traces with Beyla][].
310-
311-
`trace_printer` is used to print the trace information in a specific format. The following formats are supported:
312319

313-
* `disabled` disables trace printing.
314-
* `counter` prints the trace information in a counter format.
315-
* `text` prints the trace information in a text format.
316-
* `json` prints the trace information in a JSON format.
317-
* `json_indent` prints the trace information in a JSON format with indentation.
318320

319321
#### `context_propagation`
320322

internal/component/beyla/ebpf/args.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ type Selection struct {
6868
type Services []Service
6969

7070
type Service struct {
71-
Name string `alloy:"name,attr,optional"`
72-
Namespace string `alloy:"namespace,attr,optional"`
73-
OpenPorts string `alloy:"open_ports,attr,optional"`
74-
Path string `alloy:"exe_path,attr,optional"`
75-
Kubernetes KubernetesService `alloy:"kubernetes,block,optional"`
71+
Name string `alloy:"name,attr,optional"`
72+
Namespace string `alloy:"namespace,attr,optional"`
73+
OpenPorts string `alloy:"open_ports,attr,optional"`
74+
Path string `alloy:"exe_path,attr,optional"`
75+
Kubernetes KubernetesService `alloy:"kubernetes,block,optional"`
76+
ContainersOnly bool `alloy:"containers_only,attr,optional"`
7677
}
7778

7879
type KubernetesService struct {
@@ -84,6 +85,7 @@ type KubernetesService struct {
8485
DaemonSetName string `alloy:"daemonset_name,attr,optional"`
8586
OwnerName string `alloy:"owner_name,attr,optional"`
8687
PodLabels map[string]string `alloy:"pod_labels,attr,optional"`
88+
PodAnnotations map[string]string `alloy:"pod_annotations,attr,optional"`
8789
}
8890

8991
type Discovery struct {
@@ -126,6 +128,8 @@ type EBPF struct {
126128
ContextPropagation string `alloy:"context_propagation,attr,optional"`
127129
HighRequestVolume bool `alloy:"high_request_volume,attr,optional"`
128130
HeuristicSQLDetect bool `alloy:"heuristic_sql_detect,attr,optional"`
131+
BpfDebug bool `alloy:"bpf_debug,attr,optional"`
132+
ProtocolDebug bool `alloy:"protocol_debug_print,attr,optional"`
129133
}
130134

131135
type Filters struct {

internal/component/beyla/ebpf/beyla_linux.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,25 @@ func (args Services) Convert() (services.DefinitionCriteria, error) {
161161
}
162162
podLabels[k] = &label
163163
}
164+
// Convert pod annotations to attributes
165+
podAnnotations := map[string]*services.RegexpAttr{}
166+
for k, v := range s.Kubernetes.PodAnnotations {
167+
annotation, err := stringToRegexpAttr(v)
168+
if err != nil {
169+
return nil, err
170+
}
171+
podAnnotations[k] = &annotation
172+
}
164173

165174
attrs = append(attrs, services.Attributes{
166-
Name: s.Name,
167-
Namespace: s.Namespace,
168-
OpenPorts: ports,
169-
Path: paths,
170-
Metadata: kubernetes,
171-
PodLabels: podLabels,
175+
Name: s.Name,
176+
Namespace: s.Namespace,
177+
OpenPorts: ports,
178+
Path: paths,
179+
Metadata: kubernetes,
180+
PodLabels: podLabels,
181+
ContainersOnly: s.ContainersOnly,
182+
PodAnnotations: podAnnotations,
172183
})
173184
}
174185
return attrs, nil
@@ -356,6 +367,8 @@ func (args EBPF) Convert() (*beylaCfg.EBPFTracer, error) {
356367
ebpf.TrackRequestHeaders = args.TrackRequestHeaders
357368
ebpf.HighRequestVolume = args.HighRequestVolume
358369
ebpf.HeuristicSQLDetect = args.HeuristicSQLDetect
370+
ebpf.BpfDebug = args.BpfDebug
371+
ebpf.ProtocolDebug = args.ProtocolDebug
359372
return &ebpf, nil
360373
}
361374

internal/component/beyla/ebpf/beyla_linux_test.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ func TestArguments_UnmarshalSyntax(t *testing.T) {
103103
http_request_timeout = "10s"
104104
high_request_volume = true
105105
heuristic_sql_detect = true
106+
bpf_debug = false
107+
protocol_debug_print = false
106108
}
107109
filters {
108110
application {
@@ -168,6 +170,8 @@ func TestArguments_UnmarshalSyntax(t *testing.T) {
168170
require.Equal(t, 10*time.Second, cfg.EBPF.HTTPRequestTimeout)
169171
require.True(t, cfg.EBPF.HighRequestVolume)
170172
require.True(t, cfg.EBPF.HeuristicSQLDetect)
173+
require.False(t, cfg.EBPF.BpfDebug)
174+
require.False(t, cfg.EBPF.ProtocolDebug)
171175
require.Len(t, cfg.Filters.Application, 1)
172176
require.Len(t, cfg.Filters.Network, 1)
173177
require.Equal(t, filter.MatchDefinition{NotMatch: "UDP"}, cfg.Filters.Application["transport"])
@@ -346,9 +350,10 @@ func TestConvert_Discovery(t *testing.T) {
346350
args := Discovery{
347351
Services: []Service{
348352
{
349-
Name: "test",
350-
Namespace: "default",
351-
OpenPorts: "80",
353+
Name: "test",
354+
Namespace: "default",
355+
OpenPorts: "80",
356+
ContainersOnly: true,
352357
},
353358
{
354359
Kubernetes: KubernetesService{
@@ -366,6 +371,7 @@ func TestConvert_Discovery(t *testing.T) {
366371
DaemonSetName: "test",
367372
OwnerName: "test",
368373
PodLabels: map[string]string{"test": "test"},
374+
PodAnnotations: map[string]string{"test": "test"},
369375
},
370376
},
371377
},
@@ -384,6 +390,7 @@ func TestConvert_Discovery(t *testing.T) {
384390
require.Equal(t, "test", config.Services[0].Name)
385391
require.Equal(t, "default", config.Services[0].Namespace)
386392
require.Equal(t, services.PortEnum{Ranges: []services.PortRange{{Start: 80, End: 0}}}, config.Services[0].OpenPorts)
393+
require.True(t, config.Services[0].ContainersOnly)
387394
require.True(t, config.Services[1].Metadata[services.AttrNamespace].IsSet())
388395
require.True(t, config.Services[1].Metadata[services.AttrDeploymentName].IsSet())
389396
_, exists := config.Services[1].Metadata[services.AttrDaemonSetName]
@@ -396,6 +403,7 @@ func TestConvert_Discovery(t *testing.T) {
396403
require.True(t, config.Services[2].Metadata[services.AttrDaemonSetName].IsSet())
397404
require.True(t, config.Services[2].Metadata[services.AttrOwnerName].IsSet())
398405
require.True(t, config.Services[2].PodLabels["test"].IsSet())
406+
require.True(t, config.Services[2].PodAnnotations["test"].IsSet())
399407
require.NoError(t, config.Services.Validate())
400408
require.Len(t, config.ExcludeServices, 1)
401409
require.Equal(t, "test", config.ExcludeServices[0].Name)
@@ -453,6 +461,8 @@ func TestConvert_EBPF(t *testing.T) {
453461
HighRequestVolume: true,
454462
HeuristicSQLDetect: true,
455463
ContextPropagation: "headers",
464+
BpfDebug: true,
465+
ProtocolDebug: true,
456466
}
457467

458468
expectedConfig := beyla.DefaultConfig.EBPF
@@ -461,6 +471,8 @@ func TestConvert_EBPF(t *testing.T) {
461471
expectedConfig.HighRequestVolume = true
462472
expectedConfig.HeuristicSQLDetect = true
463473
expectedConfig.ContextPropagation = config.ContextPropagationHeadersOnly
474+
expectedConfig.BpfDebug = true
475+
expectedConfig.ProtocolDebug = true
464476

465477
config, err := args.Convert()
466478
require.NoError(t, err)

0 commit comments

Comments
 (0)